🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Drawing to pixel scale?

Started by
1 comment, last by GameDev.net 18 years, 1 month ago
I want to be able to draw shapes to pixel scale. That is to say, when I write: glVertex3f(-16.0f, -16.0f, 0.0f); I want that point to be exactly 16 pixels down ont he x and y axi. Thre more of these would draw a 32x32 square. I came across the gluOrtho2D(0, 1024, 0, 768); function, but I'm not really sure how to use it, or where in my code to place it. Any and all help is welcomed. Thanks in advance for any aid you provide ^^ Meow.
Advertisement
That function modifies the PROJECTION matrix. Place it before the viewing transformation and before you draw any objects.

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0, 1024, 0, 768);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
//apply viewing transformation
//draw objects
deathkrushPS3/Xbox360 Graphics Programmer, Mass Media.Completed Projects: Stuntman Ignition (PS3), Saints Row 2 (PS3), Darksiders(PS3, 360)
Make sure that the width and height are your actual program dimensions, not just 1024 and 768.

This topic is closed to new replies.

Advertisement