Skip navigation.
 
mlCAOpenGLLayer
FROM : Stefan Hafeneger
DATE : Sat Mar 29 17:01:20 2008

Hi,

I would like to use CAOpenGLLayer instead of NSOpenGLView. I didn't 
find any example source code but got it working. I implemented

- (BOOL)canDrawInCGLContext:(CGLContextObj)glContext pixelFormat:
(CGLPixelFormatObj)pixelFormat
- (void)drawInCGLContext:(CGLContextObj)glContext pixelFormat:
(CGLPixelFormatObj)pixelFormat forLayerTime:
(CFTimeInterval)timeInterval displayTime:(const CVTimeStamp *)timeStamp
- (CGLPixelFormatObj)copyCGLPixelFormatForDisplayMask:(uint32_t)mask
- (void)releaseCGLPixelFormat:(CGLPixelFormatObj)pixelFormat

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 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).

So, is there a way to setup the context once and update the camera 
only when needed or do I have to setup the environment in every 
drawInCGLContext:... call?

With best wishes, Stefan Hafeneger

Related mailsAuthorDate
mlCAOpenGLLayer Stefan Hafeneger Mar 29, 17:01
mlRe: CAOpenGLLayer John Harper Mar 31, 05:27
mlRe: CAOpenGLLayer Stefan Hafeneger Apr 2, 21:23
mlRe: CAOpenGLLayer John Harper Apr 2, 22:19
mlRe: CAOpenGLLayer Stefan Hafeneger Apr 2, 22:26