It is currently Wed Mar 01, 2017 9:47 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: PB 5.51 GL Constants
PostPosted: Mon Jan 30, 2017 10:19 pm 
Offline
User
User

Joined: Thu Mar 14, 2013 11:24 am
Posts: 19
Hello, apparently some (but not all) OpenGL Globals Constants were added in the latest release of PB 5.51
And they are conflicting with my GL Module(I use it globally ie: UseModule OpenGL)
Where/How can I find the exhaustive list of those Constants?


Top
 Profile  
Reply with quote  
 Post subject: Re: PB 5.51 GL Constants
PostPosted: Tue Jan 31, 2017 9:19 am 
Offline
Addict
Addict

Joined: Sun Jun 25, 2006 7:28 pm
Posts: 1235
There is a big lists of constants posted here by luis
viewtopic.php?f=13&t=45687&start=0

also the file C:\Purebasic\Residents\OpenGL.res contains the constants in purebasic distribution, can be opened with notepad as text
copy the name of the constant and search for it in luis unclude files to get its value.

using Dos comp utility (in windows xp):
the OpenGL.res in PB 5.51 is the same as in PB 5.43
but different than OpenGL.res in PB 5.31 and 5.40
so i suggest to backup OpenGL.res in your PB5.51 and replace it with the OpenGL.res from PB5.40 or 5.31 it may work


Top
 Profile  
Reply with quote  
 Post subject: Re: PB 5.51 GL Constants
PostPosted: Tue Jan 31, 2017 1:41 pm 
Offline
User
User

Joined: Thu Mar 14, 2013 11:24 am
Posts: 19
Thanks for the answer applePi!
I didn't knew about residents files...
I encountered the problem upgrading from PB 5.41 to PB 5.51...
I'll try replacing the .res file tonight...


Top
 Profile  
Reply with quote  
 Post subject: Re: PB 5.51 GL Constants
PostPosted: Tue Jan 31, 2017 2:15 pm 
Offline
Addict
Addict

Joined: Sun Jun 25, 2006 7:28 pm
Posts: 1235
i suggest first to try your demo in 5.43/5.44 which have the same OpenGL.res as 5.51 and compile it as ascii not unicode and see if it works. if it works then it is a unicode issue:
related to 5.51: as pjay said (Many of the OpenGL commands that you pass strings to will need modifying, this is due to PB switching to Unicode strings internally): viewtopic.php?f=36&t=62179&hilit=Shader+coding+with+PB+possible&start=30
i have faced this also here viewtopic.php?f=12&t=49583&hilit=Small+cross+platform+OpenGL+demo&start=45


Top
 Profile  
Reply with quote  
 Post subject: Re: PB 5.51 GL Constants
PostPosted: Tue Jan 31, 2017 9:30 pm 
Offline
User
User

Joined: Thu Mar 14, 2013 11:24 am
Posts: 19
replacing the opengl.res file isn't working...
however I managed to compile by introducing a CompilerIf checking the PB version and declaring only missing GL constants that I use

Code:
CompilerIf #PB_Compiler_Version < 550
   ;Here I declare ALL GL Constants
