Next article: Fluid Simulation for Dummies
Previous article: What Every Programmer Should Know
Tags: advice cocoa opengl
If you've done any OpenGL work in Cocoa, you may have noticed that OpenGL surfaces behave badly when it comes to things like miniaturization and deminiaturization to the Dock. This recently caused some big problems for me, and I finally found out how to get rid of these problems altogether. It wasn't excruciatingly hard to find, but I wanted to make a post about it here so that it could be found with words like "deminiaturization".My problem was worse than usual because I'm using a raw NSOpenGLContext, not an NSOpenGLView. When I miniaturized the window to the Dock and then deminiaturized, my OpenGL content was gone and wouldn't redraw. While searching for the secret sauce to get it to redraw, I found out how to stop it from blanking in the first place, which is even better.
The "secret" is to turn off the "One shot" checkbox for your window in Interface Builder. This setting basically destroys your window while it's hidden, including while it's miniaturized to the Dock. Destroying the window breaks the link between your context and the window, resulting in it blanking out as it flies toward the Dock. Disabling this checkbox makes sure the window always sticking around, so that your OpenGL content looks indistinguishable from the rest.
I discovered this in this mailing list post: http://lists.apple.com/archives/mac-opengl/2003/Apr/msg00132.html
No comments have been posted.
Add your thoughts, post a comment:
Spam and off-topic posts will be deleted without notice. Culprits may be publicly humiliated at my sole discretion.