Update for Glew and Opengl -> 4.0
BlitzMax Forums/OpenGL Module/Update for Glew and Opengl -> 4.0
| ||
| I'm trying to update Opengl to OpenGL 4.0 ( with glew 1.5.4 ) for my 3D engine ( BigBang -> an OpenGl engine intended to replace Blitz3D ) For now, those are the step : 1/ BackUp the pub.opengl and pub.glew !!! 2/ Download last version of glew http://sourceforge.net/projects/glew/files/glew/1.5.4/ ( glew-1.5.4.zip ) 3/ Extracted countain of "glew-1.5.4.zip" to a folder 3.1/ Copy/Paste "GL" directory ( from "include" directory ) to "pub.glew/GL" ( overwrite existing file ) 3.2/ Copy/Paste "glew.c" ( from "src" Directory ) to "pub.glew" ( overwrite existing file ) 4/ Update "Glew2Bmx.bmx" ( in pub.glew ) to : 4.1 -> update the code and save it 4.2 -> Run the code. 5 / Replace files 5.1 / Replace glew.bmx with __glew__.bmx ( replacing name of course ) 5.2 / Replace opengl.bmx ( in pub.opengl ) with __opengl__.bmx 6 / Rebuild modules Every thing seems to work fine except a bug in Z-Order ... but, maybe I missed something ? |
| ||
| Oo , I find the error -> actually, using Glew2Bmx ( original ) it seems to have an error , it just can't get any GL Constant with value = "1" So there is no "GL_TRUE" and a lot of other const... Any ideas why BRL did this ? |
| ||
| It's because there are duplicate identifiers in the glew.bmx generated code. The code above will create glew.bmx correctly. This code creates opengl.bmx
Strict
Framework brl.basic
Import brl.map
Import brl.retro
Rem
Cheezy little app to convert glew.h to bmx source.
extract glew header to __opengl__.bmx and __glew__.bmx
End Rem
Local OutOpenGLName$="__opengl__.bmx"
Local OutGlewName$="__glew__.bmx"
Global OutOpenGL:TStream = WriteStream(OutOpenGLName$)
Global OutGLew :TStream = WriteStream(OutGlewName$)
Global Out :TStream = OutOpenGL
' Write Headers
WriteLine OutOpenGL, "Strict"
WriteLine OutOpenGL, "Rem"
WriteLine OutOpenGL, "bbdoc: Graphics/OpenGL 1.1"
WriteLine OutOpenGL, "End Rem"
WriteLine OutOpenGL, "Module Pub.OpenGL"
WriteLine OutOpenGL, ""
WriteLine OutOpenGL, "ModuleInfo "+Chr(34)+"Version: 1.02"+Chr(34)
WriteLine OutOpenGL, "ModuleInfo "+Chr(34)+"License: SGI Free Software License B"+Chr(34)
WriteLine OutOpenGL, "ModuleInfo "+Chr(34)+"Modserver: brl"+Chr(34)
WriteLine OutOpenGL, ""
WriteLine OutOpenGL, "ModuleInfo "+Chr(34)+"History: 1.02 Release"+Chr(34)
WriteLine OutOpenGL, "ModuleInfo "+Chr(34)+"History: Restored GLU"+Chr(34)
WriteLine OutOpenGL, ""
WriteLine OutOpenGL, "?MacOS"
WriteLine OutOpenGL, "Import "+Chr(34)+"-Framework AGL"+Chr(34)
WriteLine OutOpenGL, "Import "+Chr(34)+"-Framework OpenGL"+Chr(34)
WriteLine OutOpenGL, "?Win32"
WriteLine OutOpenGL, "Import "+Chr(34)+"-lglu32"+Chr(34)
WriteLine OutOpenGL, "Import "+Chr(34)+"-lopengl32"+Chr(34)
WriteLine OutOpenGL, "?Linux"
WriteLine OutOpenGL, "Import "+Chr(34)+"-lGL"+Chr(34)
WriteLine OutOpenGL, "Import "+Chr(34)+"-lGLU"+Chr(34)
WriteLine OutOpenGL, "?"
WriteLine OutOpenGL, ""
WriteLine OutOpenGL, "Import "+Chr(34)+"glu.bmx"+Chr(34)
WriteLine OutOpenGL, ""
WriteLine OutOpenGL, "Extern "+Chr(34)+"Os"+Chr(34)
WriteLine OutGLew, "Strict"
WriteLine OutGLew, ""
WriteLine OutGLew, "Rem"
WriteLine OutGLew, "bbdoc: Graphics/Glew"
WriteLine OutGLew, "End Rem"
WriteLine OutGLew, "Module Pub.Glew"
WriteLine OutGLew, ""
WriteLine OutGLew, "ModuleInfo "+Chr(34)+"Version: 1.07"+Chr(34)
WriteLine OutGLew, "ModuleInfo "+Chr(34)+"Author: Milan Ikits, Marcelo Magallon"+Chr(34)
WriteLine OutGLew, "ModuleInfo "+Chr(34)+"License: SGI Free Software License B"+Chr(34)
WriteLine OutGLew, "ModuleInfo "+Chr(34)+"Copyright: Milan Ikits, Marcelo Magallon"+Chr(34)
WriteLine OutGLew, "ModuleInfo "+Chr(34)+"Modserver: brl"+Chr(34)
WriteLine OutGLew, ""
WriteLine OutGLew, "ModuleInfo "+Chr(34)+"History: 1.07 Release"+Chr(34)
WriteLine OutGLew, "ModuleInfo "+Chr(34)+"History: Updated To glew 1.5.1"+Chr(34)
WriteLine OutGLew, "ModuleInfo "+Chr(34)+"History: Modified glew2bmx To handle a GLint64EXT, GLuint64EXT And char - UNTESTED!"+Chr(34)
WriteLine OutGLew, "ModuleInfo "+Chr(34)+"History: 1.06 Release"+Chr(34)
WriteLine OutGLew, "ModuleInfo "+Chr(34)+"History: Rebuilt To fix MacOs ld errors"+Chr(34)
WriteLine OutGLew, "ModuleInfo "+Chr(34)+"History: 1.05 Release"+Chr(34)
WriteLine OutGLew, "ModuleInfo "+Chr(34)+"History: Removed glew2bmx.exe!"+Chr(34)
WriteLine OutGLew, "ModuleInfo "+Chr(34)+"History: 1.04 Release"+Chr(34)
WriteLine OutGLew, "ModuleInfo "+Chr(34)+"History: Updated To glew 1.3.4"+Chr(34)
WriteLine OutGLew, "ModuleInfo "+Chr(34)+"History: 1.03 Release"+Chr(34)
WriteLine OutGLew, "ModuleInfo "+Chr(34)+"History: Updated To GL2.0 compatible version 1.3.3"+Chr(34)
WriteLine OutGLew, ""
WriteLine OutGLew, "Import Pub.OpenGL"
WriteLine OutGLew, ""
WriteLine OutGLew, "Import "+Chr(34)+"glew_static.c"+Chr(34)
WriteLine OutGLew, ""
WriteLine OutGLew, "Extern "+Chr(34)+"Os"+Chr(34)
Global StartOutputGlew :Byte = False
Function Happen (chaine$, bbDoc$)
WriteLine Out,"rem"
WriteLine Out,"bbdoc: "+bbDoc
WriteLine Out,"endrem"
WriteLine Out,chaine
If StartOutputGlew = False
If Instr ( chaine , "glViewport" )
Out = OutGLew
StartOutputGlew = True
EndIf
EndIf
End Function
Global in:TStream=ReadStream( "GL/glew.h" )
Global curr$,text$
Local funMap:TMap=New TMap
Local constMap:TMap=New TMap
While Not Eof(in)
text=in.ReadLine()
bump
If curr="GLAPI"
bump
Local funty$=gltype()
If funty<>"x" And curr="GLAPIENTRY"
Local id$=bump()
If id[..2]="gl" And bump()="("
Local proto$=glproto()
If proto<>"x"
Happen ( "Function "+id+funty+"("+proto+")", "GL Function "+id+funty )
EndIf
EndIf
EndIf
Else If curr="#"
If bump()="define"
Local id$=bump()
If id[..11]="GL_VERSION_"
Else If id[..3]="GL_"
If Not constMap.ValueForKey(id)
Local n$=bump()
If n[..2]="0x"
Happen ( "Const "+id+"=$"+n[2..], "GL Const "+id )
Else If n.length And isdigit(n[0]) 'And n<>"1"
Happen ( "Const "+id+"="+n, "GL Const "+id )
EndIf
constMap.Insert id,n
EndIf
Else If id[..5]="GLEW_"
If bump()="GLEW_GET_VAR" And bump()="("
Local sym$=bump()
If sym[..7]="__GLEW_" And bump()=")"
Happen ( "Global GL_"+id[5..]+":Byte=~q"+sym+"~q", "GL Global "+id )
EndIf
EndIf
Else If id[..2]="gl"
If bump()="GLEW_GET_FUN" And bump()="("
Local sym$=bump()
If sym[..6]="__glew" And bump()=")"
Local key$="PFNGL"+sym[6..].ToUpper()+"PROC"
Local val$=String( funMap.ValueForKey( key ) )
If val
Happen ( "Global "+id+val+"=~q"+sym+"~q", "GL Global "+id+val )
Else
DebugLog "***** "+sym+" *****"
EndIf
EndIf
EndIf
EndIf
EndIf
Else If curr="typedef"
bump
Local funty$=gltype()
If funty<>"x" And curr="(" And bump()="GLAPIENTRY" And bump()="*"
Local id$=bump()
If id[..5]="PFNGL" And bump()=")" And bump()="("
Local proto$=glproto()
If proto<>"x"
funMap.Insert id,funty+"("+proto+")"
EndIf
EndIf
EndIf
EndIf
Wend
in.Close
' close outputs
WriteLine OutOpenGL , ""
WriteLine OutOpenGL , "End Extern" ;OutOpenGL.Close()
WriteLine OutGLew , "End Extern"
WriteLine OutGLew , ""
WriteLine OutGLew , "Extern "+Chr(34)+"C"+Chr(34)
WriteLine OutGLew , "Function glewInit()"
WriteLine OutGLew , "End Extern" ;OutGLew.Close()
Function glproto$()
If bump()=")" Return ""
Local proto$,err,argid
Repeat
Local argty$=gltype()
If argty="x" Return argty
Local id$
If curr<>"," And curr<>")" And curr.length And (isalpha(curr[0]) Or curr[0]=Asc("_"))
id$=curr
If bump()="["
While bump()<>"]"
Wend
bump
If Not argty argty="Byte"
argty:+" Ptr"
EndIf
Else
id="arg"+argid
EndIf
argid:+1
If proto proto:+","
proto:+id+"_"+argty
If curr=")"
bump
If proto="arg0_" proto=""
Return proto
EndIf
If curr<>"," Return "x"
bump
Forever
End Function
Function gltype$()
Local ty$
If curr="const"
bump
EndIf
Select curr
Case "void","GLvoid"
ty=""
Case "char","GLbyte","GLubyte","GLchar","GLboolean","GLcharARB"
ty="Byte"
Case "GLshort","GLushort","GLhalf"
ty="Short"
Case "GLint","GLuint","GLenum","GLsizei","GLbitfield"
ty="Int"
Case "GLintptr","GLsizeiptr","GLintptrARB","GLsizeiptrARB"
ty="Int"
Case "GLhandleARB"
ty="Int"
Case "GLint64EXT","GLuint64EXT", "GLint64", "GLuint64"
ty="Long"
Case "GLfloat","GLclampf"
ty="Float"
Case "GLdouble","GLclampd"
ty="Double"
Default
Return "x"
End Select
Repeat
bump
If curr="const" bump
If curr<>"*" Exit
If Not ty ty="Byte"
ty:+" Ptr"
Forever
If ty ty=":"+ty
Return ty
End Function
Function isalpha( c )
Return (c>=Asc("A") And c<=Asc("Z")) Or (c>=Asc("a") And c<=Asc("z"))
End Function
Function isdigit( c )
Return c>=Asc("0") And c<=Asc("9")
End Function
Function isalnum( c )
Return isalpha(c) Or isdigit(c)
End Function
Function isxdigit( c )
Return (c>=Asc("A") And c<=Asc("F")) Or (c>=Asc("a") And c<=Asc("f")) Or isdigit(c)
End Function
Function bump$()
Local i=0
While i<text.length And text[i]<=Asc(" ")
i:+1
Wend
If i=text.length
curr=""
text=""
Return curr
EndIf
text=text[i..]
Local c=text[0]
i=1
If isalpha(c) Or c=Asc("_")
While i<text.length And (isalnum( text[i] ) Or text[i]=Asc("_"))
i:+1
Wend
Else If c>=Asc("0") And c<=Asc("9")
If i<text.length And c=Asc("0") And text[i]=Asc("x")
i:+1
While i<text.length And isxdigit(text[i])
i:+1
Wend
Else
While i<text.length And isdigit(text[i])
i:+1
Wend
EndIf
EndIf
curr=text[..i]
text=text[i..]
Return curr
End Function
|
| ||
| This works fine untill i try to compile in debug mode. I get these errors. Last edited 2012 |
| ||
| Help, i can't debug mi apps anymore :( Did anyone else get this after updating or did i do something wrong? What does this error mean and how can it be fixed? |
| ||
| "1/ BackUp the pub.opengl and pub.glew !!!" Have you made a backup before running the update ? Else, it seems something is missing ... Did you import the pub.glew and initialized glew ? Import pub.glew SetGraphicsDriver GLMax2DDriver() Graphics 800,600,0 GlewInit() |
| ||
| Thx for the reply! Glew is imported and initialized. I have a backup, ill just try again. |
| ||
| I've done this with the latest version of glew(1.9.0) but when I do a version check Graphics3D(1300, 700, 0, 2, 60) Local major:Int Local minor:Int glGetIntegerv​(GL_MAJOR_VERSION​, Varptr major) glGetIntegerv​(GL_MINOR_VERSION​, Varptr minor) Notify major + " . " + minor + " glver: " + te End I get 3.0!?? shouldn't it be 4.3? |
| ||
| They changed how opengl context work awhile ago, you have to open a core context to get all the newer stuff. You will be opening a context the old way based on the code you show and this will generally make a compatability context which only supports up to opengl 3.3 I think, so it will only return a 3.x opengl level. Of course if your gfx card doesnt support the level your trying to create either in hardware or driver then you will not be able to make higher level contexts anyway. Look into wglCreateContextAttribsARB I think thats how you open a higher context. Last edited 2012 |