Re: Cocoa controls on top of an OpenGL view
Re: Cocoa controls on top of an OpenGL view
- Subject: Re: Cocoa controls on top of an OpenGL view
- From: "Sean McBride" <email@hidden>
- Date: Mon, 4 Jun 2007 13:05:44 -0400
- Organization: Rogue Research
On 2007-06-03 11:12, John Stiles said:
>Is there a recommended way to float Cocoa controls on top of an
>NSOpenGLView?
John,
We do the following, and it works well. Basically, we use the technique
of this sample code:
/Developer/Examples/OpenGL/Cocoa/UnderlaySurface/
(Beware it does not build correctly, IIRC, the Info.plist has the wrong
class name for NSApplication)
Your Cocoa controls must be subviews of the OpenGL view, else there will
be drawing problems. Your OpenGL view must do:
- (void)viewDidMoveToWindow
{
[super viewDidMoveToWindow];
[[self window] setOpaque:NO];
}
- (BOOL)isOpaque
{
return YES;
}
- (void)drawRect:(NSRect)theRect
{
NSRect bounds = [self bounds];
[[NSColor clearColor] set];
NSRectFill(bounds);
// other drawing, ex call super
}
the follow initialization is also needed somewhere, maybe in
viewDidMoveToWindow:
NSOpenGLContext* context = ...;
GLInt order = -1;
[context setValues:&order forParameter:NSOpenGLCPSurfaceOrder];
Also, you should google "NSOpenGLCPSurfaceOrder" and "UnderlaySurface".
hth,
--
____________________________________________________________
Sean McBride, B. Eng email@hidden
Rogue Research www.rogue-research.com
Mac Software Developer Montréal, Québec, Canada
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden