I'll find a reference when I get a chance, but I recall reading somewhere that what you're trying to do won't work. You will need to use CAOpenGLLayer if you want to add sub-layers to it.

Just to test it, don't add the sub-layer and see if it shows up then. If it doesn't then you may have other issues in your init code. You might try hooking up an NSOpenGLView in Interface Builder instead. I am pretty sure, though that you'll need a CAOpenGLLayer.

Here is a blog post I wrote that shows how to display a QuickTime movie using a CAOpenGLLayer: http://www.cimgf.com/2008/09/10/core-animation-tutorial-rendering-quicktime-movies-in-a-caopengllayer/

HTH,

-Matt



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

Hello,

I am trying to programmatically create an NSOpenGLView and have it layer-backed. I would use CAOpenGLLayer except that I am using a subclass of NSOpenGLView and I don't have the time to rewrite it. Now, for some reason I can not get the NSOpenGLView to show up. If I use the same subclassed NSOpenGLView in Interface Builder everything shows up fine and I can communicate with it how I need to, but if I create it programmatically it simply never shows up.

The weird thing is that I think it is getting created correctly but is just not becoming visible. The NSOpenGLView plays a QTMovie and even though it doesn't show up I can still hear the audio from the QTMovie playing back. Also, I've added a bunch of NSLog's in the subclass and they all get triggered when I try to communicate with the version that was created programmatically even though it never shows up.

Here's my code ... what am I doing wrong?

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];
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to