Apple Controls in OpenGL

The fun never ends. I am trying to get NSButtons, NSSliders, and all sorts of other Apple provided GUI controls to show up in my OpenGL view. Unfortunately, I am using an OpenGL context created by SDL.

On the flip side, I have created a custom NSOpenGLView subclass and tried to use Interface Builder to layout buttons for an interface. Unfortunately, the NSOpenGLView occludes all other controls and will not display any controls I add programmatically to it's view.

How do you guys do it? Thanks a lot!

Mac users swear by their computers, PC users swear at their computers. ~Unknown

ThemsAllTook Wrote:We don't, usually. It's often more convenient and thematically consistent to implement custom controls in an OpenGL application, rather than using the system-provided ones.

So, you recommend developing my own mouse-intercept code, my own button rendering code, and my own event interpretation code? Wow, that sucks. Alright, well I suppose that is next on the drawing board. Thanks!

Mac users swear by their computers, PC users swear at their computers. ~Unknown

You have 3 options.
1) as mentioned, child window
2) transparent window, change opengl context order to be behind window buffer
3) core animation OpenGL layer for the in-game view, Cocoa widgets on top of that in another core animation layer. Leopard+ only.

Option 3 is the 'safest', but neither gets you the performance boost in fullscreen mode from being able to just swap GL buffers in a true fullscreen GL context, instead of having to copy front buffer to the screen.

Or just use kCGLCPSurfaceOrder, as demonstrated in the (very old) sample code at /Developer/Examples/Cocoa/UnderlaySurface. NSButtons etc will be composited on top of your GL content, and receive events normally.

arekkusu Wrote:Or just use kCGLCPSurfaceOrder, as demonstrated in the (very old) sample code at /Developer/Examples/Cocoa/UnderlaySurface. NSButtons etc will be composited on top of your GL content, and receive events normally.