• 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: Layer-backed NSOpenGLView not showing up
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Layer-backed NSOpenGLView not showing up


  • Subject: Re: Layer-backed NSOpenGLView not showing up
  • From: David Duncan <email@hidden>
  • Date: Sun, 16 Nov 2008 09:18:40 -0800

On Oct 3, 2008, at 9:46 AM, Albert Martin wrote:

videoLayer = [[CALayer layer] retain];

NSOpenGLPixelFormatAttribute attributes[] = {
NSOpenGLPFANoRecovery,

NSOpenGLPFAColorSize, 24,
NSOpenGLPFAAlphaSize, 8,
NSOpenGLPFADepthSize, 16,
NSOpenGLPFADoubleBuffer,
NSOpenGLPFAAccelerated,
0};

presentationVideoLayer = [[[IWVideoView alloc] initWithFrame: NSMakeRect(0, 0, frameRect.size.width, frameRect.size.height) pixelFormat: [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes]] retain];
[presentationVideoLayer setLayer: videoLayer];
[presentationVideoLayer setWantsLayer: YES];

[[self layer] addSublayer: videoLayer];

[presentationVideoLayer setNeedsDisplay: YES];
[[presentationVideoLayer openGLContext] update];

There are number issues here.

One is as Matt mentioned, your using a plain CALayer when a CAOpenGLLayer is called for. A plain CALayer will not render OpenGL content. In this simple case, you will likely want to just let AppKit create the layer for you (by not calling setLayer:).

Two, your trying to add a layer as a sublayer of itself. That won't work for obvious reasons :). But then, you shouldn't be playing with this layer anyway.

Third, and this one might not actually be an issue for you, is that there is a bug in AppKit that causes layer-backed NSOpenGLViews to use the wrong pixel format for their CAOpenGLLayers. Specifically, if you really need a depth buffer (and aren't just copying a pixel format from elsewhere) then you will need to create your own CAOpenGLLayer subclass and do the proper work there. You can see the CALayerEssentials sample <http://developer.apple.com/samplecode/CALayerEssentials/index.html > for details on how to do that.

This is just an aside, but I notice when you create your view you do alloc/init.../retain - this usually indicates that you are going to leak sometime in the future as you are claiming two counts of ownership on the view. This may be what you want, but it usually isn't, so thats why I point it out.
--
David Duncan
Apple DTS Animation and Printing


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please 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


References: 
 >Layer-backed NSOpenGLView not showing up (From: Albert Martin <email@hidden>)

  • Prev by Date: Re: Archiving NSError
  • Next by Date: NSArrayController bound to an array of strings
  • Previous by thread: Re: Layer-backed NSOpenGLView not showing up
  • Next by thread: Finder's sidebar background color
  • Index(es):
    • Date
    • Thread