I’m very new to OpenGL (and I don’t know anything about glew or glut), but I’m trying to follow some examples on how to create a framebuffer object (for rendering to a texture).
I’m using BlitzMax which is a wrapper around OpenGL but everything else works except when I try to use a framebuffer object.
Do I have to somehow enable the framebuffer extension somehow? I thought the very first call to initialize an FBO was glGenFramebuffersEXT(). Am I wrong?
Here is my code:
Import Pub.Glew
'SetGraphicsDriver(GLGraphicsDriver())
GLGraphics(320, 200)
GlewInit()
' Laptop = OpenGL v1.5
' Laptop = ARB_multitexture present!
Enable2D()
glEnable(GL_LINE_SMOOTH)
glEnable(GL_POLYGON_SMOOTH)
glEnable(GL_ALPHA_TEST)
glEnable(GL_BLEND)
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST)
glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST)
glHint(GL_POINT_SMOOTH_HINT, GL_NICEST)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
' *************************
Local fbo : Int Ptr;
glGenFramebuffersEXT(1, fbo);
' *************************
glClearColor(0.0, 0.0, 0.0, 0.0)
While Not KeyHit(KEY_ESCAPE)
glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT);
glBegin(GL_LINES)
glVertex2i(0 , 0)
glVertex2i(320, 200)
glEnd()
Flip()
Wend
Function Enable2D()
Local vPort : Int[4]
glGetIntegerv(GL_VIEWPORT, vPort);
glMatrixMode(GL_PROJECTION) ;
glLoadIdentity();
glOrtho(0, vPort[2], vPort[3], 0, -1, 1) ;
glMatrixMode(GL_MODELVIEW) ;
glLoadIdentity();
End Function
The memory exception is occuring on the glGenFramebufferEXT() line.
Supposedly the way to check for the FBO extension support is this:
If glGenFramebuffersEXT=Null Notify "Your computer doesn't support FBOs"
This code works so it looks like my video card DOES support FBOs so I must be doing something wrong.
Please help :\