Jump to content
  • Advertisement
Sign in to follow this  
leonard2012

Formula for affine transformation of RSSetViewports

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

D3D function RSSetViewports plays the same role as glViewport. They all define an affine transformation that convert normalized device coordinates to viewport (window) coordinates. A explicit formula for glViewport is given at http://msdn.microsoft.com/en-us/library/dd374202(v=VS.85).aspx. It's
x_w = (x_ndc+1)*w/2 + x0
y_w = (y_ndc+1)*h/2 + y0
However, there is no formula given to RSSetViewports. I believe the same formula can be applied to RSSetViewports. Am I right?

Share this post


Link to post
Share on other sites
Advertisement
The formula is here:


X = (X + 1) * Viewport.Width * 0.5 + Viewport.TopLeftX
Y = (1 - Y) * Viewport.Height * 0.5 + Viewport.TopLeftY
Z = Viewport.MinDepth + Z * (Viewport.MaxDepth - Viewport.MinDepth)

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!