Graphics Reference
In-Depth Information
LISTING 8-3
Continued
// Returns the texture coordinates for the
// part of the image that should be displayed
CVOpenGLTextureGetCleanTexCoords
(
currentFrame
,
lowerLeft
,
lowerRight
,
upperRight
,
upperLeft
);
return YES
;
}
return NO
;
}
Before you can draw anything on an OpenGL context, you must first set up the
visual context for the QuickTime movie. The call to
-setupVisualContext
is shown in
Listing 8-4.
LISTING 8-4
Implementation of QuickTime Visual Context
- (
void
)setupVisualContext:(
CGLContextObj
)glContext
withPixelFormat:(
CGLPixelFormatObj
)pixelFormat;
{
OSStatus error;
NSDictionary *attributes =
nil
;
attributes = [
NSDictionary dictionaryWithObjectsAndKeys
:
[
NSDictionary dictionaryWithObjectsAndKeys
:
[
NSNumber numberWithFloat
:[
self
frame
].
size
.
width
],
kQTVisualContextTargetDimensions_WidthKey
,
[
NSNumber numberWithFloat
:[
self
frame
].
size
.height],
kQTVisualContextTargetDimensions_HeightKey
,
nil
],
kQTVisualContextTargetDimensionsKey
,
[
NSDictionary dictionaryWithObjectsAndKeys
:
[
NSNumber numberWithFloat
:[
self
frame
].
size
.
width
],
kCVPixelBufferWidthKey
,
[
NSNumber numberWithFloat
:[
self
frame
].
size
.height],
kCVPixelBufferHeightKey
,
nil
],
kQTVisualContextPixelBufferAttributesKey
,
nil
];
// Create the QuickTime visual context
error =
QTOpenGLTextureContextCreate
(
NULL
,
glContext,