Dark Bit Factory & Gravity
PROGRAMMING => Purebasic => Topic started by: Omnikam on April 17, 2017
-
After Discovering the beautiful world of GLSL shaders`s i wanted to be able to render Gfx on top of it, A nice logo for example? Thus began the quest, and after what seemed like forever i achieved my goal
This Project has evolved a lot and so ive updated the scope to include a scroller.
I learned so much on this project, pushed by inc to work out solution`s to problems i have grown in confidence.
Credit to Pjay for his original GLSL shader compiler and Samual from purebasic forum for his excellent image to Gltexture procedure and enhancement to Pjay`s code
The goal of this project was not to use other people's shaders in my demo's, the goal was how to incorporate textured logo's while using glsl shaders, this later expanded to a scroller, my intentions is to leave code that will help other's trying to combine shaders with textured quads. It must be added that the scroller was pulled straight out of pjays Vroom remake
The attachment contains everything needed to compile, Just 2 warnings
You must disable make unicode exe from compile options
You will need PureBasic 5,44 or 5.40 tested it on latest 5.60, but it wont work
; deactivate Create Unicode Executable in Compiler
;EnableExplicit
#WindowWidth=640 : #WindowHeight = 240 : #TopBorder = 18 : #BottomBorder = 18 : #ActualWindowHeight = 240*2
InitSound()
CatchMusic(1,?music,?musend-?music); Get our Music
MusicVolume(1,10);
UsePNGImageDecoder()
Enumeration ;/ Window
#Window_Main
EndEnumeration
Enumeration ;/ Gadget
#Gad_OpenGL
EndEnumeration
Structure System
Event.i
Exit.i
MouseX.i
MouseY.i
App_CurrentTime.i
App_StartTime.i
Editor_LastText.s
Shader_Vertex_Text.s
Shader_Fragment_Text.s
Shader_Vertex.i
Shader_Fragment.i
Shader_Program.i
Shader_Uniform_Time.i
Shader_Uniform_Resolution.i
Shader_Uniform_Mouse.i
Shader_Uniform_SurfacePosition.i
fragtext.s
EndStructure
Global System.System
Structure Scrolltext
Letter_Texture_Pos.f
Letter_Texture_Posy.f
X.l
EndStructure
Structure Copper
length.l
r.c[1000]
g.c[1000]
b.c[1000]
RGB.i[1000]
EndStructure
;
Procedure test() ;Load our fragment shader from our included binardy text file
System\fragtext = PeekS(? Nurbs)
EndProcedure
#GL_VERTEX_SHADER = $8B31
#GL_FRAGMENT_SHADER = $8B30
#GL_BGR = $80E0
#GL_BGRA = $80E1
Prototype glCreateShader(type.l)
Prototype glCreateProgram()
Prototype glCompileShader(shader.l)
Prototype glDeleteShader(ShaderObj.i)
Prototype glLinkProgram(shader.l)
Prototype glUseProgram(shader.l)
Prototype glAttachShader(Program.l, shader.l)
Prototype glShaderSource(shader.l, numOfStrings.l, *strings, *lenOfStrings) :
Prototype glGetUniformLocation(Program.i, name.s)
Prototype glUniform1i(location.i, v0.i)
Prototype glUniform2i(location.i, v0.i, v1.i)
Prototype glUniform1f(location.i, v0.f)
Prototype glUniform2f(location.i, v0.f, v1.f)
Prototype glGetShaderInfoLog(shader.i, bufSize.l, *length_l, *infoLog)
Declare CompileShader(VertexShader.s, FragmentShader.s)
Declare FreeShaderSourceBuf(*p)
Declare GetShaderSourceBuf(*shader)
Declare Render()
Declare SetupOpenGL()
Declare SetupGLTexture(ImageHandle.i); test
Define.i CTR
Define.i Event
Global.i Image1
Global.i Texture1
Global.i font
Global.i Texture
Global Quit.i, DrawnFrames.i, Offset.f, Font_Lookup_Text.S, MyLoop.i, Copper1.Copper, Max_Balls = 100, BallSpeed.f=0.04
Global ST_Base1.f,ST_Base2.f, ST_Next.i, ST_FontWidth.w = 30, ST_Texture_Width.f = 0.0625, ST_Font_Gap.w = 2, ST_Text.S, ST_Position.i, ST_Delay_Scroller.i, Pages.i = 6
Global Colours.i, Page.i, Current_Page.i = 1, Current_Letter.i, Page_Swap_Duration.i = 280, Page_Swap_Time.i = 200, Current_Line.i, Current_Letter.i, PT_Delay.i=1, PT_Update.i
Global Dim MiniText.s(Pages,3,40), Dim Text_Page.s(3,40), NewList Scrolltext.Scrolltext()
Global Font_Lookup_Text.S = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.!:,'?-£$/[]+ "
Global ST_Text = " AFTER MANY MANY DAYS OF TRIAL AND ERROR EVERYTHING IS WORKING ILL LEAVE IT TO OTHERS TO FINE TUNE APPHA BLENDING WAS A PROBLEM BUT I WORKED IT OUT CASE CLOSED"
Define.i EveryOther, Event.i, SoundAvailable.i
;Now we create textures which can be used for rendering with OpenGL.
;{ Window, OpenGL + other bits setup
OpenWindow(#Window_Main, 0, 0, #WindowWidth, #ActualWindowHeight,"test",#PB_Window_ScreenCentered|#PB_Window_BorderLess)
OpenGLGadget(0, 0, 0,WindowWidth(0),WindowHeight(0),#PB_OpenGL_Keyboard|#PB_OpenGL_FlipSynchronization|#PB_OpenGL_8BitStencilBuffer|#PB_Window_BorderLess)
SetGadgetAttribute(#Gad_OpenGL,#PB_OpenGL_Cursor,#PB_Cursor_Invisible)
SetWindowPos_(WindowID(0),#HWND_TOPMOST,0,0,0,0,#SWP_NOMOVE|#SWP_NOSIZE)
;
glEnable_(#GL_BLEND) : glBlendFunc_(#GL_SRC_ALPHA, #GL_ONE_MINUS_SRC_ALPHA);
glDepthMask_(#GL_FALSE) : glDisable_(#GL_DEPTH_TEST)
glEnable_(#GL_CULL_FACE) : glCullFace_(#GL_BACK)
glMatrixMode_(#GL_PROJECTION): glLoadIdentity_()
glDisable_(#GL_LIGHTING)
glOrtho_(0, #WindowWidth-1, 0, #WindowHeight-1, 0, 1)
;/ read copperlist
Restore Copperlist: ;copd:
Read.w Copper1\length
For MyLoop=1 To Copper1\length
Read.B Copper1\r[MyLoop] : Read.B Copper1\g[MyLoop] : Read.B Copper1\b[MyLoop]
Copper1\r[MyLoop] * 15 : Copper1\r[MyLoop] * 1.133
Copper1\g[MyLoop] * 15 : Copper1\g[MyLoop] * 1.133
Copper1\b[MyLoop] * 15 : Copper1\b[MyLoop] * 1.133
Next
ShowCursor_(0)
test(): ;Fragment shader text
PlayMusic(1)
;}
;THIS IS FOR OUR LOGO ONLY; USES A DIFFERENT PROCEDURE TO THE SCROLLER TEXTURE
;Load images
Image1 = CatchImage(#PB_Any, ?MyLogo)
;Now we create textures which can be used For rendering With OpenGL.
Texture1 = SetupGLTexture(Image1)
;Get OpenGL functions
Global glCreateShader.glCreateShader = wglGetProcAddress_("glCreateShader")
Global glCreateProgram.glCreateProgram = wglGetProcAddress_("glCreateProgram")
Global glCompileShader.glCompileShader = wglGetProcAddress_("glCompileShader")
Global glDeleteShader.glDeleteShader = wglGetProcAddress_("glDeleteShader")
Global glLinkProgram.glLinkProgram = wglGetProcAddress_("glLinkProgram")
Global glUseProgram.glUseProgram = wglGetProcAddress_("glUseProgram")
Global glAttachShader.glAttachShader = wglGetProcAddress_("glAttachShader")
Global glShaderSource.glShaderSource = wglGetProcAddress_("glShaderSource")
Global glGetUniformLocation.glGetUniformLocation = wglGetProcAddress_("glGetUniformLocation")
Global glUniform1i.glUniform1i = wglGetProcAddress_("glUniform1i")
Global glUniform2i.glUniform2i = wglGetProcAddress_("glUniform2i")
Global glUniform1f.glUniform1f = wglGetProcAddress_("glUniform1f")
Global glUniform2f.glUniform2f = wglGetProcAddress_("glUniform2f")
Global glGetShaderInfoLog.glGetShaderInfoLog = wglGetProcAddress_("glGetShaderInfoLog")
;Store the shaders within string variables.
System\Shader_Vertex_Text = "attribute vec3 position;"+Chr(10)+
"attribute vec2 surfacePosAttrib;"+Chr(10)+
"varying vec2 surfacePosition;"+Chr(10)+
"void main() {"+Chr(10)+
" surfacePosition = surfacePosAttrib;"+Chr(10)+
" gl_Position = vec4( position, 1.0 );"+Chr(10)+
; "gl_TexCoord[0] = gl_MultiTexCoord0; );"+Chr(10)+
"}"
System\Shader_Fragment_Text = System\fragtext;"uniform float time;"+Chr(10)
;Setup system data
With System
\Shader_Program = CompileShader(\Shader_Vertex_Text, \Shader_Fragment_Text)
glUseProgram(\Shader_Program)
If System\Shader_Program = 0
MessageRequester("Unsupported Device?","No Shader Support Available",#PB_MessageRequester_Ok)
End
EndIf
\App_StartTime = ElapsedMilliseconds()
;/ store shader uniform locations
; Debug "Shader: "+\Shader_Program
\Shader_Uniform_Time = glGetUniformLocation(\Shader_Program, "time")
\Shader_Uniform_Mouse = glGetUniformLocation(\Shader_Program, "mouse")
;resolution is blacking out the shader not really sure why.
;\Shader_Uniform_Resolution = glGetUniformLocation(\Shader_Program, "resolution")
\Shader_Uniform_SurfacePosition = glGetUniformLocation(\Shader_Program, "surfacePosition")
;Debug "Time location: "+\Shader_Uniform_Time
; Debug "Mouse location: "+\Shader_Uniform_Mouse
;Debug "Res location: "+\Shader_Uniform_Resolution
; Debug "SurfacePos location: "+\Shader_Uniform_SurfacePosition
EndWith
Procedure SmallFontText() ;/ updates the draws the top ticker-text
Protected X.i, Y.i, SmT_YSize.i = 9, Smt_Ypos.i, Letter.s, Lup.l, txPos.f, txPosY.f, ST_Xpos.f, ST_Width.i
If DrawnFrames > Page_Swap_Time
;/ swap between the two pages
PT_Update-1
If PT_Update < 1
Current_Letter+1
If Current_Letter = 41 : Current_Letter = 0 : : Current_Line + 1 : EndIf
If Current_Line < 4
Text_Page.S(Current_Line,Current_Letter) = MiniText(Current_Page,Current_Line,Current_Letter)
EndIf
If Current_Line = 4 : Current_Line = 0 : Page_Swap_Time = DrawnFrames + Page_Swap_Duration : Current_Page + 1 : EndIf
If Current_Page > Pages : Current_Page = 1 : EndIf
PT_Update = PT_Delay
PT_Delay + 1
If PT_Delay = 3 : PT_Delay = 1 : EndIf
EndIf
EndIf
;/ render
glEnable_(#GL_TEXTURE_2D) : glBindTexture_(#GL_TEXTURE_2D,Smallfont)
glBegin_(#GL_QUADS)
glColor4f_(1.0,1.0,1.0,1.0)
For Y=0 To 3
For X=1 To 40
Smt_Ypos = 201-(Y*(SmT_YSize))
Letter.s = Text_Page(Y,X)
If Letter <> "" And Letter <> " "
Lup.l = FindString("ABCDEFGHIJKLMNOPQRSTUVWXYZ!0123456789'()@,.-:;<>?ccccccccccccccccccc ",Letter.s,0)-1
txPos.f = (Lup*8)/256.0
ST_Xpos = ((X-1)*16)+0 : ST_Width = 15
txPosY.f = 0
If txPos.f > 1-0.03125
txPosY.f = 0.03124
txPos - 1
EndIf
glTexCoord2f_(txPos,txPosY+0) :glVertex2i_(ST_Xpos,Smt_Ypos+SmT_YSize-1)
glTexCoord2f_(txPos,txPosY+0.027343) :glVertex2i_(ST_Xpos,Smt_Ypos)
glTexCoord2f_(txPos+0.027343,txPosY+0.027343) :glVertex2i_(ST_Xpos+ST_Width,Smt_Ypos)
glTexCoord2f_(txPos+0.027343,txPosY+0) :glVertex2i_(ST_Xpos+ST_Width,Smt_Ypos+SmT_YSize-1)
EndIf
Next
Next
glEnd_()
EndProcedure
;Texture Procedure for Logo, Could have done away with the other but it would have taken time, plus this procedure requies fliping the image
;and i didnt want to have to rewrite the scroller texture handler
Procedure SetupGLTexture(ImageHandle.i)
Define.i ImageW, ImageH, ImageD
Define.i MemoryAddress
Define.i TextureHandle
If IsImage(ImageHandle) = 0
ProcedureReturn #False
EndIf
ImageD = ImageDepth(ImageHandle, #PB_Image_InternalDepth)
StartDrawing(ImageOutput(ImageHandle))
MemoryAddress = DrawingBuffer()
StopDrawing()
If MemoryAddress = 0
ProcedureReturn #False
EndIf
glGenTextures_(1, @TextureHandle)
glBindTexture_(#GL_TEXTURE_2D, TextureHandle)
ImageW = ImageWidth(ImageHandle)
ImageH = ImageHeight(ImageHandle)
If ImageD = 32
glTexImage2D_(#GL_TEXTURE_2D, 0, 4, ImageW, ImageH, 0, #GL_BGRA, #GL_UNSIGNED_BYTE, MemoryAddress)
Else
glTexImage2D_(#GL_TEXTURE_2D, 0, 3, ImageW, ImageH, 0, #GL_BGR, #GL_UNSIGNED_BYTE, MemoryAddress)
EndIf
glTexParameteri_(#GL_TEXTURE_2D, #GL_TEXTURE_MIN_FILTER, #GL_LINEAR)
glTexParameteri_(#GL_TEXTURE_2D, #GL_TEXTURE_MAG_FILTER, #GL_LINEAR)
ProcedureReturn TextureHandle
EndProcedure
;/ *** Texture loading / processing Font textueing
Procedure LoadTexture_(Texture.i) ; Returns the texture for an OpenGL application
Protected Width.i, Height.i, NWidth.i, NHeight.i, X.i, Y.i, Colour.i, I.i, R.i, G.i, B.i, Tex.i
If Texture = 0 : CatchImage(1, ?Bigtext) : EndIf
If Texture = 3 : CatchImage(1, ?Smallfont): EndIf
Width = ImageWidth(1)
Height = ImageHeight(1)
NWidth = Width : NHeight = Height
If NWidth > NHeight : NHeight = NWidth : EndIf ;/ had to force equal width / height due to compatability issues
If NHeight > NWidth : NWidth = NHeight : EndIf ;/
Dim ImageData.c(NWidth * NHeight * 4)
ImageD = ImageDepth(Texture, #PB_Image_InternalDepth)
StartDrawing(ImageOutput(1))
For Y=0 To NHeight-1
For X=0 To NWidth-1
If Y>Height-1 Or X>Width
Colour = 0 ;/ speeds up loading
Else
Colour = Point(X,Y)
r=Red(Colour) : g=Green(Colour) : b=Blue(Colour)
ImageData(i)=b : i+1
ImageData(i)=g : i+1
ImageData(i)=r : i+1
ImageData(i)= 255
EndIf
If r<15 And g<15 And b<15 : ImageData(i)=0 : EndIf
i+1
Next
Next
StopDrawing()
glGenTextures_(1, @tex.i)
glBindTexture_(#GL_TEXTURE_2D, tex)
If ImageD = 32
glTexParameteri_(#GL_TEXTURE_2D, #GL_TEXTURE_MIN_FILTER, #GL_LINEAR)
glTexParameteri_(#GL_TEXTURE_2D, #GL_TEXTURE_MAG_FILTER, #GL_LINEAR)
Else
glTexParameteri_(#GL_TEXTURE_2D, #GL_TEXTURE_MAG_FILTER, #GL_NEAREST)
glTexParameteri_(#GL_TEXTURE_2D, #GL_TEXTURE_MIN_FILTER, #GL_NEAREST)
glTexParameteri_(#GL_TEXTURE_2D,#GL_TEXTURE_WRAP_S, #GL_CLAMP)
glTexParameteri_(#GL_TEXTURE_2D,#GL_TEXTURE_WRAP_T, #GL_CLAMP)
EndIf
If ImageD = 32
glTexImage2D_(#GL_TEXTURE_2D, 0,4 , NWidth, NHeight, 0, #GL_BGRA, #GL_UNSIGNED_BYTE, @ImageData());
Else
glTexImage2D_(#GL_TEXTURE_2D, 0, #GL_RGBA, NWidth, NHeight, 0, #GL_BGRA_EXT, #GL_UNSIGNED_BYTE, @ImageData());
EndIf
FreeImage(1)
Dim ImageData(0)
ProcedureReturn tex
EndProcedure
Procedure CopperTexture_() ; Returns the OpenGL texture
Protected Height.i, X.i, Y.i, I.i, Tex.i
Height = Copper1\length
Dim ImageData.c(Height*Height*4)
For Y=1 To Height
For X=1 To Height
ImageData(i)=Copper1\b[Y] : i+1
ImageData(i)=Copper1\g[Y] : i+1
ImageData(i)=Copper1\r[Y] : i+1
ImageData(i)=255 : i+1
Next
Next
glGenTextures_(1, @tex)
glBindTexture_(#GL_TEXTURE_2D, tex)
glTexParameteri_(#GL_TEXTURE_2D, #GL_TEXTURE_MAG_FILTER, #GL_NEAREST)
glTexParameteri_(#GL_TEXTURE_2D, #GL_TEXTURE_MIN_FILTER, #GL_NEAREST)
glTexParameteri_(#GL_TEXTURE_2D,#GL_TEXTURE_WRAP_S, #GL_CLAMP)
glTexParameteri_(#GL_TEXTURE_2D,#GL_TEXTURE_WRAP_T, #GL_CLAMP)
glTexImage2D_(#GL_TEXTURE_2D, 0, #GL_RGBA, Height, Height, 0, #GL_BGRA_EXT, #GL_UNSIGNED_BYTE, @ImageData());
Dim ImageData(0)
ProcedureReturn tex
EndProcedure
Global MyTexture.i = LoadTexture_(0), Smallfont.i = LoadTexture_(3), CopperTexture.i = CopperTexture_()
Procedure Rainbow_Copper() ;/ draws the rainbow texture over the stencil mask
glEnable_(#GL_TEXTURE_2D) : glBindTexture_(#GL_TEXTURE_2D,CopperTexture)
glBegin_(#GL_QUADS)
glColor4f_(1.0,1.0,1.0,1.0)
glTexCoord2f_(0,0) :glVertex2i_(0,171)
glTexCoord2f_(0,0.45) :glVertex2i_(0,41)
glTexCoord2f_(1,0.45) :glVertex2i_(#WindowWidth,41)
glTexCoord2f_(1,0) :glVertex2i_(#WindowWidth,171)
glEnd_()
glDisable_(#GL_STENCIL_TEST)
EndProcedure
Procedure Draw_ScrollText() ;/ updates and draws the scrolltext on to the stencil buffer
Protected letter$, Mult.i, YPos.i, YSize.i, Timmy.f, X.i, tY.f, TopM.f, BotM.f, HySize.f
glEnable_(#GL_BLEND) : glBlendFunc_(#GL_SRC_ALPHA, #GL_ONE_MINUS_SRC_ALPHA);
glColorMask_(#GL_FALSE, #GL_FALSE, #GL_FALSE, #GL_FALSE);
glDepthMask_(#GL_TRUE);
glEnable_(#GL_STENCIL_TEST);
glStencilFunc_(#GL_ALWAYS, 1, $FFFFFFFF);
glStencilOp_(#GL_REPLACE, #GL_REPLACE, #GL_REPLACE);
glEnable_(#GL_ALPHA_TEST)
glAlphaFunc_(#GL_GREATER ,0.0)
;/ update
If ST_Delay_Scroller = 0
ForEach ScrollText()
scrolltext()\X - 2
If scrolltext()\X < -ST_FontWidth : DeleteElement(scrolltext()) : EndIf
Next
If DrawnFrames >= ST_Next; And ST_Delay_Scroller = 0
ST_Position + 1 : If ST_Position > Len(ST_Text) : ST_Position = 0 : EndIf
letter$ = Mid(ST_Text,ST_Position,1)
If letter$ = "|" : ST_Delay_Scroller = 100 : ST_Next + 100: letter$ = " " : EndIf
If letter$<>" "
AddElement(scrolltext())
scrolltext()\X = #WindowWidth
scrolltext()\Letter_Texture_Pos = FindString(Font_Lookup_Text,letter$,0)-1
Mult = Int(scrolltext()\Letter_Texture_Pos / 16)
scrolltext()\Letter_Texture_Pos = scrolltext()\Letter_Texture_Pos - (Mult*16)
scrolltext()\Letter_Texture_Posy = Mult;*16
EndIf
ST_Next + (ST_FontWidth/2) + ST_Font_Gap
EndIf
Else
ST_Delay_Scroller - 1
EndIf
;/ render
glEnable_(#GL_TEXTURE_2D) : glBindTexture_(#GL_TEXTURE_2D,MyTexture)
glBegin_(#GL_QUADS)
YPos = #WindowHeight/2.4 : YSize = 32 : ST_Base1.f + 0.08 : ST_Base2.f + 0.14
glColor4f_(1.0,1.0,1.0,1.0)
timmy.f = Sin(offset/30.0)*0.5
ForEach Scrolltext()
X = scrolltext()\X
tY.f=(Sin(ST_Base1+(X/120))*(#WindowHeight/(5.5+timmy))) ; ;Y.f=(Sin(base2+((X+20)/50))-Sin(base1+(X/40)))*80 ;/ double base
YSize = 14 + (Sin(ST_Base2+X/360.0)*7.0)
HySize.f = YSize/2.0
TopM.f = 0.0580 : BotM.f = 0.005
;/ top
glTexCoord2f_((ST_Texture_Width*scrolltext()\Letter_Texture_Pos),(ST_Texture_Width*scrolltext()\Letter_Texture_Posy)+0.0585) : glVertex2i_(X,(tY+YPos-HySize)-1)
glTexCoord2f_((ST_Texture_Width*scrolltext()\Letter_Texture_Pos)+0.0585,(ST_Texture_Width*scrolltext()\Letter_Texture_Posy)+0.0585) : glVertex2i_(X+ST_FontWidth+2,(tY+YPos-HySize)-1)
glTexCoord2f_((ST_Texture_Width*scrolltext()\Letter_Texture_Pos)+0.0585,(ST_Texture_Width*scrolltext()\Letter_Texture_Posy)+TopM) : glVertex2i_(X+ST_FontWidth+2,(tY+YPos-HySize))
glTexCoord2f_((ST_Texture_Width*scrolltext()\Letter_Texture_Pos),(ST_Texture_Width*scrolltext()\Letter_Texture_Posy)+TopM) : glVertex2i_(X,(tY+YPos-HySize))
;/ middle
glTexCoord2f_((ST_Texture_Width*scrolltext()\Letter_Texture_Pos),(ST_Texture_Width*scrolltext()\Letter_Texture_Posy)+TopM) : glVertex2i_(X,tY+YPos-HySize)
glTexCoord2f_((ST_Texture_Width*scrolltext()\Letter_Texture_Pos)+0.0585,(ST_Texture_Width*scrolltext()\Letter_Texture_Posy)+TopM) : glVertex2i_(X+ST_FontWidth+2,tY+YPos-HySize)
glTexCoord2f_((ST_Texture_Width*scrolltext()\Letter_Texture_Pos)+0.0585,(ST_Texture_Width*scrolltext()\Letter_Texture_Posy)+BotM) : glVertex2i_(X+ST_FontWidth+2,tY+YPos+YSize)
glTexCoord2f_((ST_Texture_Width*scrolltext()\Letter_Texture_Pos),(ST_Texture_Width*scrolltext()\Letter_Texture_Posy)+BotM) : glVertex2i_(X,tY+YPos+YSize)
;/ bottom
glTexCoord2f_((ST_Texture_Width*scrolltext()\Letter_Texture_Pos),(ST_Texture_Width*scrolltext()\Letter_Texture_Posy)+BotM) : glVertex2i_(X,tY+YPos+YSize)
glTexCoord2f_((ST_Texture_Width*scrolltext()\Letter_Texture_Pos)+0.0585,(ST_Texture_Width*scrolltext()\Letter_Texture_Posy)+BotM) : glVertex2i_(X+ST_FontWidth+2,tY+YPos+YSize)
glTexCoord2f_((ST_Texture_Width*scrolltext()\Letter_Texture_Pos)+0.0585,(ST_Texture_Width*scrolltext()\Letter_Texture_Posy)+0.000) : glVertex2i_(X+ST_FontWidth+2,tY+YPos+YSize+2)
glTexCoord2f_((ST_Texture_Width*scrolltext()\Letter_Texture_Pos),(ST_Texture_Width*scrolltext()\Letter_Texture_Posy)+0.000) : glVertex2i_(X,tY+YPos+YSize+2)
Next
glEnd_()
glDisable_(#GL_TEXTURE_2D) : glColorMask_(#GL_TRUE, #GL_TRUE, #GL_TRUE, #GL_TRUE);
glStencilFunc_(#GL_EQUAL, 1, $FFFFFFFF) : glStencilOp_(#GL_KEEP, #GL_KEEP, #GL_KEEP);
EndProcedure
;LOGO QUADS AND TEXTURE BINDING
Procedure Draw_My_Logo() ;/ Create Our Quad Draw Then Bind Our Nice LOGO Texture
glEnable_(#GL_TEXTURE_2D) :
glBindTexture_(#GL_TEXTURE_2D,Texture1); Texture created
glMatrixMode_(#GL_TEXTURE);
glLoadIdentity_()
;
glScalef_(1.0, -1.0, 1.0);; Flips the texture right way up
glBegin_(#GL_QUADS)
glTexCoord2f_(0,1) :
glVertex2i_(159,50)
glTexCoord2f_(1,1) :
glVertex2i_(500,50)
glTexCoord2f_(1,0) :
glVertex2i_(500,150)
glTexCoord2f_(0,0) :
glVertex2i_(159,150)
glEnd_()
glDisable_(#GL_TEXTURE_2D)
glLoadIdentity_();
EndProcedure
;\\\\\\\\\MAIN LOOP\\\\\\\\\
;{/ Main Loop
Repeat
Event = WindowEvent()
System\MouseX = WindowMouseX(#Window_Main)
System\MouseY = WindowMouseY(#Window_Main)
System\App_CurrentTime = ElapsedMilliseconds()
Render() ;Shader rendering
Draw_ScrollText() ;/ Main Scroller
Rainbow_Copper() ;/ Colour the scroller
Draw_My_Logo() ;/ Draw Our Nice Logo
;/ Update the BorderLines colour position
everyother = 1 - everyother : If everyother : offset.f + 1 : EndIf
;/ Flip buffers
DrawnFrames + 1
a=a+0.1
SetGadgetAttribute(#Gad_OpenGL,#PB_OpenGL_FlipBuffers,#True)
Repeat ;/ check for escape key & clear other events
Event = WindowEvent()
Select Event
Case #PB_Event_Gadget ;/ must be our opengl gadget
If EventType() = #PB_EventType_KeyDown
If GetGadgetAttribute(#Gad_OpenGL,#PB_OpenGL_Key ) = #VK_ESCAPE
Quit = #True
EndIf
EndIf
EndSelect
Until Not Event
glClear_(#GL_COLOR_BUFFER_BIT | #GL_STENCIL_BUFFER_BIT)
Until Quit = #True
;}
Procedure CompileShader(VertexShader.s, FragmentShader.s)
Define.i shader_program
Define.i vs, fs
Define.i *vbuff, *fbuff
*vbuff = GetShaderSourceBuf(@VertexShader)
*fbuff = GetShaderSourceBuf(@FragmentShader)
vs = glCreateShader(#GL_VERTEX_SHADER)
glShaderSource(vs, 1, @*vbuff, #Null)
glCompileShader(vs)
fs = glCreateShader(#GL_FRAGMENT_SHADER)
glShaderSource(fs, 1, @*fbuff, #Null)
glCompileShader(fs)
shader_program = glCreateProgram()
glAttachShader(shader_program, fs)
glDeleteShader(fs)
glAttachShader(shader_program, vs)
glDeleteShader(vs)
glLinkProgram(shader_program)
FreeShaderSourceBuf(*vbuff)
FreeShaderSourceBuf(*fbuff)
ProcedureReturn shader_program
EndProcedure
Procedure FreeShaderSourceBuf(*p)
CompilerIf #PB_Compiler_Unicode
If *p
FreeMemory(*p)
EndIf
CompilerEndIf
EndProcedure
Procedure GetShaderSourceBuf(*shader)
Protected *p, l, t$
CompilerIf #PB_Compiler_Unicode
t$ = PeekS(*shader, -1) : l = Len(t$)
*p = AllocateMemory(l + SizeOf(Character))
If *p
PokeS(*p, t$, l, #PB_Ascii)
EndIf
CompilerElse
*p = *shader
CompilerEndIf
ProcedureReturn *p
EndProcedure
Procedure Render()
glClear_(#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT)
glClearColor_(0.2, 0.2, 0.2, 0.1)
glUseProgram(System\Shader_Program)
;/ set shader Uniform values
glUniform2f(System\Shader_Uniform_Resolution, 640, 480)
glUniform1f(System\Shader_Uniform_Time,(System\App_CurrentTime-System\App_StartTime)/1000)
glUniform2i(System\Shader_Uniform_SurfacePosition,System\MouseX,System\MouseY)
glBegin_(#GL_QUADS)
glVertex3f_(-1,-1,0)
glVertex3f_( 1,-1,0)
glVertex3f_( 1, 1,0)
glVertex3f_(-1, 1,0)
glEnd_()
glUseProgram(0)
EndProcedure
DataSection
Smallfont:
IncludeBinary "SmallFont.bmp"
Smalltextend:
Bigtext:
IncludeBinary "Font.bmp"
Bigtextend:
MyLogo:
IncludeBinary "9.png"
MyLogoEnd:
Nurbs:
IncludeBinary "Fire2.txt"
NurbsEnd:
Data.b 0
music:
IncludeBinary"pop.mod"
musend:
CopperList:
Data.w 256
Data.B $F,$3,$0 ,$F,$4,$0 ,$F,$5,$0 ,$F,$6,$0 ,$F,$7,$0 ,$F,$8,$0 ,$F,$9,$0 ,$F,$A,$0 ,$F,$B,$0 ,$F,$C,$0
Data.B $F,$D,$0 ,$F,$E,$0 ,$F,$F,$0 ,$E,$F,$0 ,$D,$F,$0 ,$C,$F,$0 ,$B,$F,$0 ,$A,$F,$0 ,$9,$F,$0 ,$8,$F,$0
Data.B $7,$F,$0 ,$6,$F,$0 ,$5,$F,$0 ,$4,$F,$0 ,$3,$F,$0 ,$2,$F,$0 ,$1,$F,$0 ,$0,$F,$0 ,$0,$F,$1 ,$0,$F,$2
Data.B $0,$F,$3 ,$0,$F,$4 ,$0,$F,$5 ,$0,$F,$6 ,$0,$F,$7 ,$0,$F,$8 ,$0,$F,$9 ,$0,$F,$A ,$0,$F,$B ,$0,$F,$C
Data.B $0,$F,$D ,$0,$F,$E ,$0,$F,$F ,$0,$E,$F ,$0,$D,$F ,$0,$C,$F ,$0,$B,$F ,$0,$A,$F ,$0,$9,$F ,$0,$8,$F
Data.B $0,$7,$F ,$0,$6,$F ,$0,$5,$F ,$0,$4,$F ,$0,$3,$F ,$0,$2,$F ,$0,$1,$F ,$0,$0,$F ,$1,$0,$F ,$2,$0,$F
Data.B $3,$0,$F ,$4,$0,$F ,$5,$0,$F ,$6,$0,$F ,$7,$0,$F ,$8,$0,$F ,$9,$0,$F ,$A,$0,$F ,$B,$0,$F ,$C,$0,$F
Data.B $D,$0,$F ,$E,$0,$F ,$F,$0,$F ,$F,$0,$E ,$F,$0,$D ,$F,$0,$C ,$F,$0,$B ,$F,$0,$A ,$F,$0,$9 ,$F,$0,$8
Data.B $F,$0,$7 ,$F,$0,$6 ,$F,$0,$5 ,$F,$0,$4 ,$F,$0,$3 ; ,$F,$0,$2 ,$F,$0,$1 ,$F,$0,$0 ,$F,$1,$0 ,$F,$2,$0
Data.B $F,$3,$0 ,$F,$4,$0 ,$F,$5,$0 ,$F,$6,$0 ,$F,$7,$0 ,$F,$8,$0 ,$F,$9,$0 ,$F,$A,$0 ,$F,$B,$0 ,$F,$C,$0
Data.B $F,$D,$0 ,$F,$E,$0 ,$F,$F,$0 ,$E,$F,$0 ,$D,$F,$0 ,$C,$F,$0 ,$B,$F,$0 ,$A,$F,$0 ,$9,$F,$0 ,$8,$F,$0
Data.B $7,$F,$0 ,$6,$F,$0 ,$5,$F,$0 ,$4,$F,$0 ,$3,$F,$0 ,$2,$F,$0 ,$1,$F,$0 ,$0,$F,$0 ,$0,$F,$1 ,$0,$F,$2
Data.B $0,$F,$3 ,$0,$F,$4 ,$0,$F,$5 ,$0,$F,$6 ,$0,$F,$7 ,$0,$F,$8 ,$0,$F,$9 ,$0,$F,$A ,$0,$F,$B ,$0,$F,$C
Data.B $0,$F,$D ,$0,$F,$E ,$0,$F,$F ,$0,$E,$F ,$0,$D,$F ,$0,$C,$F ,$0,$B,$F ,$0,$A,$F ,$0,$9,$F ,$0,$8,$F
Data.B $0,$7,$F ,$0,$6,$F ,$0,$5,$F ,$0,$4,$F ,$0,$3,$F ,$0,$2,$F ,$0,$1,$F ,$0,$0,$F ,$1,$0,$F ,$2,$0,$F
Data.B $3,$0,$F ,$4,$0,$F ,$5,$0,$F ,$6,$0,$F ,$7,$0,$F ,$8,$0,$F ,$9,$0,$F ,$A,$0,$F ,$B,$0,$F ,$C,$0,$F
Data.B $D,$0,$F ,$E,$0,$F ,$F,$0,$F ,$F,$0,$E ,$F,$0,$D ,$F,$0,$C ,$F,$0,$B ,$F,$0,$A ,$F,$0,$9 ,$F,$0,$8
Data.B $F,$0,$7, $F,$0,$6, $F,$0,$5, $F,$0,$4, $F,$0,$3, $F,$0,$2, $F,$0,$1, $F,$0,$0, $F,$1,$0, $F,$2,$0 ;- padded so the colours flow a bit bitter between lists.
Data.B $F,$3,$0 ,$F,$4,$0 ,$F,$5,$0 ,$F,$6,$0 ,$F,$7,$0 ,$F,$8,$0 ,$F,$9,$0 ,$F,$A,$0 ,$F,$B,$0 ,$F,$C,$0
Data.B $F,$D,$0 ,$F,$E,$0 ,$F,$F,$0 ,$E,$F,$0 ,$D,$F,$0 ,$C,$F,$0 ,$B,$F,$0 ,$A,$F,$0 ,$9,$F,$0 ,$8,$F,$0
Data.B $7,$F,$0 ,$6,$F,$0 ,$5,$F,$0 ,$4,$F,$0 ,$3,$F,$0 ,$2,$F,$0 ,$1,$F,$0 ,$0,$F,$0 ,$0,$F,$1 ,$0,$F,$2
Data.B $0,$F,$3 ,$0,$F,$4 ,$0,$F,$5 ,$0,$F,$6 ,$0,$F,$7 ,$0,$F,$8 ,$0,$F,$9 ,$0,$F,$A ,$0,$F,$B ,$0,$F,$C
Data.B $0,$F,$D ,$0,$F,$E ,$0,$F,$F ,$0,$E,$F ,$0,$D,$F ,$0,$C,$F ,$0,$B,$F ,$0,$A,$F ,$0,$9,$F ,$0,$8,$F
Data.B $0,$7,$F ,$0,$6,$F ,$0,$5,$F ,$0,$4,$F ,$0,$3,$F ,$0,$2,$F ,$0,$1,$F ,$0,$0,$F ,$1,$0,$F ,$2,$0,$F
Data.B $3,$0,$F ,$4,$0,$F ,$5,$0,$F ,$6,$0,$F ,$7,$0,$F ,$8,$0,$F ,$9,$0,$F ,$A,$0,$F ,$B,$0,$F ,$C,$0,$F
Data.B $D,$0,$F ,$E,$0,$F ,$F,$0,$F ,$F,$0,$E ,$F,$0,$D ,$F,$0,$C ,$F,$0,$B ,$F,$0,$A ,$F,$0,$9 ,$F,$0,$8
Data.B $F,$0,$7 ,$F,$0,$6 ,$F,$0,$5 ,$F,$0,$4 ,$F,$0,$3 ; ,$F,$0,$2 ,$F,$0,$1 ,$F,$0,$0 ,$F,$1,$0 ,$F,$2,$0
Data.B $F,$3,$0 ,$F,$4,$0 ,$F,$5,$0 ,$F,$6,$0 ,$F,$7,$0 ,$F,$8,$0 ,$F,$9,$0 ,$F,$A,$0 ,$F,$B,$0 ,$F,$C,$0
Data.B $F,$D,$0 ,$F,$E,$0 ,$F,$F,$0 ,$E,$F,$0 ,$D,$F,$0 ,$C,$F,$0 ,$B,$F,$0 ,$A,$F,$0 ,$9,$F,$0 ,$8,$F,$0
Data.B $7,$F,$0 ,$6,$F,$0 ,$5,$F,$0 ,$4,$F,$0 ,$3,$F,$0 ,$2,$F,$0 ,$1,$F,$0 ,$0,$F,$0 ,$0,$F,$1 ,$0,$F,$2
Data.B $0,$F,$3 ,$0,$F,$4 ,$0,$F,$5 ,$0,$F,$6 ,$0,$F,$7 ,$0,$F,$8 ,$0,$F,$9 ,$0,$F,$A ,$0,$F,$B ,$0,$F,$C
Data.B $0,$F,$D ,$0,$F,$E ,$0,$F,$F ,$0,$E,$F ,$0,$D,$F ,$0,$C,$F ,$0,$B,$F ,$0,$A,$F ,$0,$9,$F ,$0,$8,$F
Data.B $0,$7,$F ,$0,$6,$F ,$0,$5,$F ,$0,$4,$F ,$0,$3,$F ,$0,$2,$F ,$0,$1,$F ,$0,$0,$F ,$1,$0,$F ,$2,$0,$F
;Data.B $F,$0,$7,
EndDataSection
-
i only did a test to view the code.
:goodpost:
- solved :cheers:
but no problem with that. interesting is the fact that a picture is overlayed. lets hope we can fix out png with alpha transparency.
later in my tool you can add logos and music too and export all into a single exe file.
-
Yes... unless you change the compile options and un-tick make unicode exe, Then it will work as expected 5.44 Cant say if 5.60 has the option to turn it off
I believe the png has the alph while the orge logo was just a jpeg
I suppose i could have made it look nicer ;D but i wanted to share this straight away :cheers:
-
maybe you have time to replace the ogre image with this one:
(https://abload.de/img/pacelogo2fpl6y.png)
and switch off the grass image.
i hope it works. i have no time for messing around today.
-
Here you go O0
Fixed and Working :bananaphallus:
-
- solved
-
ahhh yes i see, because its looking for the picture in example folder, ill fix it asap :-*
-
includebinary "..."
:D
-
Looking forward Omnikam
-
includebinary "..."
:D
Yep, ive done this, just having some trouble with CatchImage(0, ?Logo)
Image2 = ?Logo
something is not right there?
-
I'm not on PC yet. Easter time in germany. Will write a working code later today.
But i have also trouble with loadimage and another png from the same example folder path. I must figure out what the other code is doing
-
Okay its fixed, updated first post, Test exe should work with logo :cheers:
-
Okay its fixed, updated first post, Test exe should work with logo :cheers:
you still load the image via LoadImage.
use IncludeBinary ;)
(https://abload.de/img/unbenannt33s3v.png)
attached: demo
- hit esc for exit
- grab window with mouse on the header
-
Nice one inc, i solved my issue with
Image2 = CatchImage(#PB_Any, ?Logo)
works now ;D
-
; deactivate Create Unicode Executable in Compiler
EnableExplicit
UsePNGImageDecoder()
Enumeration ;/ Window
#Window_Main
EndEnumeration
Enumeration ;/ Gadget
#Gad_OpenGL
EndEnumeration
Structure System
Event.i
Exit.i
MouseX.i
MouseY.i
App_CurrentTime.i
App_StartTime.i
Editor_LastText.s
Shader_Vertex_Text.s
Shader_Fragment_Text.s
Shader_Vertex.i
Shader_Fragment.i
Shader_Program.i
Shader_Uniform_Time.i
Shader_Uniform_Resolution.i
Shader_Uniform_Mouse.i
Shader_Uniform_SurfacePosition.i
EndStructure
Global System.System
#GL_VERTEX_SHADER = $8B31
#GL_FRAGMENT_SHADER = $8B30
#GL_BGR = $80E0
#GL_BGRA = $80E1
Prototype glCreateShader(type.l)
Prototype glCreateProgram()
Prototype glCompileShader(shader.l)
Prototype glDeleteShader(ShaderObj.i)
Prototype glLinkProgram(shader.l)
Prototype glUseProgram(shader.l)
Prototype glAttachShader(Program.l, shader.l)
Prototype glShaderSource(shader.l, numOfStrings.l, *strings, *lenOfStrings) :
Prototype glGetUniformLocation(Program.i, name.s)
Prototype glUniform1i(location.i, v0.i)
Prototype glUniform2i(location.i, v0.i, v1.i)
Prototype glUniform1f(location.i, v0.f)
Prototype glUniform2f(location.i, v0.f, v1.f)
Prototype glGetShaderInfoLog(shader.i, bufSize.l, *length_l, *infoLog)
Declare CompileShader(VertexShader.s, FragmentShader.s)
Declare FreeShaderSourceBuf(*p)
Declare GetShaderSourceBuf(*shader)
Declare Render()
Declare Render2DQuad(OGLTexture.i, StartX.d, StartY.d, Width.i, Height.i, Z.d)
Declare SetupGLTexture(ImageHandle.i)
Declare SetupOpenGL()
Define.i CTR
Define.i Event
Global.i Image1
Global.i Texture1
;-MAIN WINDOW
OpenWindow(#Window_Main, 0 , 0, 640, 480,"",#PB_Window_ScreenCentered|#PB_Window_BorderLess)
SetWindowColor(#Window_Main, RGB(128, 128, 128))
OpenGLGadget(#Gad_OpenGL, 0, 20, 640, 460, #PB_OpenGL_Keyboard)
SetupOpenGL()
;Load images
Image1 = CatchImage(#PB_Any, ?Logo)
;Now we create textures which can be used for rendering with OpenGL.
Texture1 = SetupGLTexture(Image1)
;Get OpenGL functions
Global glCreateShader.glCreateShader = wglGetProcAddress_("glCreateShader")
Global glCreateProgram.glCreateProgram = wglGetProcAddress_("glCreateProgram")
Global glCompileShader.glCompileShader = wglGetProcAddress_("glCompileShader")
Global glDeleteShader.glDeleteShader = wglGetProcAddress_("glDeleteShader")
Global glLinkProgram.glLinkProgram = wglGetProcAddress_("glLinkProgram")
Global glUseProgram.glUseProgram = wglGetProcAddress_("glUseProgram")
Global glAttachShader.glAttachShader = wglGetProcAddress_("glAttachShader")
Global glShaderSource.glShaderSource = wglGetProcAddress_("glShaderSource")
Global glGetUniformLocation.glGetUniformLocation = wglGetProcAddress_("glGetUniformLocation")
Global glUniform1i.glUniform1i = wglGetProcAddress_("glUniform1i")
Global glUniform2i.glUniform2i = wglGetProcAddress_("glUniform2i")
Global glUniform1f.glUniform1f = wglGetProcAddress_("glUniform1f")
Global glUniform2f.glUniform2f = wglGetProcAddress_("glUniform2f")
Global glGetShaderInfoLog.glGetShaderInfoLog = wglGetProcAddress_("glGetShaderInfoLog")
;Store the shaders within string variables.
System\Shader_Vertex_Text = "attribute vec3 position;"+Chr(10)+
"attribute vec2 surfacePosAttrib;"+Chr(10)+
"varying vec2 surfacePosition;"+Chr(10)+
"void main() {"+Chr(10)+
" surfacePosition = surfacePosAttrib;"+Chr(10)+
" gl_Position = vec4( position, 1.0 );"+Chr(10)+
"}"
System\Shader_Fragment_Text = "uniform float time;"+Chr(10)+
"uniform vec2 resolution;"+Chr(10)+
"void main( void ) {"+Chr(10)+
" vec2 p = ( gl_FragCoord.xy / resolution.xy ) - 0.5;"+Chr(10)+
" float sx = 0.3 * (p.x + 0.8) * sin( 2.0 * p.x - 1. * time);"+Chr(10)+
" float dy = 2./ ( 123. * abs(p.y - sx));"+Chr(10)+
" dy += 5./ (160. * length(p - vec2(p.x, 0.)));"+Chr(10)+
" gl_FragColor = vec4( (p.x + 0.5) * dy, 0.3 * dy, dy, 5.1 );"+Chr(10)+
"}"
;Setup system data
With System
\Shader_Program = CompileShader(\Shader_Vertex_Text, \Shader_Fragment_Text)
glUseProgram(\Shader_Program)
If System\Shader_Program = 0
MessageRequester("Unsupported Device?","No Shader Support Available",#PB_MessageRequester_Ok)
End
EndIf
\App_StartTime = ElapsedMilliseconds()
;/ store shader uniform locations
Debug "Shader: "+\Shader_Program
\Shader_Uniform_Time = glGetUniformLocation(\Shader_Program, "time")
\Shader_Uniform_Mouse = glGetUniformLocation(\Shader_Program, "mouse")
;resolution is blacking out the shader not really sure why.
;\Shader_Uniform_Resolution = glGetUniformLocation(\Shader_Program, "resolution")
\Shader_Uniform_SurfacePosition = glGetUniformLocation(\Shader_Program, "surfacePosition")
Debug "Time location: "+\Shader_Uniform_Time
Debug "Mouse location: "+\Shader_Uniform_Mouse
Debug "Res location: "+\Shader_Uniform_Resolution
Debug "SurfacePos location: "+\Shader_Uniform_SurfacePosition
EndWith
;-MAIN REPEAT
Repeat
Event = WindowEvent()
System\MouseX = WindowMouseX(#Window_Main)
System\MouseY = WindowMouseY(#Window_Main)
System\App_CurrentTime = ElapsedMilliseconds()
Render()
Select Event
Case #WM_LBUTTONDOWN
Debug "klick"
If WindowMouseX(#Window_Main) >= 0 And WindowMouseX(#Window_Main) <= 640 And WindowMouseY(#Window_Main) >= 0 And WindowMouseY(#Window_Main) <= 61
SendMessage_(WindowID(#Window_Main), #WM_NCLBUTTONDOWN, #HTCAPTION, 0)
EndIf
EndSelect
;ESC END PROGRAM
If GetAsyncKeyState_(#VK_ESCAPE)
End
EndIf
Until Event = #PB_Event_CloseWindow
End
Procedure CompileShader(VertexShader.s, FragmentShader.s)
Define.i shader_program
Define.i vs, fs
Define.i *vbuff, *fbuff
*vbuff = GetShaderSourceBuf(@VertexShader)
*fbuff = GetShaderSourceBuf(@FragmentShader)
vs = glCreateShader(#GL_VERTEX_SHADER)
glShaderSource(vs, 1, @*vbuff, #Null)
glCompileShader(vs)
fs = glCreateShader(#GL_FRAGMENT_SHADER)
glShaderSource(fs, 1, @*fbuff, #Null)
glCompileShader(fs)
shader_program = glCreateProgram()
glAttachShader(shader_program, fs)
glDeleteShader(fs)
glAttachShader(shader_program, vs)
glDeleteShader(vs)
glLinkProgram(shader_program)
FreeShaderSourceBuf(*vbuff)
FreeShaderSourceBuf(*fbuff)
ProcedureReturn shader_program
EndProcedure
Procedure FreeShaderSourceBuf(*p)
CompilerIf #PB_Compiler_Unicode
If *p
FreeMemory(*p)
EndIf
CompilerEndIf
EndProcedure
Procedure GetShaderSourceBuf(*shader)
Protected *p, l, t$
CompilerIf #PB_Compiler_Unicode
t$ = PeekS(*shader, -1) : l = Len(t$)
*p = AllocateMemory(l + SizeOf(Character))
If *p
PokeS(*p, t$, l, #PB_Ascii)
EndIf
CompilerElse
*p = *shader
CompilerEndIf
ProcedureReturn *p
EndProcedure
Procedure Render()
glClear_(#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT)
glClearColor_(0.2, 0.2, 0.2, 1.0)
glUseProgram(System\Shader_Program)
;/ set shader Uniform values
glUniform2f(System\Shader_Uniform_Resolution, 640, 480)
glUniform1f(System\Shader_Uniform_Time,(System\App_CurrentTime-System\App_StartTime)/1000)
glUniform2i(System\Shader_Uniform_SurfacePosition,System\MouseX,System\MouseY)
glBegin_(#GL_QUADS)
glVertex3f_(-1,-1,0)
glVertex3f_( 1,-1,0)
glVertex3f_( 1, 1,0)
glVertex3f_(-1, 1,0)
glEnd_()
glUseProgram(0)
;## DRAWING TEXTURES/IMAGES
;First enable the Texture system.
glEnable_(#GL_TEXTURE_2D)
;This procedure will create a quad and apply a texture to it.
;The Texture variable contains the texture created earlier using SetupGLTexture().
Render2DQuad(Texture1, 160, 160, ImageWidth(Image1), ImageHeight(Image1), 1)
;After all the textures have been displayed disable the texture system.
;Otherwise it will conflict with the non texture graphics.
glDisable_(#GL_TEXTURE_2D)
SetGadgetAttribute(#Gad_OpenGL, #PB_OpenGL_FlipBuffers, #True)
EndProcedure
Procedure Render2DQuad(OGLTexture.i, StartX.d, StartY.d, Width.i, Height.i, Z.d)
;The texture is first bound which tells OpenGL to use this texture for any future rendering.
glBindTexture_(#GL_TEXTURE_2D, OGLTexture)
glBegin_(#GL_QUADS)
glColor4f_ (1,1,1,1)
glNormal3f_ (0,0,1.0)
glTexCoord2f_(1.0,1.0)
glVertex3f_ (StartX+Width,StartY,Z)
glTexCoord2f_(0.0,1.0)
glVertex3f_ (StartX,StartY,Z)
glTexCoord2f_(0.0,0.0)
glVertex3f_ (StartX,StartY+Height,Z)
glTexCoord2f_(1.0,0.0)
glVertex3f_ (StartX+Width,StartY+Height,Z)
glEnd_()
EndProcedure
Procedure SetupGLTexture(ImageHandle.i)
Define.i ImageW, ImageH, ImageD
Define.i MemoryAddress
Define.i TextureHandle
If IsImage(ImageHandle) = 0
ProcedureReturn #False
EndIf
ImageD = ImageDepth(ImageHandle, #PB_Image_InternalDepth)
StartDrawing(ImageOutput(ImageHandle))
MemoryAddress = DrawingBuffer()
StopDrawing()
If MemoryAddress = 0
ProcedureReturn #False
EndIf
glGenTextures_(1, @TextureHandle)
glBindTexture_(#GL_TEXTURE_2D, TextureHandle)
ImageW = ImageWidth(ImageHandle)
ImageH = ImageHeight(ImageHandle)
If ImageD = 32
glTexImage2D_(#GL_TEXTURE_2D, 0, 4, ImageW, ImageH, 0, #GL_BGRA, #GL_UNSIGNED_BYTE, MemoryAddress)
Else
glTexImage2D_(#GL_TEXTURE_2D, 0, 3, ImageW, ImageH, 0, #GL_BGR, #GL_UNSIGNED_BYTE, MemoryAddress)
EndIf
glTexParameteri_(#GL_TEXTURE_2D, #GL_TEXTURE_MIN_FILTER, #GL_LINEAR)
glTexParameteri_(#GL_TEXTURE_2D, #GL_TEXTURE_MAG_FILTER, #GL_LINEAR)
ProcedureReturn TextureHandle
EndProcedure
Procedure SetupOpenGL()
glMatrixMode_(#GL_PROJECTION)
glOrtho_(0.0, 640, 480, 0.0, -1000.0, 1000.0)
glMatrixMode_(#GL_MODELVIEW)
glEnable_(#GL_DEPTH_TEST)
glEnable_(#GL_BLEND)
glBlendFunc_(#GL_SRC_ALPHA, #GL_ONE_MINUS_SRC_ALPHA)
EndProcedure
DataSection
Logo:
IncludeBinary "9.png"
LogoEnd:
EndDataSection
-
:goodpost:
Working Nicely inc, The embedded data didnt though, Which is why you changed it to include?
Just noticed this http://www.dbfinteractive.com/forum/index.php?topic=5762.0
Seems the source has been floating around since 2012 ;D
-
The whole code with embedded Data for the gfx Logo was too long for the Forums "code Tag". That's why i changed the code back to includebinary.
I have my own framework for the shader tool. Next, i'll add a Button to load gfx into the tool plus an option to move the gfx to a desired x/y location on the Demo screen. And when all is done, it can be saved to a xinclude pbi for the Main Demo code.
The existing SC from 2012 is for PB 4.60 if am i right? I think it will not work with the current PB Version. Next, external shader must be in the Same folder where the final exe is stored. Not a good idea. All in one exe file is the best solution :D
-
Yes the example from the link I posted is definitely dated, but I noticed much code that was included in the current additions are from it, and that was posted in 2012, so wow, second life. ;D
I can't wait to see your demo tool, I hope you have a nice scroller option. I can't imagine an intro without a scroller :-* that's my next goal. I have a nice Glsl shader for pretty cool looking text. But having the old sprite/images would be fun :)
-
(https://abload.de/img/unknownivuza.png)
another quick GLSL attempt straight from the tool with music.
i hope it runs fine on any sys.
-
Very nice inc. Love the choice of Shader2Music2Logo, I just kept watching :) hypnotized
Have you a working scroller? I have some code for one that might need tweeting if your interested, just message me
-
amazing , thanks guys !
inc. always at top level ;D
-
Just For fun i added to your demo script,
Added mod playing via IncludeBinary
Added get Shader from IncludeBinary
Logo moves with the mouse
-
nice try. you should the "drag logo" feature activate on #PB_MouseButton_Right. and if you press again RMB then the logo should stay on its new location.
#WM_LBUTTONDOWN is reserved for "drag the whole window".
Let me see your scroller. Yes i have scroller code but no time to add into the glsl thing.
merged with this thread:
http://www.dbfinteractive.com/forum/index.php?topic=6674.msg83811#msg83811
( a bit different - the music player comes from the mp3d Lib. i like the clean sound of v2m tunes )
-
The installer was 32bit only :o Im 64bit
Attached some psudo code, it`s in C but can be adapted, The actual scrolling routine is left out
-
No need for 64Bit. Install the 32bit. Also working nice on x64. I have installed on my x64 sys the Purebasic x86 Version. No idea why using pbx64.
After installing, do not forget to setup in Compiler option at lib Subsystem: DX9
I have PureBasic Scroller code. No need to translate C to PB
I'll check your attachment later. Not on my PC ATM.
-
Just an article I trawled from the Internet, I liked it because it was basically a the standard scroller but using glsl shader
Okay got it all up and running, ;D
-
did you added the option:
"you should the "drag logo feature" activate on #PB_MouseButton_Right and if you press again RMB then the logo should stay on its new x/y location"
scroller is up and running too?
-
Had no time, school holidays and son's birthday party. Will take a shot at it in a day or 2. Been surrounded by 6 year olds all day :boxer: I'm off to a well earned sleep. I think it won't be too hard to add a scroller, I have a idea, just need some time to code it in. I'll post my code in a few days :)
-
Nah, no rush. It's only my reply of your post:
"Okay got it all up and running"
I thought u already made it :D
-
Ahh, I wish ;D The Scroller Is a pain is the ass look at it if you will, but i warn you it might be hard to follow, it is for me :carrot:
Ps i borrowed code from the Vroom remake demo
-
So after more tinkering i have the scroller working, but now the image doesnt display and the nice nurbs shader is static
-
Okay inc ;D I have both the Shader and the Scrolling text working :bfuck2:
I still need to get the Logo to render
-
calling 2 times:
glOrtho_
wont work.
the first call is the view for the scroller text:
glOrtho_(#Window_Main, 640, 0.0, 240, 0, 1)
the second call for our logo that we used before is:
glOrtho_(#Window_Main, 640, 480, 0, -1, 0)
calling both will occur a conflict for the x / y Coordinates for the gfx.
scroller use the whole window width: Ortho_(#Window_Main, 640,
scroller use YPos: glOrtho_(#Window_Main, 640, 0.0, 240,
logo use window width: glOrtho_(#Window_Main, 640,
logo use window height: glOrtho_(#Window_Main, 640, 480,
Logo x/y Position is separately defined (thats why we have in this line Zero: glOrtho_(#Window_Main, 640, 480, 0,
logo definition comes at this point: Render2DQuad(Texture1, 150, 120, ImageWidth(Image1), ImageHeight(Image1), 1)
and so, the logo will move the scroller out of the viewpoint and the demoscreen
a lil help:
https://wiki.delphigl.com/index.php/glOrtho
-
Thanks inc :inspired: I figured it was an glOrtho_ issue,but couldnt understand iys use , thanks for your insight, ill try to fix the problem , It`s a problem of the cut and paste beginner code, getting things to work without fully understanding how. Ill figue out this glOrtho_ command and post a working solution. I noticed iy rendered terribly in full screen so i had to disable it, the scroller would seem sluggish, okay im off to work :D
Im feeling like the guy from 36th Chamber of Shaolin trying to start at the top. even after reading wiki and your explanation, i still feel like a stupid monkey :'(
I know the solution is simple , i understand that both scroller and logo are in conflict with each other, the scroller push`s out the logo, but no matter what position i give the logo, its not displayed
Render2DQuad(Texture1, 0, 0, ImageWidth(Image1), ImageHeight(Image1), 1)
is this my issue? or is it where Render2DQuad is defined in memory?
-
Render2DQuad(Texture1, 0, 0, ImageWidth(Image1), ImageHeight(Image1), 1)
is this my issue? or is it where Render2DQuad is defined in memory?
it's both of 'em ( glOrtho and Render2DQuad ) but not sure yet. i must figure it out as soon i have time.
the scroller must be included in other way.
looking forward ;)
-
Does glOrtho act like a window view scale? a view port resizer?
in my included picture i have a question on some of the parameters, from what i understand it should be glOrtho_(left,right,up,down,zdepth)
I dont understand why the scroller`s view is glOrtho_(0, #WindowWidth-1, 0, #WindowHeight-1, 0, 1)
what`s with the extra 0`s ?
Is this valid glOrtho(0,320,0,300,0)
does this represent my small square in my image? and would glOrtho(0,640,0,600,0)
would this be the larger view?
-
I dont understand why the scroller`s view is glOrtho_(0, #WindowWidth-1, 0, #WindowHeight-1, 0, 1)
what`s with the extra 0`s ?
Those last 2 parameter should be the "near plane" and "far plane" and it's related to the opengl 2d projection matrix, normally I use -1.0f for near and 1.0f for the far clipping plane.
Take a look here, it might help a little bit.
http://www.songho.ca/opengl/gl_projectionmatrix.html#ortho
-
Thanks rbz, that link was intimidating indeed, mathematics was not my strong point during my school year's, particularly algebra and geometry, and now I'm having to use them and understand them more than ever :P I think though that I'm starting to understand why the logo doesn't show up
Last question, in a program will it only have 1 active declaration using glOrtho?
-
If you are only drawing 2D stuff, then yes, you just setup your orthographic matrix only one time on init opengl.
If your drawing 3D mixed with 2D you will need to be switching from perspective projection (3d) to orthographic projection (2D).
-
Well im stumped, the scroller is at 0,680,0,240 while the image is 0,680,480,0 -1000 -1000 setting glortho to the scroller totally pushes image offscreen
i think my approach will be to implement a new image to opengl texture routine that has a more normalized matrix. That might be beyond my current level which is level 1 lol
-
about the scroller.
it is located in the main window at:
glOrtho_(#Gad_OpenGL, 640, 0, 240, 0, 1)
Z-View: 0 ---- is fine. it must not be a negative value. 0 is working.
now you wonder why the second value is ZERO.
it is because of the 2nd definition in the Procedure: Draw_ScrollText()
at: YPos = #WindowHeight/2.4
we tell our Scroller, he have to display exactly 240 on the windows Y Axis. 240 = #WindowHeight/2.4
but calling 2 times glOrtho for different images will not work. we must rewrite the code for gfx on GL Screen and call both or more only once with glOrtho command
just checking
edit:
i have a good typer Sourcecode. Maybe you wanna include this one infront of the GL screen :D
-
Still working on the Logo. I have today off work, so I'm going to try to figure this out. Pjay's Vroom remake is an excellent resource for learning as he used all opengl. But I'm basically just trying to catch image encode image bind image to gltexture create a full screen quad bind the texture to the quad. Sounds easy hey :) I'm sure it is, but if you ever saw my pirate demo then you would know my skills are limited. But I will keep trying Inc. A nice typer is always welcome ;)
-
Sounds good. Looking forward mate. If you sort something out, lemme see.
I never seen your "Pirate Demo" :)
Meanwhile i do some codings on my shader Editor Demo tool: Adding the option to include gfx and music on demand.
And also catching the Font for scrolling or typing infront of the GL Screen.
Lot of work to do :D
-
Well I had a partial success, I managed to get all 3 working, unfortunately the logo loses transparency, so no go. Instead of using quads and gltexture I went with the startdrawing () drawImage stopdrawing () command, as I said it loses Alpha channel, I might try my old sprite method next, I seem to remember getting my sprites to render with Alpha, so perhaps can be adapted here
-
Good news. looking forward to the outcome and hope to see a nice and properly commented sourcecode :D
maybe i can adapt some lines into the Shader Tool then.
-
Well i seemed to have hit a road block with this one, No matter what ive tried i lose the logo`s transparency..Back to the drawing board]
-
Procedure Logo()
CreateImage(0, 800, 600) ;create image from loaded logo ImageId2
StartDrawing(WindowOutput(0)) ;startdrawing
DrawAlphaImage(ImageID(2), 0, 0,255)
DrawingMode(#PB_2DDrawing_AlphaBlend) ;Doest do the transparancy like it should
StopDrawing()
EndProcedure
not working on a OGL Gadget. this call a canvas and you draw the logo on it. can't be transparent
so, back to the start.
i hope i have some time to help soon
Edit:
I found another site with interesting information.
https://www.sjbaker.org/steve/omniv/opengl_text.html
-
Okay well ive gone for a VERY unpractical approach
-
it looks like, you made 2 ogl windows, parent and child and stick em together.
a solution but not the right way :D
my x/y coordinates looks different than yours:
(https://abload.de/img/neu-28pb8i.png)
just waiting for more information and when it's done i hope i can fix it :)
-
:stirrer: Damm i was wondering if different desktop resolutions would have that effect :clap: Well now i know :cheers:
The second window isnt an Opengl window, it`s a custom transparent window using the Image as window, i then hide the window, I suppose i could use get desktop width and height to align the windows properly. The open Gl solution would be best, a textured quad does sound right, but it was beyond my skill set, if you look a page down you will see my second ever demo, its basic as are my skills
-
Could You try this one :) Made a few modifications, hopefully it will render properly
it should have the logo centered regardless of resolution
-
Understand. U made the second Window transparent. What happen if you grab another Explorer Window and move it over your Demo?
i started your example. the picture should speak for itself:
(https://abload.de/img/neu-2lmsf9.png)
Let us render the "logo gfx" as an textured quad. i'll hang on.
Give me a lil time. I will check your 2nd Demo later. :)
-
Yes back to quads. Transparent window still could have its use, I'll show you something that would give it a cool effect later. I think I have an idea for the quad issue too, but not free to explore my idea for a few day's
I think ive figured it out, ill post a quad test soon
:-[ I failed
But i have a new Test to try out ;)
-
:bfuck2: :bananaphallus: :carrot: :|| :bfuck1: :buddies:
I Did it, After God Knows how many hours and researching and reading. I tried So many times and failed. I swear i was all ready to give up, but then in the quietness of Failure, i had a new idea, why reinvent the wheel when it has already been done? So i looked at Pjays code for his Vroom remake, and hello, the answer was staring me in the face :inspired:
So here it is my Demo with everything working
Yes Inc , that's textured quad goodness :cheers:
-
Exactly :clap:, that's it what ppl expected and wait'n for.
now an well commented SC and we can adapt the GFX options into my Shader Tool :)
well done.
-
Removed
-
ok, there is a lil bug. i hope i can find it quick
you made black = transparent. the sourcecode does no longer support the alphablending. :whack:
(https://abload.de/img/neu-10xaugq.png)
-
Well this is the best i could do
Or Transparent is Nice
For some reason whenever the fragment shader is a little complex the scroller slows to a craw?
-
Ok. I see this is the wrong way you go. We have weekend in germany. Things to do with family and lil child. As soon i have time, i fix this Problem.
Good Job over the last days mate :)
-
Cheers inc, enjoy the family weekend..Ill keep messing around and post a fix if i work it out ;)
-
thanks :)
head back to this code and find out what you did wrong. with the SC below the alphablending works fine:
-solved
-
There is a lot of differences, The Texture Procedure is different
Procedure LoadTexture_(Texture.i) ; Returns the texture for an OpenGL application
Protected Width.i, Height.i, NWidth.i, NHeight.i, X.i, Y.i, Colour.i, I.i, R.i, G.i, B.i, Tex.i
If Texture = 0 : CatchImage(1, ?Bigtext) : EndIf
If Texture = 1 : CatchImage(1, ?MyLogo) : EndIf; Catch Logo Image to Texture(1)
If Texture = 3 : CatchImage(1, ?Smallfont): EndIf
Width = ImageWidth(1)
Height = ImageHeight(1)
NWidth = Width : NHeight = Height
If NWidth > NHeight : NHeight = NWidth : EndIf ;/ had to force equal width / height due to compatability issues
If NHeight > NWidth : NWidth = NHeight : EndIf ;/
Dim ImageData.c(NWidth * NHeight * 4)
ImageD = ImageDepth(Texture, #PB_Image_InternalDepth)
StartDrawing(ImageOutput(1))
For Y=0 To NHeight-1
For X=0 To NWidth-1
If Y>Height-1 Or X>Width
Colour = 0 ;/ speeds up loading
Else
Colour = Point(X,Y)
r=Red(Colour) : g=Green(Colour) : b=Blue(Colour)
ImageData(i)=b : i+1
ImageData(i)=g : i+1
ImageData(i)=r : i+1
ImageData(i)=255
EndIf
If r<15 And g<15 And b<15 : ImageData(i)=0 : EndIf
i+1
Next
Next
StopDrawing()
glGenTextures_(1, @tex.i)
glBindTexture_(#GL_TEXTURE_2D, tex)
If ImageD = 32
glTexParameteri_(#GL_TEXTURE_2D, #GL_TEXTURE_MIN_FILTER, #GL_LINEAR)
glTexParameteri_(#GL_TEXTURE_2D, #GL_TEXTURE_MAG_FILTER, #GL_LINEAR)
Else
glTexParameteri_(#GL_TEXTURE_2D, #GL_TEXTURE_MAG_FILTER, #GL_NEAREST)
glTexParameteri_(#GL_TEXTURE_2D, #GL_TEXTURE_MIN_FILTER, #GL_NEAREST)
glTexParameteri_(#GL_TEXTURE_2D,#GL_TEXTURE_WRAP_S, #GL_CLAMP)
glTexParameteri_(#GL_TEXTURE_2D,#GL_TEXTURE_WRAP_T, #GL_CLAMP)
EndIf
If ImageD = 32
glTexImage2D_(#GL_TEXTURE_2D, 0,4 , NWidth, NHeight, 0, #GL_BGRA, #GL_UNSIGNED_BYTE, @ImageData());
Else
glTexImage2D_(#GL_TEXTURE_2D, 0, #GL_RGBA, NWidth, NHeight, 0, #GL_BGRA_EXT, #GL_UNSIGNED_BYTE, @ImageData());
EndIf
FreeImage(1)
Dim ImageData(0)
ProcedureReturn tex
EndProcedure
And then This
Procedure SetupGLTexture(ImageHandle.i)
Define.i ImageW, ImageH, ImageD
Define.i MemoryAddress
Define.i TextureHandle
If IsImage(ImageHandle) = 0
ProcedureReturn #False
EndIf
ImageD = ImageDepth(ImageHandle, #PB_Image_InternalDepth)
StartDrawing(ImageOutput(ImageHandle))
MemoryAddress = DrawingBuffer()
StopDrawing()
If MemoryAddress = 0
ProcedureReturn #False
EndIf
glGenTextures_(1, @TextureHandle)
glBindTexture_(#GL_TEXTURE_2D, TextureHandle)
ImageW = ImageWidth(ImageHandle)
ImageH = ImageHeight(ImageHandle)
If ImageD = 32
glTexImage2D_(#GL_TEXTURE_2D, 0, 4, ImageW, ImageH, 0, #GL_BGRA, #GL_UNSIGNED_BYTE, MemoryAddress)
Else
glTexImage2D_(#GL_TEXTURE_2D, 0, 3, ImageW, ImageH, 0, #GL_BGR, #GL_UNSIGNED_BYTE, MemoryAddress)
EndIf
glTexParameteri_(#GL_TEXTURE_2D, #GL_TEXTURE_MIN_FILTER, #GL_LINEAR)
glTexParameteri_(#GL_TEXTURE_2D, #GL_TEXTURE_MAG_FILTER, #GL_LINEAR)
ProcedureReturn TextureHandle
EndProcedure
There are other Differences too, however i think perhaps the loading and binding is the problem especially this
StartDrawing(ImageOutput(1))
For Y=0 To NHeight-1
For X=0 To NWidth-1
If Y>Height-1 Or X>Width
Colour = 0 ;/ speeds up loading
Else
Colour = Point(X,Y)
r=Red(Colour) : g=Green(Colour) : b=Blue(Colour)
ImageData(i)=b : i+1
ImageData(i)=g : i+1
ImageData(i)=r : i+1
ImageData(i)=255
EndIf
If r<15 And g<15 And b<15 : ImageData(i)=0 : EndIf
i+1
Next
Next
StopDrawing()
Wont have time to look at it for a few days
-
Removed
-
can not run this code. you should provide all externals too.
btw. i sent you a pm
-
:cheers:
Okay :buddies: It`s Fixed
Feel free to Merge both Texture Procedures into one ;D
Thanks for the Typer source :) Havnt looked at it yet, check it out soon
Its nearly time to put something together O0
Included in the Attachment is everything needed to compile my "DEMO"
-
Screenshot looks good :)
But first, head over into the bed. :cheers:
-
Yeah i forget about Time Zones, it`s 1pm atm and 3.40am in Germany
Okay dude get some rest :)
-
Really well done mate. :updance: :clap:
you should move the final into your first post and remove the not working code from your thread.
if not, other could be frustrated ;)
last question: what was the issue with the blending? which line in your SC?
and another Question, have you any idea to import shaders from shadertoy?
now back to work with the shader tool . you made a great progress for further tool options because i stuck with that gfx.
-
Thia was the problem, no Alpha channel, it creates am image pixel by pixel but only using r,g,b and setting transparency
Else
Colour = Point(X,Y)
r=Red(Colour) : g=Green(Colour) : b=Blue(Colour)
ImageData(i)=b : i+1
ImageData(i)=g : i+1
ImageData(i)=r : i+1
ImageData(i)= 255
EndIf
Shadertoy would be difficult for me, Too much to implement. They have more than vertex and fragment shader support, and also some custom environmental naming s
Update: From what ive just read about Shadertoy they use a pixel shader. Naming issues wont be a problem, just simple things like
uniform U_time;
to Uniform time;
Fragcolor
to [code[gl_fragcolor[/code]
etc
as for their ichannels im not sure?
-
it seems to be more different. it's a web GL Sahder. for this kind of Shaders i'm not skilled enuff :D
-
Until recently id never used glsl shaders, Ive been going through the exercises from
http://thebookofshaders.com Learning a lot from it
I`d like to know how to communicate with the shader, so i can pass information in real time, the idea being to make music effect the fragments, Apparently Emook achieved this ;) ill post anything really cool i uncover, sharing makes us all stronger
Ps. Our Glsl shader does support WebGl Take GLSLSandbox.com its all WebGl and most of the shaders work without any need to convert
-
(https://abload.de/img/goodpostplu67.gif)
A great link. Thanks.
Yes shaders from the sandbox can copied and pasted directly.
But we try to discover and support shadertoy's shader too. the "shader Demo tool", that i'm coding at the moment, should be able to handle them too.
It is a nice idea to sync shaders behavior to music :) but you will be also able to sync any other shaders to the beat of your music. i have added a timer option that can switch between shaders in 1 ms. you can create cool effects.
here is a test with longer switch timer straight from the tool:
see attachment pls
There are GL options that can handle music.
Uniform Sampler 2D textex1 and so on.
I'll discover :)
Take time to watch this video. Very cool and interesting :
https://youtu.be/m6xWreYb3zM
have a closer look at 4:48 min
-
Really cool that someone has been able to do this finally! Well done!
I managed to get shaders to react to FFT values set by BASS dll.
https://www.youtube.com/watch?v=4uk19hytCnw (https://www.youtube.com/watch?v=4uk19hytCnw)
I'll clean up the sources and post, it was a while back!
-
yes. i've seen this demo, but we want to include all into one exe file :D no external libs / dll should be shared with the demo.
we find the way.
-
And its the TextFFT* values that bezomatic generates from the audio it listens to, not the textures.
-
And its not hard to have a bass dll inside the exe, it would be possible even to use the osm library included and use that instead.
-
Sounds good. Yes it is possible to include each file via includebinary into the exe and extract em on start into a temp folder.
Looking forward, would be nice to see some solution using FFT or similar :inspired:
-
I've been busy writing code for the spectrum over the past two years and haven't really done much in PB but I'll grab rework my example using the texture mapping above.
I had everything working apart from being able to show bitmaps at the same time. As I couldn't find a solution the whole code got out of the shelf :)
-
It`s funny Emook because in my search for a solution i found your posts over at Purebasic forums, only 2 years earlier. It`s funny because i came up with some pretty funny workarounds before the solution, thank god inc pressed me to solve it properly, because at one point i was using png drawn windows to display an image on top of the GlGadget, it worked :P but not good coding practice
inc ;D Very nice share. especially the expansion folder :cheers:
-
What would life be like without a Vu meter for xm music?
This one uses uFmod and in particular the uFMOD_GetStats() to capture the RMS volume stats for L and R channels. I then modified the output to use in my textured quads matrix
-
nice oldschool effect :D
i made some similar in the past:
http://aftermath-creations.net/viewtopic.php?f=16&t=120
now, back to work and programming the "shader tool demo maker" with your unveiled features and some more :clap:
here is a omnikam logo: feel free to use ( i had time )
(https://abload.de/img/omnikamlogo3cjv4.png)
-
:goodpost:
Wow! inc i love it :buddies: And thanks for the link to the code snipit, very nice effect :)