• Advertisement
Sign in to follow this  

Drawing to pixel scale?

This topic is 4291 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Make sure that the width and height are your actual program dimensions, not just 1024 and 768.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement