from geometry to pixels

[NSOpenGLContext flushBuffer] might not do what you think

OpenGL on MacOS X has some problems with bugs and missing support of newer features. Sadly, even the Cocoa part of the 3D API (which gets defined by Apple, not the ARB) has some quirks. [NSOpenGLContext flushBuffer] is used to swap the backbuffer to the front in double buffered applications, in single buffered apps it does nothing – so far so good. But: it doesn’t switch the front and back buffer of the default framebuffer – it is defined to swap whatever framebuffer is active! According to the OpenGL specs, framebuffer objects are always singlebuffered so, indirectly [NSOpenGLContext flushBuffer] is defined to do nothing if another FB is bound than FB 0.
I guess only Apple knows why they ‘support’ all kinds of framebuffers by doing nothing…

Note: If you’re using a platform independent framework for your window handling, like GLFW, you might also run into this problem without knowing it!

Just to make this clear, it’s not a bug, the behavior is well defined and documented. It’s just a bit strange and the implications might not be clear after a short look at the docs. I ran into this problem so this post might be a help for the next one googleing this behavior.

, ,

2 thoughts on “[NSOpenGLContext flushBuffer] might not do what you think

Leave a Reply

Your email address will not be published. Required fields are marked *