PDA

View Full Version : glGenFramebuffersEXT segmentation fault



nachovall
09-09-2010, 02:48 AM
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,

ZbuffeR
09-09-2010, 02:56 AM
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

nachovall
09-09-2010, 03:08 AM
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.

ZbuffeR
09-09-2010, 04:22 AM
Maybe it is an EXT versus ARB issue :
http://www.opengl.org/registry/specs/ARB/framebuffer_object.txt
Try with glGenFramebuffersARB ?

mhagain
09-09-2010, 08:41 AM
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.

nachovall
09-10-2010, 01:41 AM
Maybe it is an EXT versus ARB issue :
http://www.opengl.org/registry/specs/ARB/framebuffer_object.txt

Maybe, but which? Is very difficult to find.



Try with glGenFramebuffersARB ?
I'll try first to solve it using glGenFramebuffersEXT. If it can't, I'll check this option.

Thank you.

nachovall
09-10-2010, 01:46 AM
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.

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?


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).

I'm using C++.


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.


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.

ZbuffeR
09-10-2010, 03:11 AM
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\n");
}
if (glewIsSupported("GL_ARB_framebuffer_object"){
printf("Newer ARB FBO available\n");
}

nachovall
09-10-2010, 03:29 AM
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\n",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.

ZbuffeR
09-10-2010, 04:53 AM
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 ?