Jump to content
  • Advertisement
Sign in to follow this  
silothesuper

making quad of exact size?

This topic is 4353 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

Lets say I have a 32x32 pixel bitmap, how can I create a quad thats 32x32 pixels in size so that I can apply the 32x32 bitmap to perfectly. Can I do this? Thanks, Silo the Super

Share this post


Link to post
Share on other sites
Advertisement
Well if you are working in 2D then this is easy because you specify the vertices in screen coordinates. This is practically impossible in 3D because the 'size' of the quad is determined by where the camera is.

Hope that helps,

Dave

Share this post


Link to post
Share on other sites
Oh lol, I see now :D. So when I set up a viewport for 2D, I would go like um:
gluOrtho2D(0, 800, 600, 0);
I was going putting something silly like
gluOrtho2D(-10, 10, -7.5, 7.5);

Thanks :D

Share this post


Link to post
Share on other sites
You want to do:


glViewport(0, 0, imageWidth, imageHeight);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0f, imageWidth, 0.0f, imageHeight);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f); glVertex2i(0, 0);
glTexCoord2f(1.0f, 0.0f); glVertex2i(imageWidth, 0);
glTexCoord2f(1.0f, 1.0f); glVertex2i(imageWidth, imageHeight);
glTexCoord2f(0.0f, 1.0f); glVertex2i(0, imageHeight);
glEnd();



with your texture already set up. Make sure you use GL_NEAREST as your filter mode if you want to get pixel perfect (GL_LINEAR can blur your image very slightly).

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!