CompilerElse
    #GL_SHADING_LANGUAGE_VERSION                           = $8B8C
    #GL_INVALID_FRAMEBUFFER_OPERATION                      = $0506
    #GL_COMPILE_STATUS                                     = $8B81
    #GL_VERTEX_SHADER                                      = $8B31
    #GL_FRAGMENT_SHADER                                    = $8B30
    #GL_GEOMETRY_SHADER                                    = $8DD9
   
    #GL_ARRAY_BUFFER                                       = $8892
    #GL_ELEMENT_ARRAY_BUFFER                               = $8893
    #GL_ARRAY_BUFFER_BINDING                               = $8894
    #GL_ELEMENT_ARRAY_BUFFER_BINDING                       = $8895
    #GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING                 = $889F
   
    #GL_TEXTURE0                                           = $84C0
    #GL_TEXTURE1                                           = $84C1
    #GL_TEXTURE2                                           = $84C2
    #GL_TEXTURE3                                           = $84C3
    #GL_TEXTURE4                                           = $84C4
    #GL_TEXTURE5                                           = $84C5
    #GL_TEXTURE6                                           = $84C6
    #GL_TEXTURE7                                           = $84C7
    #GL_TEXTURE8                                           = $84C8
    #GL_TEXTURE9                                           = $84C9
    #GL_TEXTURE10                                          = $84CA
    #GL_TEXTURE11                                          = $84CB
    #GL_TEXTURE12                                          = $84CC
    #GL_TEXTURE13                                          = $84CD
    #GL_TEXTURE14                                          = $84CE
    #GL_TEXTURE15                                          = $84CF
    #GL_TEXTURE16                                          = $84D0
    #GL_TEXTURE17                                          = $84D1
    #GL_TEXTURE18                                          = $84D2
    #GL_TEXTURE19                                          = $84D3
    #GL_TEXTURE20                                          = $84D4
    #GL_TEXTURE21                                          = $84D5
    #GL_TEXTURE22                                          = $84D6
    #GL_TEXTURE23                                          = $84D7
    #GL_TEXTURE24                                          = $84D8
    #GL_TEXTURE25                                          = $84D9
    #GL_TEXTURE26                                          = $84DA
    #GL_TEXTURE27                                          = $84DB
    #GL_TEXTURE28                                          = $84DC
    #GL_TEXTURE29                                          = $84DD
    #GL_TEXTURE30                                          = $84DE
    #GL_TEXTURE31                                          = $84DF
   
    #GL_STREAM_DRAW                                        = $88E0
    #GL_STREAM_READ                                        = $88E1
    #GL_STREAM_COPY                                        = $88E2
    #GL_STATIC_DRAW                                        = $88E4
    #GL_STATIC_READ                                        = $88E5
    #GL_STATIC_COPY                                        = $88E6
    #GL_DYNAMIC_DRAW                                       = $88E8
    #GL_DYNAMIC_READ                                       = $88E9
    #GL_DYNAMIC_COPY                                       = $88EA
   
    #GL_FRAMEBUFFER                                        = $8D40
    #GL_FRAMEBUFFER_BINDING                                = $8CA6
    #GL_DRAW_FRAMEBUFFER_BINDING                           = $8CA6 ; GL_FRAMEBUFFER_BINDING
    #GL_RENDERBUFFER_BINDING                               = $8CA7
    #GL_READ_FRAMEBUFFER                                   = $8CA8
    #GL_DRAW_FRAMEBUFFER                                   = $8CA9
    #GL_READ_FRAMEBUFFER_BINDING                           = $8CAA
    #GL_RENDERBUFFER_SAMPLES                               = $8CAB
    #GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE                 = $8CD0
    #GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME                 = $8CD1
    #GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL               = $8CD2
    #GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE       = $8CD3
    #GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER               = $8CD4
    #GL_FRAMEBUFFER_COMPLETE                               = $8CD5
    #GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT                  = $8CD6
    #GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT          = $8CD7
    #GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER                 = $8CDB
    #GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER                 = $8CDC
    #GL_FRAMEBUFFER_UNSUPPORTED                            = $8CDD
    #GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING              = $8210
    #GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE              = $8211
    #GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE                    = $8212
    #GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE                  = $8213
    #GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE                   = $8214
    #GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE                  = $8215
    #GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE                  = $8216
    #GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE                = $8217
    #GL_FRAMEBUFFER_DEFAULT                                = $8218
    #GL_FRAMEBUFFER_UNDEFINED                              = $8219
    #GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE                 = $8D56
    #GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS               = $8DA8
   
    #GL_RENDERBUFFER                                       = $8D41
    #GL_RENDERBUFFER_WIDTH                                 = $8D42
    #GL_RENDERBUFFER_HEIGHT                                = $8D43
    #GL_RENDERBUFFER_INTERNAL_FORMAT                       = $8D44
   
    #GL_DEPTH_COMPONENT16                                  = $81A5
    #GL_DEPTH_COMPONENT24                                  = $81A6
    #GL_DEPTH_COMPONENT32                                  = $81A7
   
    #GL_MAX_COLOR_ATTACHMENTS                              = $8CDF
    #GL_COLOR_ATTACHMENT0                                  = $8CE0
    #GL_COLOR_ATTACHMENT1                                  = $8CE1
    #GL_COLOR_ATTACHMENT2                                  = $8CE2
    #GL_COLOR_ATTACHMENT3                                  = $8CE3
    #GL_COLOR_ATTACHMENT4                                  = $8CE4
    #GL_COLOR_ATTACHMENT5                                  = $8CE5
    #GL_COLOR_ATTACHMENT6                                  = $8CE6
    #GL_COLOR_ATTACHMENT7                                  = $8CE7
    #GL_COLOR_ATTACHMENT8                                  = $8CE8
    #GL_COLOR_ATTACHMENT9                                  = $8CE9
    #GL_COLOR_ATTACHMENT10                                 = $8CEA
    #GL_COLOR_ATTACHMENT11                                 = $8CEB
    #GL_COLOR_ATTACHMENT12                                 = $8CEC
    #GL_COLOR_ATTACHMENT13                                 = $8CED
    #GL_COLOR_ATTACHMENT14                                 = $8CEE
    #GL_COLOR_ATTACHMENT15                                 = $8CEF
    #GL_DEPTH_ATTACHMENT                                   = $8D00
    #GL_STENCIL_ATTACHMENT                                 = $8D20
   
    #GL_STENCIL_INDEX1                                     = $8D46
    #GL_STENCIL_INDEX4                                     = $8D47
    #GL_STENCIL_INDEX8                                     = $8D48
    #GL_STENCIL_INDEX16                                    = $8D49
   
    #GL_DEPTH24_STENCIL8                                   = $88F0
    #GL_DEPTH_COMPONENT32F                                 = $8CAC
    #GL_DEPTH32F_STENCIL8                                  = $8CAD
    #GL_FLOAT_32_UNSIGNED_INT_24_8_REV                     = $8DAD
    #GL_DEPTH_STENCIL                                      = $84F9
    #GL_DEPTH_STENCIL_ATTACHMENT                           = $821A
   
    #GL_BGR                                                = $80E0
    #GL_BGRA                                               = $80E1
    #GL_RGBA32F                                            = $8814
    #GL_RGB32F                                             = $8815
    #GL_RGBA16F                                            = $881A
    #GL_RGB16F                                             = $881B
    #GL_UNSIGNED_INT_24_8                                  = $84FA
   
    #GL_TEXTURE_CUBE_MAP                                   = $8513
    #GL_TEXTURE_BINDING_CUBE_MAP                           = $8514
    #GL_TEXTURE_CUBE_MAP_POSITIVE_X                        = $8515
    #GL_TEXTURE_CUBE_MAP_NEGATIVE_X                        = $8516
    #GL_TEXTURE_CUBE_MAP_POSITIVE_Y                        = $8517
    #GL_TEXTURE_CUBE_MAP_NEGATIVE_Y                        = $8518
    #GL_TEXTURE_CUBE_MAP_POSITIVE_Z                        = $8519
    #GL_TEXTURE_CUBE_MAP_NEGATIVE_Z                        = $851A
    #GL_PROXY_TEXTURE_CUBE_MAP                             = $851B
    #GL_MAX_CUBE_MAP_TEXTURE_SIZE                          = $851C
   
    #GL_DELETE_STATUS                                      = $8B80
    #GL_COMPILE_STATUS                                     = $8B81
    #GL_LINK_STATUS                                        = $8B82
    #GL_VALIDATE_STATUS                                    = $8B83
    #GL_INFO_LOG_LENGTH                                    = $8B84
    #GL_ATTACHED_SHADERS                                   = $8B85
    #GL_ACTIVE_UNIFORMS                                    = $8B86
    #GL_ACTIVE_UNIFORM_MAX_LENGTH                          = $8B87
    #GL_SHADER_SOURCE_LENGTH                               = $8B88
    #GL_ACTIVE_ATTRIBUTES                                  = $8B89
    #GL_ACTIVE_ATTRIBUTE_MAX_LENGTH                        = $8B8A
    #GL_FRAGMENT_SHADER_DERIVATIVE_HINT                    = $8B8B
    #GL_SHADING_LANGUAGE_VERSION                           = $8B8C
    #GL_CURRENT_PROGRAM                                    = $8B8D
    #GL_POINT_SPRITE_COORD_ORIGIN                          = $8CA0
    #GL_LOWER_LEFT                                         = $8CA1
    #GL_UPPER_LEFT                                         = $8CA2
    #GL_STENCIL_BACK_REF                                   = $8CA3
    #GL_STENCIL_BACK_VALUE_MASK                            = $8CA4
    #GL_STENCIL_BACK_WRITEMASK                             = $8CA5
   
    #GL_PIXEL_PACK_BUFFER                                  = $88EB
    #GL_PIXEL_UNPACK_BUFFER                                = $88EC
    #GL_PIXEL_PACK_BUFFER_BINDING                          = $88ED
    #GL_PIXEL_UNPACK_BUFFER_BINDING                        = $88EF
  CompilerEndIf


