Re: QCComposition in CAOpenGLLayer

2009-01-30 Thread David Duncan

On Jan 30, 2009, at 1:03 AM, Anshul jain wrote:


i am trying to play  QCComposition in CAOpenGLLayer



Why not use the QCCompositionLayer?
--
David Duncan
Apple DTS Animation and Printing

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


RE: QCComposition in CAOpenGLLayer

2009-01-30 Thread Anshul jain

i am trying to play  QCComposition in CAOpenGLLayer

Sorry for the earlier post  here is the snippet of the code

According to the documentation of QCrenderer this should work fine.

but at final output nothing is displayed. Can anyone tell me where i  
am going wrong.


- (id) init
{
self = [super init];
if (self != nil) {
[self setAsynchronous:YES];
}
return self;
}

- (CGLPixelFormatObj)copyCGLPixelFormatForDisplayMask:(uint32_t)mask
{
CGLPixelFormatAttribute attributes[] = {
kCGLPFADisplayMask, mask,
kCGLPFAAccelerated,
kCGLPFAColorSize, 2,
kCGLPFAAlphaSize, 8,
kCGLPFADepthSize, 16,
kCGLPFANoRecovery,
kCGLPFAMultisample,
kCGLPFASupersample,
kCGLPFASampleAlpha,
0
};
CGLPixelFormatObj pixelFormatObj = NULL;
GLint numPixelFormats = 0;
CGLChoosePixelFormat(attributes, &pixelFormatObj, &numPixelFormats);
if (pixelFormatObj == NULL)
NSLog(@"Error: Could not choose pixel format!");
return pixelFormatObj;
}

- (void)releaseCGLPixelFormat:(CGLPixelFormatObj)pixelFormat
{
CGLDestroyPixelFormat(pixelFormat);
}

- (CGLContextObj)copyCGLContextForPixelFormat: 
(CGLPixelFormatObj)pixelFormat

{
	CGLContextObj object =  [super  
copyCGLContextForPixelFormat:pixelFormat];
	NSString *path = [[NSBundle mainBundle] pathForResource:@"Blob"  
ofType:@"qtz"];

QCComposition *aComposition = [QCComposition compositionWithFile:path];
	CGColorSpaceRef colorRef =   
CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
	qcRenderer = [[QCRenderer alloc] initWithCGLContext:object  
pixelFormat:pixelFormat colorSpace:colorRef composition:aComposition];

return object;
}

- (BOOL)canDrawInCGLContext:(CGLContextObj)glContext pixelFormat: 
(CGLPixelFormatObj)pixelFormat forLayerTime: 
(CFTimeInterval)timeInterval displayTime:(const CVTimeStamp *)timeStamp

{
BOOL success = [self renderAtTime:timeStamp];
if (texture)
CVOpenGLBufferRelease(texture);
texture = [qcRenderer createSnapshotImageOfType:@"CVOpenGLBuffer"];
if (texture)
return YES;
else return NO;
return success;
}

- (BOOL) renderAtTime:(const CVTimeStamp*)time
{

NSTimeInterval  videoTime;
if (time) {
		videoTime = (NSTimeInterval)time->videoTime / (NSTimeInterval)time- 
>videoTimeScale;
		NSLog(@"%f  %f  %f",videoTime,time->videoTime,time- 
>videoRefreshPeriod);

return [qcRenderer renderAtTime:videoTime arguments:nil];
}
else
NO;
}

- (void)drawInCGLContext:(CGLContextObj)glContext pixelFormat: 
(CGLPixelFormatObj)pixelFormat forLayerTime: 
(CFTimeInterval)timeInterval displayTime:(const CVTimeStamp *)timeStamp

{
glClearColor(0, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glEnable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
if (CFGetTypeID(texture) == CVOpenGLTextureGetTypeID()) {
GLenum target = CVOpenGLTextureGetTarget(texture);
GLint name = CVOpenGLTextureGetName(texture);
GLfloat topLeft[2], topRight[2], bottomRight[2], bottomLeft[2];
		CVOpenGLTextureGetCleanTexCoords(texture, bottomLeft, bottomRight,  
topRight, topLeft);

glPushMatrix();
glColor4f(1.0f, 1.0f, 1.0f, 1.0);
glEnable(target);
glBindTexture(target, name);
glBegin(GL_QUADS);
glTexCoord2fv(bottomLeft);  glVertex2i(-1, -1);
glTexCoord2fv(topLeft); glVertex2i(-1,  1);
glTexCoord2fv(topRight);glVertex2i( 1,  1);
glTexCoord2fv(bottomRight); glVertex2i( 1, -1);
glEnd();
glDisable(target);
glPopMatrix();
}
glDisable(GL_BLEND);
glDisable(GL_DEPTH_TEST);
	[super drawInCGLContext:glContext pixelFormat:pixelFormat  
forLayerTime:timeInterval displayTime:timeStamp];

}







___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com