iDevGames Forums
Apple Controls in OpenGL - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: Apple Controls in OpenGL (/thread-1789.html)



Apple Controls in OpenGL - Talyn - Feb 7, 2009 09:06 PM

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!


Apple Controls in OpenGL - ThemsAllTook - Feb 7, 2009 09:28 PM

Talyn Wrote:How do you guys do it?

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.


Apple Controls in OpenGL - Talyn - Feb 7, 2009 09:38 PM

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!


Apple Controls in OpenGL - TomorrowPlusX - Feb 8, 2009 08:09 AM

One thing I've done is to create a Cocoa child window of the main window. I made that child window transparent, and let it overlay my Cocoa window.

Presumably, there's a big performance hit since the compositor has to perform more blending, but it does work. It won't work in a captured fullscreen mode, however.


Apple Controls in OpenGL - DoG - Feb 8, 2009 08:53 AM

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.


Apple Controls in OpenGL - arekkusu - Feb 8, 2009 11:23 AM

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.


Apple Controls in OpenGL - Talyn - Feb 8, 2009 01:25 PM

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.

Ah, yes please! Sweet! Thanks Arekkusu! That's exactly what I'm looking for!