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

## 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 on other sites
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 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 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).

1. 1
2. 2
3. 3
Rutin
16
4. 4
5. 5

• 10
• 14
• 30
• 13
• 11
• ### Forum Statistics

• Total Topics
631788
• Total Posts
3002356
×