Last edited by benmalartre on Tue Jan 31, 2017 9:42 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: PB 5.51 GL Constants
PostPosted: Tue Jan 31, 2017 9:38 pm 
Offline
User
User

Joined: Thu Mar 14, 2013 11:24 am
Posts: 19
No problems with the encoding of my shaders...

Here is my shader Module

Code:
;============================================================================================
; Shader Module Declararion
;============================================================================================
XIncludeFile "../libs/OpenGL.pbi"
XIncludeFile "../libs/GLFW.pbi"
XIncludeFile "../libs/OpenGLExt.pbi"
XIncludeFile "../core/Log.pbi"

DeclareModule Shader
  UseModule OpenGL
  UseModule GLFW
 
  Enumeration
    #SHADER_VERTEX
    #SHADER_GEOMETRY
    #SHADER_FRAGMENT
  EndEnumeration
 
 
  Structure Shader_t
    s.s
    path.s
  EndStructure
 
  ;Global GLSL_PATH.s = "D:\Projects\PureBasic\Modules\glsl\"
  If FileSize("../../glsl120")=-2
    If OpenGL::#USE_LEGACY_OPENGL
      Global GLSL_PATH.s = "../../glsl120/"
    Else
      Global GLSL_PATH.s = "../../glsl/"
    EndIf
 
  Else
    If OpenGL::#USE_LEGACY_OPENGL
      Global GLSL_PATH.s = "glsl120/"
    Else
      Global GLSL_PATH.s = "glsl/"
    EndIf
  EndIf
 
   
 
   
   
 
  Declare New(type.i,str.s)
  Declare Delete(*shader.Shader_t)
  Declare.s DeCodeUnicodeShader(unicode.s)
  Declare OutputCompileLog(shader.OpenGL::GLuint)
  Declare Create(*code,type.i,name.s)
  Declare.s LoadFile(filename.s)
