Jump to content
  • Advertisement
Sign in to follow this  
Prozak

How to Map Quad to Viewport Area

This topic is 4999 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've got a quad, composed of two triangles, how do I map it so that it fits the viewport area perfectly, even after a viewport resize?

Share this post


Link to post
Share on other sites
Advertisement
Uh, use an ortho projection and position the quad at the edges of your ortho view?

Incidentally the viewport is independant of your view - rendering gets scaled to fit the current viewport. So if it takes up all of the screen then it'll take up all of the screen regardless of how big or small the viewport is.

Share this post


Link to post
Share on other sites
e.g.


void GoOrtho(int w, int h)
{
glPushMatrix();
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0,w,0,h,0,1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}



And then set your vertices of your quad to the 4 edges of the screen. :)

Share this post


Link to post
Share on other sites
Also, not sure about PC/OpenGL (may vary with graphics card / filtering type etc, not 100% sure) but on some platforms you need to offset the positions of your quads vertices by half a pixel so that the texture filtering doesn't adversely affect your screen-mapped quad.

e.g. Rather than one corner being (0,0) and opposite being (width,height), make them (0 - 0.5, 0 - 0.5) and (width - 0.5, height - 0.5).

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!