• 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: CAOpenGLLayer
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CAOpenGLLayer


  • Subject: Re: CAOpenGLLayer
  • From: John Harper <email@hidden>
  • Date: Sun, 30 Mar 2008 20:27:17 -0700

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:
This email sent to email@hidden


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

  • Prev by Date: unpacking binary data
  • Next by Date: Re: unpacking binary data
  • Previous by thread: CAOpenGLLayer
  • Next by thread: Cocoa Tutoring in SF Bay Area
  • Index(es):
    • Date
    • Thread