On Wed, Oct 7, 2009 at 9:55 AM, Beth S
<email@hidden> wrote:
Hi there,
I've almost got this thing licked, but there's one last piece of the puzzle that I'm missing. I'm trying to play back QT video spanned across two displays using shared opengl contexts. These displays are on the same graphics card (otherwise my understanding is that shared OpenGL contexts on different GPUs can't share textures).
My question is, if they are shared contexts and they share the PBO, how does the slave context know when there is a new frame available from the master?
The display link callback code from QTCoreVideo202 is below. It's unclear to me how to make it work in the case of a shared PBO across two NSOpenGLViews. Presumably only the master NSOpenGLView would need to load new frames, but how does the slave NSOpenGLView check for the master's new frame? How does the slave NSOpenGLView reference the master's frame object?
- (CVReturn) getFrameForTime:(const CVTimeStamp *)timeStamp
flagsOut:(CVOptionFlags *)flagsOut
{
// There is no autorelease pool when this method is called because it will
// be called from another thread it's important to create one or you will
// leak objects
NSAutoreleasePool *pool = [NSAutoreleasePool new];
// Check for new frame
if ( ( [visualContext isValidVisualContext] )
&& ( [visualContext isNewImageAvailable:timeStamp] ) )
{
// If we have a previous frame release it
[self deleteCVPixelBuffer];
// Get a "frame" (image image) from the Visual Context, indexed by
// the provided time
attributes->coreVideo.videoFrame = [visualContext copyImageForTime:timeStamp];
// The above call may produce a null frame so check for this first
// if we have a frame, then draw it
if ( attributes->coreVideo.videoFrame != NULL )
{
[self drawRect:NSZeroRect];
} // if
else
{
NSLog( @"WARNING: QT Visual Context Copy Image for Time Error!" );
} // else
} // if
[pool release];
return kCVReturnSuccess;
} // getFrameForTime
Thanks!
Beth.