Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CAOpenGLLayer



Hi,

On Mar 29, 2008, at 9:01 AM, Stefan Hafeneger wrote:
I would like to use CAOpenGLLayer instead of NSOpenGLView. I didn't find any example source code but got it working. I implemented

The API documentation says that the viewport is already set to bounds size before drawInCGLContext:... is called and that I should disable all OpenGL settings that I enabled before. I don't understand why.

I don't either, there's no reason for you to undo any changes to the context you made before returning from your draw method. With the default implementation of the -copyCGLContextForPixelFormat: method you are guaranteed to have exclusive access to the OpenGL context until it's destroyed.



I would like to setup my OpenGL context once (as with NSOpenGLView) and set the perspective only if the bounds change. I tried to set the perspective (gluPerspective) in copyCGLContextForPixelFormat:... but this didn't work (I set the currect context to the new OpenGL context and also locked the context).

Assuming you didn't override -copyCGLContextForPixelFormat: (e.g. to share a single context between multiple layers) that should work, but only until the window hosting the layer moves to a different display. When that happens the layer's display mask may change and the layer will release the original context and create a new one. You can detect this by overriding either the -releaseCGLContext: or - releaseCGLPixelFormat: method and recording that you need to reload all your OpenGL state next time you draw.


btw, it's not necessary for you to set the current context and lock it, CAOpenGLLayer will make sure the context passed to the draw method is current and locked.

	John


_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >CAOpenGLLayer (From: Stefan Hafeneger <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.