Graphics Reference
In-Depth Information
LISTING 8-7
Continued
usingContentFrame :
NSRectToCGRect ([[ window contentView ] bounds ])];
[[ window contentView ] setWantsLayer : YES ];
[[[ window contentView ] layer ] addSublayer : gridLayer ];
[ gridLayer playMovies ];
}
When OpenGLVidGridLayer is allocated,
we pass it the array of movie file paths
and the content frame in which each
movie will render.
NOTE
Most of the paths specified point to movies
that are on your system, assuming you have
installed the Xcode Tools. The one called
stirfry.mp4 is located in the main bundle of
the example project.
When the root layer of the window's
content view is made layer-backed
using [[window contentView]
setWantsLayer:YES] , add the
OpenGLVidGridLayer to the root layer as a sublayer, and then call -playMovies , which
simply calls [videoController togglePlaybackAll] . This function iterates through each
of the VideoChannel objects inside the VideoChannelController and instructs them to
start playing back each movie in their designated container.
Listing 8-8 shows how we have overridden the calls to -canDrawInCGLContext and
-drawInCGLContext in the OpenGLVideGridLayer .
LISTING 8-8
Implementation of Drawing Functions
- ( BOOL )canDrawInCGLContext:( CGLContextObj )glContext
pixelFormat:( CGLPixelFormatObj )pixelFormat
forLayerTime:( CFTimeInterval )timeInterval
displayTime:( const CVTimeStamp *)timeStamp
{
if ( ![ videoController isPlaying ] )
return NO ;
[ videoController setVisualContext :glContext
withPixelFormat :pixelFormat];
BOOL ready = [ videoController
channelsReadyToDraw :( CVTimeStamp *)timeStamp];
return ready;
}
 
Search WWH ::




Custom Search