I'm looking at using CAOpenGLLayer to boost drawing performance. I'm a total
novice at OpenGL.
Looking at the 'CALayerEssentials' sample code as a starting point, it has the
following code:
-(void)drawInCGLContext:(CGLContextObj)glContext
pixelFormat:(CGLPixelFormatObj)pixelFormat
forLayerTime:(CFTimeInterval)timeInterval displayTime:(const CVTimeStamp
*)timeStamp
{
// Set the current context to the one given to us.
CGLSetCurrentContext(glContext);
// We're just going to draw a single red quad spinning around based on
the current time. Nothing particularly fancy.
GLfloat rotate = timeInterval * 60.0; // 60 degrees per second!
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glRotatef(rotate, 0.0, 0.0, 1.0);
glBegin(GL_QUADS);
glColor3f(1.0, 0.0, 0.0);
glVertex2f(-0.5, -0.5);
glVertex2f(-0.5, 0.5);
glVertex2f( 0.5, 0.5);
glVertex2f( 0.5, -0.5);
glEnd();
glPopMatrix();
// Call super to finalize the drawing. By default all it does is call
glFlush().
[super drawInCGLContext:glContext pixelFormat:pixelFormat
forLayerTime:timeInterval displayTime:timeStamp];
}
What I find a bit odd here is that the coordinate values for the glVertex calls
are not related to the layer's actual bounds, but to some notional coordinate
system stretching from -1 to +1 in each dimension. If the layer is resized, the
'square' resulting stretches in proportion.
I didn't expect this, though perhaps it's normal for OpenGL, or at least
CAOpenGLLayer. There's virtually nothing in the documentation about this layer
or how it's set up, so I'm having a hard time understanding how I'm supposed to
go about calculating the coordinates I need.
Can someone point me in the direction of any documentation that could help
here, or at least confirm my observations about coordinates being relative to a
+/- 1 virtual space?
--Graham
_______________________________________________
Cocoa-dev mailing list ([email protected])
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]