• Advertisement
Sign in to follow this  

Formula for affine transformation of RSSetViewports

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