Viewport, Ortho result is twice desired size

Started by
1 comment, last by pprice001 20 years, 3 months ago
Dear all, I am a little puzzled by viewports and the Ortho projection matrix at the moment. Using the following code, I am defining viewport that is the top right quater of a window, and as an experiment defining the viewport to have 2 units for X & Y What puzzles me is that when I draw the square (in the code) it is the entire viewport size, not 1 quater of the viewport size!! Have I missed something here??? Thanks guys Paul.

glViewport(m_uWidth / 2, m_uHeight / 2, m_uWidth, m_uHeight);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0, 2, 0, 2);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glColor3f(1.0f, 1.0f, 1.0f);
glBegin(GL_QUADS);
	glVertex2i(0, 0);
	glVertex2i(0, 1);
	glVertex2i(1, 1);
	glVertex2i(1, 0);
	glVertex2i(0, 0);
glEnd();
Advertisement
quote:Original post by pprice001
... I am defining viewport that is the top right quater of a window...

Hint: Check some documentation on what the two last parameters of glViewport means.
What a minute, I think I might have another stupid question!!

Thanks, I obviously suffer from some kind of lazy reading problem, first word and last word of every sentence or something!

But now I understand, appreciated!

Paul.

This topic is closed to new replies.

Advertisement