Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - inc.

Pages: 1 2 [3] 4 5 6 7 8 9 10 ... 13
41
Code: [Select]
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

42
General chat / Re: The Welcoming Committee
« on: April 26, 2017 »
welcome. looking forward to see some

43
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.


44
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

45
General chat / Re: Ideas for a new DBF compo
« on: April 25, 2017 »
i like the idea.
maybe something with summer ?

46
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

47
Code: [Select]
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 ;)

48
calling 2 times:

glOrtho_

wont work.

the first call is the view for the scroller text:
Code: [Select]
glOrtho_(#Window_Main, 640, 0.0, 240, 0, 1)
the second call for our logo that we used before is:
Code: [Select]
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

49
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

50
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?

51
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.

52
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 )

53


another quick GLSL attempt straight from the tool with music.

i hope it runs fine on any sys.

54
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

55
Code: [Select]
; 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

56
Okay its fixed, updated first post, Test exe should work with logo  :cheers:


you still load the image via LoadImage.
use IncludeBinary ;)




attached: demo
- hit esc for exit
- grab window with mouse on the header

57
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

58
includebinary "..."
:D

59
- solved

60
maybe you have time to replace the ogre image with this one:



and switch off the grass image.

i hope it works. i have no time for messing around today.

Pages: 1 2 [3] 4 5 6 7 8 9 10 ... 13