Graphics Reference
In-Depth Information
LISTING 8-6
Continued
}
if
(
videoController
!=
nil
)
{
[
videoController release
];
}
videoController
= [[
VideoChannelController alloc
]
init
];
[
videoController setVideoChannels
:
videoChannels
];
}
Previously in this chapter, we looked at how to render a single video clip in an OpenGL
context. We have taken that code and placed it into classes that encapsulate that func-
tionality. The
VideoChannelController
class holds the
VideoChannel
objects so that they
can be controlled. It passes the OpenGL context to each
VideoChannel
object and tells
them to draw their content (the movies) to that context.
In the
AppDelegate
for this project, we instantiate a
CAOpenGLLayer
-derived layer called
OpenGLVidGridLayer
and pass it an array of
NSString
s containing movie paths, as shown
in Listing 8-7.
LISTING 8-7
Initializing the OpenGLVidGridLayer in the AppDelegate
-(
void
)awakeFromNib;
{
NSString
*path1 =
@”/System/Library/Compositions/Eiffel Tower.mov”
;
NSString
*path2 =
@”/System/Library/Compositions/Fish.mov”
;
NSString
*path3 = [[
NSBundle mainBundle
]
pathForResource
:
@”stirfry”
ofType
:
@”mp4”
];
NSString
*path4 =
@”/System/Library/Compositions/Rollercoaster.mov”
;
NSString
*path5 =
@”/System/Library/Compositions/Sunset.mov”
;
NSString
*path6 =
@”/System/Library/Compositions/Yosemite.mov”
;
NSArray
*paths = [
NSArray arrayWithObjects
:path1,
path2,
path3,
path4,
path5,
path6,
nil
];
gridLayer
= [[
OpenGLVidGridLayer alloc
]
initWithVideoPaths
:paths