currently im trying to get the screen rendered to a texture and over the course of doing this i have ran into a problem with the
glGenFramebuffers() function.
Here is my main function
main(int argc, char **argv, char **envp)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGBA|GLUT_DOUBLE|GLUT_DEPTH);
glutInitWindowSize(800, 600);
// glutInitContextVersion(4, 2);
// glutInitContextFlags(GLUT_FORWARD_COMPATIBLE | GLUT_DEBUG);
glutCreateWindow("Shaders, Bitch");
glutIdleFunc(IdleFunction);
glutReshapeFunc(changeViewport);
initGL();
modelInit();
glEnable(GL_DEPTH_TEST);
glutDisplayFunc(render);
glewInit();
ttime=glutGet(GLUT_ELAPSED_TIME);
postProcessShader.ShaderInit("RenderFrametoQuad.vsh","RenderFrametoQuad.fsh");
WorldRenderer.ShaderInit("vertexShader.vsh","fragmentShader.fsh");
bufferSetup(&VaoID,&VboID,&indexBufferID,Meshes[0].vertcnt);
glClearColor(.5f, 0.0f, 0.0f, 0.0f );
camera.initCamera(85,WorldRenderer.shaderProgramID);
// createFBO();
GLuint FBID=0;
//It segfaults right here
glGenFramebuffers(GL_DRAW_FRAMEBUFFER, &FBID);
printf("===============FRAME BUFFER ID:%d
",FBID );//this statement doesnt actually get printed
glutKeyboardFunc(KeyPressed);
glutKeyboardUpFunc(keyUp);
glutSpecialFunc(SpKeyPressed);
glutSpecialUpFunc(SpKeyUp);
cout<<"VERSION IS--->>>"<<glGetString(GL_VERSION)<<endl;
glutTimerFunc(1000/60, mloop, 0); /* 60 == frame rate */
glutMainLoop();
}
When i back trace the segfault in gdb i get this
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff4362276 in ?? () from /usr/lib/fglrx/dri/fglrx_dri.so
(gdb) bt
#0 0x00007ffff4362276 in ?? () from /usr/lib/fglrx/dri/fglrx_dri.so
#1 0x00007ffff3ef5151 in ?? () from /usr/lib/fglrx/dri/fglrx_dri.so
#2 0x000000000040628d in main (argc=1, argv=0x7fffffffdf08, envp=0x7fffffffdf18) at main.cpp:322
I originally had this function call in a another function and it also used a global variable however for the purposes of this thread ive boiled it down to this.
If i comment out
glGenFramebuffers(GL_DRAW_FRAMEBUFFER, &FBID);
than the program runs fine and everything renders like it should.
this is my compile command
g++ main.cpp Keyboard.cpp shaderTools.cpp Camera.cpp TextureLoader.cpp -lGL -lm -lGLEW -lGLU -lglut -g -o mloader
Does anyone have any idea whats going on here? Its really holding me up and im kinda crunched for time so i would really really apreciate anyone’s insight here.
Also, im using linux with an AMD card.