• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Cocoa controls on top of an OpenGL view
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Cocoa controls on top of an OpenGL view
      • From: John Stiles <email@hidden>
References: 
 >Cocoa controls on top of an OpenGL view (From: John Stiles <email@hidden>)

  • Prev by Date: Re: Cocoa controls on top of an OpenGL view
  • Next by Date: Re: Updating Image metadata
  • Previous by thread: Re: Cocoa controls on top of an OpenGL view
  • Next by thread: Re: Cocoa controls on top of an OpenGL view
  • Index(es):
    • Date
    • Thread