Graphics Reference
In-Depth Information
In a CAOpenGLLayer , however, setting up and using a display link callback is com-
pletely unnecessary as this is provided for you in both -canDrawInCGLContext and
-drawInCGLContext . The time you use to check to see if a new frame is ready is provided
in the parameter called displayTime .
So, to render a movie into the CAOpenGLLayer , in the -canDrawInCGLContext :
1. Check to see if the movie is playing back; if not, return NO .
2. If the movie is playing back, check to see if the context for the movie has been set
up yet. If not, set it up with a call to -setupVisualContext .
3. Check to see if a new frame is ready.
4. If so, copy the current image into the image buffer.
5. If everything is successful, return YES .
6. If -canDrawInCGLContext returned YES , -drawInCGLContext gets called. Inside of that
method, draw the OpenGL quads for the movie's current texture images.
The implementation of -canDrawInCGLContext is in Listing 8-3.
LISTING 8-3
Implementation of Delegate -canDrawInCGLContext
- ( BOOL )canDrawInCGLContext:( CGLContextObj )glContext
pixelFormat:( CGLPixelFormatObj )pixelFormat
forLayerTime:( CFTimeInterval )timeInterval
displayTime:( const CVTimeStamp *)timeStamp
{
if ( ! qtVisualContext )
{
// If the visual context for the QTMovie has not been set up
// we initialize it now
[ self setupVisualContext :glContext withPixelFormat :pixelFormat];
}
// Check to see if a new frame (image) is ready to be drawn at
// the current time by passing NULL as the second param
if ( QTVisualContextIsNewImageAvailable ( qtVisualContext , NULL ))
{
// Release the previous frame
CVOpenGLTextureRelease ( currentFrame );
// Copy the current frame into the image buffer
QTVisualContextCopyImageForTime ( qtVisualContext ,
NULL ,
NULL ,
& currentFrame );
Search WWH ::




Custom Search