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!
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!
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.
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!
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.
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.
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.
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.
Ah, yes please! Sweet! Thanks Arekkusu! That's exactly what I'm looking for!
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Cocoa controls on top of NSOpenGLView | wadesworld | 5 | 5,071 |
Apr 6, 2009 01:38 AM Last Post: arekkusu |
|
| Custom Controls | SethWillits | 4 | 3,335 |
Aug 6, 2002 06:26 PM Last Post: Jeff Binder |
|

