glGenFramebuffersEXT crash

Started by
5 comments, last by mlt 15 years, 3 months ago
In some code where I create a Frame Buffer object I have:

class FBO {
...
      static GLuint create()
      {
        GLuint id = 0;
        glGenFramebuffersEXT(1, &id);
        return id;
      }
...
};


But when the line: glGenFramebuffersEXT(1, &id); gets executed the application crashes (found this with the debugger). Another post on the forum deals with the same problem: http://www.gamedev.net/community/forums/topic.asp?topic_id=386881 but cannot see how I can used the proposed solution. Why does the above line result in a crash? EDIT: I have found another post on the forum: http://www.gamedev.net/community/forums/topic.asp?topic_id=417657 I have now tried:

class FBO {
...
      static GLuint create()
      {
        GLuint id = 0;
        glGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC)wglGetProcAddress("glGenFramebuffersEXT");
        glGenFramebuffersEXT(1, &id);
        return id;
      }
...
};

but I still get the same error. Any hints are still appreciated!
Advertisement
Maybe it's called before you have a proper OpenGL Render Context set up, things tend to crash if you don't have one.
And did you check that your symbol ("glGenFramebuffersEXT") isn't NULL?
http://www.opengl.org/wiki/index.php/Common_Mistakes#The_Object_Oriented_Language_Problem

also ready the basics
http://www.opengl.org/wiki/index.php/Getting_started
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
Could you be more specific? I create an instance of FBO in an application class as a field:

class App {protected:......FBO fbo;......


the fbo object never gets created because of the crash when

glGenFramebuffersEXT(1, &id)

is called.
Quote:Original post by V-man
http://www.opengl.org/wiki/index.php/Common_Mistakes#The_Object_Oriented_Language_Problem

also ready the basics
http://www.opengl.org/wiki/index.php/Getting_started


I have tried to call:

glewInit();

But I still get the same crash.

EDIT:
Ok the glewInit() call actually returns an error, but I don't know how to fix it. The problems seems to be that the FBO object fbo cannot be field in the class App. If I move the creation of fbo to a function inside App it works. But then I can only use fbo inside that function!

[Edited by - mlt on December 28, 2008 1:50:05 PM]
Like the link says, if there is no GL context, then it won't work.
wglGetProcAddress won't work and will just return NULL.
glewInit won't work because it also uses wglGetProcAddress to get all the addresses for all the GL functions.

wglGetCurrentContext() will however work and tell you what the GL context is. Most likely there is none and it returns NULL.
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
If I create the field as a pointer to a FBO object it works. So the solution is to create a pointer (and then use new when I need to use the FBO) instead of a non-pointer field.

This topic is closed to new replies.

Advertisement