Sign in to follow this  
KuroKitten

Drawing to pixel scale?

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this