Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
gluOrtho2D vs glOrtho
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gluOrtho2D vs glOrtho



I just noticed that calls to gluOrtho2D seem to get ignored in a
NSOpenGLView subclass' drawRect method, while calls to glOrtho behave as
expected. In the overall context, I'm using core video to play a quicktime
movie into an opengl view. The context setup and project structure was
taken from the example code in CIVideoDemoGL. Does this behavior have
something to do with core video?

this is the whole drawRect function:

- (void)drawRect:(NSRect)rect
{
	[lock lock];

	NSRect rectView = [self bounds];
	int W = rectView.size.width;
	int H = rectView.size.height;

	[[self openGLContext] makeCurrentContext];

	glViewport( 0,0,W,H );
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
 	// doesn't update the projection matrix
	// gluOrtho2D(0, W, 0, H)
	// works fine
	glOrtho(0, W, 0, H, -1, 1);

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	glClearColor(0,0,0,0);
	glClear(GL_COLOR_BUFFER_BIT);

	GLenum target = CVOpenGLTextureGetTarget(currentFrame);
	GLint name = CVOpenGLTextureGetName(currentFrame);

	glEnable(target);
	glBindTexture(target, name);

	glBegin(GL_QUADS);
	glTexCoord2f(upperLeft[0], upperLeft[1]);		glVertex2f(0,H);
	glTexCoord2f(upperRight[0], upperRight[1]);		glVertex2f(W,H);
	glTexCoord2f(lowerRight[0], lowerRight[1]);		glVertex2f(W,0);
	glTexCoord2f(lowerLeft[0], lowerLeft[1]);		glVertex2f(0,0);
	glEnd();

	glDisable(target);

	[[self openGLContext] flushBuffer];
	[self setNeedsDisplay:YES];
	[lock unlock];
}

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Mac-opengl mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.