PDA

View Full Version : glVertex scale runs from -1 to 1



MightyEsquilax
04-12-2006, 06:21 AM
Ok, I've got a dumb question which probably means I don't understand OpenGL that well. When I use the 2D glVertex function I always have to put coordinates in that run from -1 to 1.

For the X-axis -1 is the left most part of the display and 1 is the right most part.

For Y it is what you would expect, -1 for the lowest, and 1 for the highest. How can I change the scaling so that I can use larger values, like 0 to 255 or some other scale?

Thanks!

RigidBody
04-12-2006, 07:07 AM
change the projection matrix:


glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 255.0, 0.0, 255.0, -1.0, 1.0);

MightyEsquilax
04-12-2006, 08:53 AM
Got it thanks very much!