Menu

glfwSwapBuffers 1282 when window is closed

Using GLFW
2011-05-10
2012-11-08
  • mariojmartin

    mariojmartin - 2011-05-10

    Hi,

    I know that tracking OpenGL errors is a pain, but I have noticed that
    glfwSwapBuffers() throws an error when the window is closed. It is a small
    issue, nevertheless. The code is something like this:

    while (running == 1){
            glfwGetWindowSize(&screen_width, &screen_height);
            resize(screen_width, screen_height);
            display();
            glFlush();
            er = glGetError();
            glfwSwapBuffers();
            er = glGetError();
            if (er != GL_NO_ERROR){
                _handle_error_("\nOpenGL error : %i", er); 
            }
            glFinish();
        glfwSleep(0.05);
            // Checks is the window is still active 
        running = glfwGetWindowParam( GLFW_OPENED );
    }
    
     
  • elmindreda

    elmindreda - 2011-05-10

    How do you know that the error is caused by glfwSwapBuffers if you don't check
    the value of er before calling it?

     
  • mariojmartin

    mariojmartin - 2011-05-10

    Because I call glGetError() above, which clears all previous error messages
    from OpenGL.

     
  • elmindreda

    elmindreda - 2011-05-10

    This is true. My bad.

    Which platform is this? Which version of GLFW are you using?

     
  • mariojmartin

    mariojmartin - 2011-05-10

    I am using glfw-2.7 on a Windows XP sp3. The graphic card is an Nvidia 6600,
    compatible up to GL 2.0

     
  • elmindreda

    elmindreda - 2011-05-10

    The error is likely due to the fact that you're calling glGetError after the
    context has been destroyed.

     
  • mariojmartin

    mariojmartin - 2011-05-10

    You may right. If I write
    er = glGetError();
    er = glGetError();
    I still get the same error… Very weird :)
    I suppose that glfwSwapBuffers is where the context is destroyed, and there
    any OpenGL error check should be done after that.

     
  • elmindreda

    elmindreda - 2011-05-10

    Yes.

    By default, glfwSwapBuffers calls glfwPollEvents after having swapped the
    actual buffers and, also by default, when the user attempts to close the
    window, it just gets closed.

    Since GLFW treats the window and context as a unit, the GLFW_OPENED window
    parameter also indicates whether or not there is a context.