Sign in to follow this  
silothesuper

making quad of exact size?

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

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