PDA

View Full Version : Why do I get a memory exception when trying to create an FBO? Please help!



sofakng
05-29-2007, 12:08 PM
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 FunctionThe 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 :\

Overmind
05-29-2007, 01:08 PM
Local fbo : Int Ptr;
glGenFramebuffersEXT(1, fbo);Your variable "fbo" propably contains a null pointer here.

I'm not really fluent in basic, but I think it should rather be:

Local fbo : Int;
glGenFramebuffersEXT(1, VarPtr(fbo));I'm not sure about that VarPtr part, substitute whatever is used to get the address of a variable in your language...

sofakng
05-29-2007, 01:42 PM
I've tried what you suggested above but that doesn't work either :(

Maybe my video card doesn't have support for the framebuffer extension?

Overmind
05-30-2007, 01:24 AM
1) What's the content of your extension string?
2) What's your video card? ;)


If glGenFramebuffersEXT=Null Notify "Your computer doesn't support FBOs"You cannot reliably test extension support that way. You have to look at the extension string. Glew does this for you, you just have to check the GLEW_EXT_framebuffer_object flag.