EndDeclareModule

;============================================================================================
; Program Module Declararion
;============================================================================================
DeclareModule Program
  ;UseModule OpenGL
  Structure Program_t
    *vert.Shader::Shader_t
    *geom.Shader::Shader_t
    *frag.Shader::Shader_t
   
    pgm.OpenGL::GLuint
  EndStructure
 
  Declare New(name.s,s_vert.s="",s_frag.s="")
  Declare NewFromName(name.s)
  Declare Delete(*pgm.Program_t)
  Declare Create(vertex.s, fragment.s, deb.b)
  Declare Create2(vertex.s, geometry.s,fragment.s, deb.b)
  Declare.l Build(*pgm.Program_t,name.s)
EndDeclareModule


;============================================================================================
; Shader Module Implementation
;============================================================================================
Module Shader
  ;UseModule OpenGL
  UseModule OpenGLExt
 
  ;-------------------------------------------
  ; Constructor
  ;-------------------------------------------
  Procedure New(type.i,str.s)
    Protected *shader.Shader_t = AllocateMemory(SizeOf(Shader_t))
    *shader\s = str
    *shader\path = ""
    ProcedureReturn *shader
  EndProcedure
 
 
  ;-------------------------------------------
  ; Destructor
  ;-------------------------------------------
  Procedure Delete(*shader.Shader_t)
    FreeMemory(*shader)
  EndProcedure
 
  ;-----------------------------------------------------------------------------
  ; Utilities
  ;-----------------------------------------------------------------------------
  ;-------------------------------------------
  ; Translate Shader
  ;-------------------------------------------
  Procedure.s DeCodeUnicodeShader(unicode.s)
    Protected l = StringByteLength(unicode,#PB_Unicode)
    If l>0
      Protected *mem = AllocateMemory(l)
      PokeS(*mem,unicode,-1,#PB_Ascii)
      Protected s.s = PeekS(*mem,l)
      FreeMemory(*mem)
     
      ProcedureReturn s
    Else
      ProcedureReturn ""
    EndIf
   
  EndProcedure
 
  ;-------------------------------------
  ; Output Compile Log
  ;-------------------------------------
  Procedure OutputCompileLog(shader.OpenGL::GLuint)
    Protected buffer = AllocateMemory(512)
    glGetShaderInfoLog(shader,512,#Null,buffer)
 
    CompilerIf #PB_Compiler_Unicode
      Debug PeekS(buffer,512,#PB_Ascii)
    CompilerElse
      Debug PeekS(buffer,512)
    CompilerEndIf
   
    FreeMemory(buffer)
  EndProcedure
 
  ;-------------------------------------
  ; Create GLSL Shader
  ;-------------------------------------
  Procedure Create(*code,type.i,name.s)
    GLCheckError("Before Creating Shader")
    Protected shader.OpenGL::GLuint = glCreateShader(type)
    GLCheckError("Create Shader : ")
    glShaderSource(shader,1,@*code,#Null)
    GLCheckError("Source Shader : ")
    glCompileShader(shader)
    GLCheckError("Compile Shader : ")
   
    Protected status.i
    glGetShaderiv(shader,#GL_COMPILE_STATUS,@status)
    GLCheckError("Get Shader IV : ")
    If status = #True
      Debug "[GLSLCreateShader] Success Compiling Shader ---> "+name
    Else
      Debug "[GLSLCreateShader] Fail Compiling Shader ---> "+name
    EndIf
   
    ;Output Compile Log
    OutputCompileLog(shader)
   
    ProcedureReturn shader
  EndProcedure
 
  ;-------------------------------------
  ; Load GLSL Shader From File
  ;-------------------------------------
  Procedure.s LoadFile(filename.s)
    If ReadFile(0,filename)
      Protected shader.s
      While Not Eof(0)
        shader + ReadString(0,#PB_Ascii)+Chr(10)
         
      Wend
     
;       Protected length = FileSize(filename)
;       Protected shader.s = ReadString(0,#PB_Ascii|#PB_File_IgnoreEOL,length)
      CloseFile(0)
    Else
      ProcedureReturn ""
    EndIf
   
    CompilerIf #PB_Compiler_Unicode
      shader = DeCodeUnicodeShader(shader)
    CompilerEndIf
   
    ProcedureReturn shader
  EndProcedure
 
 

EndModule

;============================================================================================
; Program Module Implementation
;============================================================================================
Module Program
  UseModule OpenGL
  UseModule OpenGLExt
 
  ;-------------------------------------------
  ; Constructor
  ;-------------------------------------------
  Procedure New(name.s,s_vert.s="",s_frag.s="")
   
    Protected *pgm.Program_t = AllocateMemory(SizeOf(Program_t))
    *pgm\vert = Shader::New(#GL_VERTEX_SHADER,s_vert)
    *pgm\frag = Shader::New(#GL_FRAGMENT_SHADER,s_frag)
    *pgm\pgm = Create(*pgm\vert \s, *pgm\frag\s, #True)
    ProcedureReturn *pgm
  EndProcedure
 
  Procedure NewFromName(name.s)
    Protected *pgm.Program_t = AllocateMemory(SizeOf(Program_t))
    Build(*pgm,name)
    ProcedureReturn *pgm
  EndProcedure
 
  ;-------------------------------------------
  ; Destructor
  ;-------------------------------------------
  Procedure Delete(*pgm.Program_t)
    FreeMemory(*pgm)
  EndProcedure
 
  ;--------------------------------------
  ; Create Simple GLSL program
  ;--------------------------------------
 
  Procedure Create(vertex.s, fragment.s, deb.b)
    Protected code.s
    Protected vert.GLuint, frag.GLuint

    vert = Shader::Create(@vertex,#GL_VERTEX_SHADER,"Vertex Shader")
    frag = Shader::Create(@fragment,#GL_FRAGMENT_SHADER,"Fragment Shader")
   
    GLCheckError("Create Shaders : ")
    Protected program.GLuint = glCreateProgram()
    GLCheckError("Create Program : ")
 
    glAttachShader(program,vert)
    GLCheckError("Attach Vertex Shader ")
   
    glAttachShader(program,frag)
    GLCheckError("Attach Fragment Shader ")
   
;     Protected paramName.s = "position"
;     glBindFragDataLocation(program,0,@paramName)
;     GLCheckError("Bind Frag Data Location ")
;     paramName.s = "normal"
;     glBindFragDataLocation(program,1,@paramName)
;     GLCheckError("Bind Frag Data Location ")
;     paramName.s = "color"
;     glBindFragDataLocation(program,2,@paramName)
;     GLCheckError("Bind Frag Data Location ")
   
    glBindAttribLocation(program,0,"position")
    ;glBindAttribLocation(program,1,"surfacePosAttrib")

    glLinkProgram(program)
    GLCheckError("Link Program : ")
   
    glUseProgram(program)
    GLCheckError("Use Program : ")
   
;     glDetachShader(program,vert)
;     glDetachShader(program,frag)
;     
;     glDeleteShader(vert)
;     glDeleteShader(frag)
   
    Protected *mem = AllocateMemory(1024)
    Protected l.GLsizei
    glGetProgramInfoLog(program,1024,@l,*mem)
    Log::Message(GLGETSTRINGOUTPUT(*mem))
    FreeMemory(*mem)
   
     ProcedureReturn program
  EndProcedure
 
  Procedure Create2(vertex.s,geometry.s, fragment.s, deb.b)
    Protected code.s
    Protected vert.GLuint, geom.GLuint, frag.GLuint
 
    vert = Shader::Create(@vertex,#GL_VERTEX_SHADER,"vertex_shader")
    geom = Shader::Create(@geometry,#GL_GEOMETRY_SHADER,"geometry_shader")
    frag = Shader::Create(@fragment,#GL_FRAGMENT_SHADER,"fragment_shader")
   
    GLCheckError("Create Shaders : ")
    Protected program.GLuint = glCreateProgram()
    GLCheckError("Create Program : ")
 
    glAttachShader(program,vert)
    GLCheckError("Attach Vertex Shader ")
   
    glAttachShader(program,geom)
    GLCheckError("Attach Geometry Shader ")
   
    glAttachShader(program,frag)
    GLCheckError("Attach Fragment Shader ")
   
  ;   Protected paramName.s = "outColor"
  ;   glBindFragDataLocation(program,0,@paramName)
  ;   GLCheckError("Bind Frag Data Location ")
  ;   
    glLinkProgram(program)
    GLCheckError("Link Program : ")
   
    glUseProgram(program)
    GLCheckError("Use Program : ")
   
    ProcedureReturn program
  EndProcedure
 
  Procedure.l Build(*pgm.Program_t,name.s)
    Debug "----------------------------------------"
 
    Define code.s
    Defineerr.b
    code = Shader::LoadFile(Shader::GLSL_PATH+name+"_vertex.glsl")
    *pgm\vert = Shader::Create(@code,#GL_VERTEX_SHADER,name+"_vertex")
    code = Shader::LoadFile(Shader::GLSL_PATH+name+"_fragment.glsl")   
    *pgm\frag = Shader::Create(@code,#GL_FRAGMENT_SHADER,name+"_fragment")
   
    err = GLCheckError("Create Shaders : ")
    *pgm\pgm = glCreateProgram()
    err = GLCheckError("Create Program : ")
 
    glAttachShader(*pgm\pgm,*pgm\vert)
    err = GLCheckError("Attach Vertex Shader ")
   
    glAttachShader(*pgm\pgm,*pgm\frag)
    err = GLCheckError("Attach Fragment Shader ")
   
    glBindAttribLocation(*pgm\pgm,0,"position")
   
;     glBindFragDataLocation(program,0,"position")
;     GLCheckError("Bind Frag Data Location ")
;     glBindFragDataLocation(program,1,"normal")
;     GLCheckError("Bind Frag Data Location ")
;     glBindFragDataLocation(program,2,"color")
;     GLCheckError("Bind Frag Data Location ")
   
    glLinkProgram(*pgm\pgm)
    err = GLCheckError("Link Program : ")
  ;   
    glUseProgram(*pgm\pgm)
    err = GLCheckError("Use Program : ")
   
    If err
      Define *mem = AllocateMemory(1024)
      Define l.GLsizei
      glGetProgramInfoLog(*pgm\pgm,1024,@l,*mem)
      Log::Message(GLGETSTRINGOUTPUT(*mem))
      FreeMemory(*mem)
    EndIf
   
  EndProcedure
 
EndModule


Top
 Profile  
Reply with quote  
 Post subject: Re: PB 5.51 GL Constants
PostPosted: Fri Feb 17, 2017 2:06 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Tue Jan 31, 2006 9:43 am
Posts: 458
Location: France
Thank you VERY much benmalartre for this very nice and useful sample of code !
I am very interested in your included files, in particular OpenGLExt.pbi.

_________________
Niffo


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye