glGenFramebuffersEXT segmentation fault

Hi all

I’m getting and segmentation fault error when I call


GLuint fbo;
glGenFramebuffersEXT(1, &fbo);

My card supports render to texture (GTX 480), and It always have worked fine until I have added OpenCL libs.

I don’t know why is this happening. Does anybody knows how can I found the error?

Thank you very much,

How do you get your function pointer for glGenFramebuffersEXT ?

Have a read about how to deal with new GL functions not in the ABI :
http://www.opengl.org/wiki/Getting_started#OpenGL_2.0.2B_and_extensions

The thing is that I’ve used FBO several times with the same code that now is crashing. This happens since I add the OpenCL libs.

The strangest thing is that I remove all dependencies of OpenCL (that is, the code and compiler options are the same as when it worked) and still crashes!!

I thing there is a problem of versions but I don’t know how to check it.

Maybe it is an EXT versus ARB issue :
http://www.opengl.org/registry/specs/ARB/framebuffer_object.txt
Try with glGenFramebuffersARB ?

Set a breakpoint at your call to glGenFramebuffersEXT, run it in the debugger and check the address of your glGenFramebuffersEXT function pointer. Many segfaults in OpenGL are a result of a NULL function pointer.

If glGenFramebuffersEXT isn’t declared in the same file as it’s used, and you’re using C, make sure that it’s "extern"ed properly too otherwise C’s “default int” will trip you up (I got caught by that one recently).

You should also initialize your “fbo” variable to 0 before calling glGenFramebuffersEXT. Aside from it being good practice, an uninitialized local variable may be given an arbitrary value (depending on your compiler and whether you’re doing a debug or a release build) which will result in undefined behaviour if glGenFramebuffersEXT attempts to do anything with it’s value before assigning it a new value.

Maybe, but which? Is very difficult to find.

I’ll try first to solve it using glGenFramebuffersEXT. If it can’t, I’ll check this option.

Thank you.

You are right, glGenFramebuffersEXT function pointer is Null. But how can I solve it? I mean, this is a function pointer creater from glew, is it?

I’m using C++.

This shouldn’t be a big deal since the variable is not used untill glGenFramebuffersEXT is called. I did anyway and it still doesn’t work.

Thank you.

Maybe your implementation does not support the old EXT version, but only the new ARB version.
Did you check for extension support ?


if (glewIsSupported("GL_EXT_framebuffer_object"){
 printf("Old EXT FBO available
");
}
if (glewIsSupported("GL_ARB_framebuffer_object"){
 printf("Newer ARB FBO available
");
}

I checked it:


if (glewIsSupported("GL_EXT_framebuffer_object"))
	cout<<"Old EXT FBO available"<<endl;
else
	cout<<"Old EXT FBO NOT available"<<endl;
if (glewIsSupported("GL_ARB_framebuffer_object"))
	cout<<"Newer ARB FBO available"<<endl;
else
	cout<<"Old ARB FBO NOT available"<<endl;

and the result was NOT supported in both cases. How is this possible? I was using GL_EXT_framebuffer_object few days ago until I link with OpenCL libraries.

New Test:


err = glewInit()
if (GLEW_OK != err)
{
	const GLubyte *e = glewGetErrorString(err);
	fprintf(stderr, "Error: %s
",glewGetErrorString(err));
}
if (glewIsSupported("GL_EXT_framebuffer_object"))
	cout<<"Old EXT FBO available"<<endl;
else
	cout<<"Old EXT FBO NOT available"<<endl;
if (glewIsSupported("GL_ARB_framebuffer_object"))
	cout<<"Newer ARB FBO available"<<endl;
else
	cout<<"Old ARB FBO NOT available"<<endl;

Now, looks like Old EXT FBO is available.

So, none worked because you forgot the glewInit ?
Then EXT is available ? And now, when you get function pointer for glGenFramebuffersEXT, is it null or not ?