Jump to content

View more

Image of the Day

#ld38 #screenshotsaturday Mimosa Fizz action gif #2 https://t.co/TUzdppvfUL
IOTD | Top Screenshots

The latest, straight to your Inbox.

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


Sign up now

glViewport math

4: Adsense

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
2 replies to this topic

#1 Null and Void   Members   

1087
Like
Likes
Like

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

#2 mittens   Members   

1323
Like
Likes
Like

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

#3 Anonymous Poster_Anonymous Poster_*   Guests   

Likes

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.