Graphics Reference
In-Depth Information
LISTING 8-8
Continued
- ( void )drawInCGLContext:( CGLContextObj )glContext
pixelFormat:( CGLPixelFormatObj )pixelFormat
forLayerTime:( CFTimeInterval )interval
displayTime:( const CVTimeStamp *)timeStamp
{
NSRect
bounds = NSRectFromCGRect ([ self bounds ]);
[ videoController drawAllInRect : bounds ];
// This forces OpenGL to flush the context
[ super drawInCGLContext :glContext
pixelFormat :pixelFormat
forLayerTime :interval
displayTime :timeStamp];
[ videoController taskAll ];
}
These functions are fairly simple because we have offloaded the majority of the work to
the VideoChannelController object. The VideoChannelController then instructs all the
VideoChannel objects to do their work, and the call to -canDrawInCGLContext checks to
see if the movies are running. If not, we don't need to render, and NO is returned. In that
case, -drawInCGLContext won't be called either. When the movies are running, however,
the visual context for rendering the QuickTime videos are set up before checking to see if
the current image buffer for each of the VideoChannels is ready to draw into using a call
to -channelsReadyToDraw in the VideoChannelController object. You can see how it is
implemented Listing 8-9.
LISTING 8-9
Implementing channelsReadyToDraw Function
- ( BOOL )channelsReadyToDraw:( CVTimeStamp *)timeStamp;
{
BOOL stillOk = NO ;
int i = 0;
for (i=0; i<[ videoChannels count ]; ++i)
{
VideoChannel *currentChannel =
[ videoChannels objectAtIndex :i];
if ( [currentChannel readyToDrawNextFrame :timeStamp] )
{
 
Search WWH ::




Custom Search