Apple Controls in OpenGL

Member
Posts: 215
Joined: 2008.06
Post: #1
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

iSayz
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #2
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.
Quote this message in a reply
Member
Posts: 215
Joined: 2008.06
Post: #3
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

iSayz
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #4
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.
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #5
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.
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #6
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.
Quote this message in a reply
Member
Posts: 215
Joined: 2008.06
Post: #7
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!

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

iSayz
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Cocoa controls on top of NSOpenGLView wadesworld 5 5,751 Apr 6, 2009 01:38 AM
Last Post: arekkusu
  Custom Controls SethWillits 4 3,571 Aug 6, 2002 06:26 PM
Last Post: Jeff Binder