• FEATURED

View more

View more

View more

Image of the Day Submit

IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

glViewport math

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.

2 replies to this topic

#1Null and Void  Members

Posted 20 October 2001 - 01:43 PM

I am wondering what the math behind what glViewport does to the projection matrix is. This is not crutial, I''d just really like to know . Thanks in advance. [Resist Windows XP''s Invasive Production Activation Technology!]

#2mittens  Members

Posted 20 October 2001 - 04:08 PM

I wouldn''t mind knowing the math of it either (in world coordinates), so if a vertex I''m going to pass is off-screen, then I don''t even have to make a call (very helpful for particle engines).... It''d be nice to know.

------------------------------
Trent (ShiningKnight)
E-mail me
ShiningKnight Games

#3Anonymous Poster_Anonymous Poster_*  Guests

Posted 21 October 2001 - 12:25 AM

What glViewport does is convert normalised device coordinates to window coordinates. The normalised coordinates are in the range [-1..1], and the window coordinates can be anything.

If your window is 640 pixels wide and 480 pixels high, then the conversion would be:

windowx = (normalisedx + 1) * 320
windowy = (normalisedy + 1) * 240

glViewport also defines an offset x,y, so the final formula is:

windowx = (normalisedx + 1) * (width/2) + x
windowy = (normalisedy + 1) * (height/2) + y

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.