Graphics Reference
In-Depth Information
LISTING 8-9
Continued
stillOk =
YES
;
}
if
( !stillOk )
return NO
;
}
return
stillOk;
}
The code iterates through the list of
VideoChannel
objects and checks each to see if
they are ready to draw. If any of them fail readiness,
NO
is returned for the current call to
-canDrawInCGLContext
. Listing 8-10 shows an implementation of the call to the
VideoChannel
's
-readyToDrawNextFrame
function.
LISTING 8-10
Implementing readyToDrawNextFrame Function
- (
BOOL
)readyToDrawNextFrame:(
CVTimeStamp
*)timeStamp;
{
if
(
QTVisualContextIsNewImageAvailable
(
qtVisualContext
,
NULL
))
{
CVOpenGLTextureRelease
(
currentFrameImageBuffer
);
QTVisualContextCopyImageForTime
(
qtVisualContext
,
NULL
,
NULL
,
&
currentFrameImageBuffer
);
CVOpenGLTextureGetCleanTexCoords
(
currentFrameImageBuffer
,
lowerLeft
,
lowerRight
,
upperRight
,
upperLeft
);
return YES
;
}
return NO
;
}
If you look closely, you see that this code is similar to the code used in Listing 8-3 to
render a single video channel. This function checks to see if a new image is available for
the visual context using the specified
timeStamp
. If it is available, the previous image
buffer is released, the current image is copied to the image buffer, the texture coordinates
are reset, and
YES
is returned; otherwise
NO
is returned.