Graphics Reference
In-Depth Information
LISTING 8-4
Continued
pixelFormat,
(
CFDictionaryRef
)attributes,
&qtVisualContext);
// Associate it with the movie
SetMovieVisualContext([movie
quickTimeMovie
],qtVisualContext);
}
Inside this call to
-setupVisualContext
, the movie is associated with the OpenGL context
of the
CAOpenGLLayer
. That way, when
-drawInCGLContext
gets called, we will have every-
thing set up to make the OpenGL calls, as shown in Listing 8-5.
LISTING 8-5
Implementation of drawInCGLContext
- (
void
)drawInCGLContext:(
CGLContextObj
)glContext
pixelFormat:(
CGLPixelFormatObj
)pixelFormat
forLayerTime:(
CFTimeInterval
)interval
displayTime:(
const
CVTimeStamp
*)timeStamp
{
NSRect bounds =
NSRectFromCGRect
([
self
bounds
]);
GLfloat minX, minY, maxX, maxY;
minX =
NSMinX
(bounds);
minY =
NSMinY
(bounds);
maxX =
NSMaxX
(bounds);
maxY =
NSMaxY
(bounds);
glMatrixMode(
GL_MODELVIEW
);
glLoadIdentity();
glMatrixMode(
GL_PROJECTION
);
glLoadIdentity();
glOrtho( minX, maxX, minY, maxY, -1.0, 1.0);
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(
GL_COLOR_BUFFER_BIT
);
CGRect imageRect = [
self
frame
];
// Enable target for the current frame
glEnable(
CVOpenGLTextureGetTarget
(currentFrame));