glfwSwapBuffers 1282 when window is closed

mariojmartin wrote on Tuesday, May 10, 2011:

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 wrote on Tuesday, May 10, 2011:

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

mariojmartin wrote on Tuesday, May 10, 2011:

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

elmindreda wrote on Tuesday, May 10, 2011:

This is true. My bad.

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

mariojmartin wrote on Tuesday, May 10, 2011:

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 wrote on Tuesday, May 10, 2011:

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

mariojmartin wrote on Tuesday, May 10, 2011:

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

elmindreda wrote on Tuesday, May 10, 2011:

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.