Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

diddly-yo

glViewport() and more

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

What exactly (ok, not exactly, just generally) does the glViewport() command do? I have tried playing around with it, but I can''t seem to understand what it does. I read the documentation on msdn, but I am unclear on a few (read: many) things. When it refers to "affine coordinates" and "normalized device coordinates," what is it talking about? Thanks, diddly

Share this post


Link to post
Share on other sites
Advertisement
Basically you are just restricting opengl to change pixels in the rectangle defined in the glViewport call. For example if you want the top half of the screen to be a front view of something and the bottom half to be the rear view you could implement it as two separate rendering contexts or you can use one context but split the screen with two calls to glViewport.

// using a 800X600 pixel rendering context
// draw on top part of screen
glViewport(0,0,800,300);
drawFrontView();
// draw on bottom part of screen
glViewport(0,300,800,300);
drawRearView();


The fanatic is incorruptible: if he kills for an idea, he can just as well get himself killed for one; in either case, tyrant or martyr, he is a monster.
--EM Cioran

Opere Citato

Share this post


Link to post
Share on other sites
another question on this topic...

if I want to create a rear view mirror, do i use glViewport like this?

glViewport( full screen coords)

draw( all stuff thats full screen)

glViewport( coords of rear-view)

draw(rear view mirror reflection)

Thanks!

Share this post


Link to post
Share on other sites
Perhaps I was a little vague in my description. glViewport is kind of like setting up a new context to render into. In other words you will fit the entire scene that would have normally appeared in fullscree/window into the new viewport. If you make your viewport tall and skinny all your wolrd objects will also be tall and skinny because that is how the coordinates will be mapped onto the screen. So you could use it to do a rearview mirror but you would have to make sure your perspective/frustrum is correct or your objects will appear small. I think glScissor is usually used for rearview mirrors. That way you don''t have to monkey with the correct scaling, you just change the direction of your frustum to face aft and only let it draw inside the scissor fence.

The fanatic is incorruptible: if he kills for an idea, he can just as well get himself killed for one; in either case, tyrant or martyr, he is a monster.
--EM Cioran

Opere Citato

Share this post


Link to post
Share on other sites

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