2

NSOpenGLContext and one-shot

 3 years ago
source link: https://www.mikeash.com/pyblog/nsopenglcontext-and-one-shot.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
NSOpenGLContext and one-shot
mikeash.com: just this guy, you know?
NSOpenGLContext and one-shot
by Mike Ash  

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:

Did you enjoy this article? I'm selling whole books full of them! Volumes II and III are now out! They're available as ePub, PDF, print, and on iBooks and Kindle. Click here for more information.

No comments have been posted.

Comments RSS feed for this page

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.

Name:The Answer to the Ultimate Question of Life, the Universe, and Everything?Comment:Formatting: <i> <b> <blockquote> <code>.NOTE: Due to an increase in spam, URLs are forbidden! Please provide search terms or fragment your URLs so they don't look like URLs.

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK