PDA

View Full Version : Units in OpenGL



AhmedSabry
02-06-2008, 09:00 AM
Hello All
I am a beginner in OpenGL and I am using OpenGL with MFC, and I am doing now 2D graphics,
I used the function
gluOrtho2D(-10.0f, 10.0f, -10.0f, 10.0f);
and I am wondering what is the units that used in OpenGL, in my code it is not pixels sure, I think it may be centimeters, but I am not sure, how can I modify this to use pixels, and I feel that, I think I donít understand gluOrtho2D too much!

weyrauch
02-06-2008, 09:48 AM
The short answer is OpenGL does not have units. The choice of units is up to your application.

See the OpenGL FAQ at http://www.opengl.org/resources/faq/technical/transformations.htm
for how to setup OpenGL to do 2D rendering in screen space.

This will get you close...

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0, windowWidth, 0, windowHeight);

-rick