moderated [OpenGL] drawing by -[NSOpenGLContext setView:]

James Walker

I see that Apple's Mac OpenGL mailing list is no more. Not too surprising, as OpenGL is now deprecated, but it will be a long time before I can move to Metal.

For reasons that we need not get into, sometimes my code disassociates an NSOpenGLContext from an NSView and destroys the context, and at some later time creates a new NSOpenGLContext and sets the same NSView as its drawable. The weird problem is that at the moment that -[NSOpenGLContext setView:] is called, the view draws the image that was last drawn by the deceased NSOpenGLContext. Any idea how to prevent that? I came up with a somewhat distasteful way: Just before destroying the old NSOpenGLContext, I set its surface order to -1, so that if it shows up again, it's hidden behind my window.

Join to automatically receive all group messages.