Jump to content

  • Log In with Google      Sign In   
  • Create Account


glViewport() and more


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 diddly-yo   Members   -  Reputation: 122

Like
Likes
Like

Posted 30 May 2002 - 12:44 PM

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

Sponsor:

#2 GKW   Members   -  Reputation: 200

Like
Likes
Like

Posted 31 May 2002 - 04:40 AM

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

#3 diddly-yo   Members   -  Reputation: 122

Like
Likes
Like

Posted 31 May 2002 - 05:59 AM

Thank you very much!

diddly

#4 camcbri   Members   -  Reputation: 122

Like
Likes
Like

Posted 31 May 2002 - 08:13 PM

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!

#5 GKW   Members   -  Reputation: 200

Like
Likes
Like

Posted 01 June 2002 - 03:34 AM

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




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS