Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: segFault on glGenFrambuffers. Very odd behavior

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2014
    Posts
    8

    segFault on glGenFrambuffers. Very odd behavior

    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
    Code :
    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\n",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
    Code :
    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
    Code :
    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.

  2. #2
    Intern Contributor
    Join Date
    Mar 2014
    Location
    San Jose, CA
    Posts
    58
    The first argument to glGenFramebuffers is the number of framebuffer ids you want to generate. In your example, that should be 1.

  3. #3
    Junior Member Newbie
    Join Date
    Feb 2014
    Posts
    8
    *facepalm*

    thankyou...i feel so much shame right now lol.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •