• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
RE: QCComposition in CAOpenGLLayer
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: QCComposition in CAOpenGLLayer


  • Subject: RE: QCComposition in CAOpenGLLayer
  • From: Anshul jain <email@hidden>
  • Date: Fri, 30 Jan 2009 14:33:51 +0530

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 (email@hidden)

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: QCComposition in CAOpenGLLayer
      • From: David Duncan <email@hidden>
  • Prev by Date: Disabling sorting in a programatically generated table
  • Next by Date: Finding Thai Words
  • Previous by thread: Re: Disabling sorting in a programatically generated table [SOLVED]
  • Next by thread: Re: QCComposition in CAOpenGLLayer
  • Index(es):
    • Date
    • Thread