Jump to content
  • Advertisement
Sign in to follow this  

Pretransformed Vertices

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


I want to draw HUD elements with pretransformed vertices (in Direct3D9 with Shaders) and have some questions about them:

1) Right now I think all I have to do is specifying the 2D vertices as 4D vectors in the range [-1,-1] to [1,1] and set the modelViewProjection Matrix to identity. So for example top left would be (-1, 1, 0, 1) and bottom right would be (1,-1, 0, 1). Is this right?

2) What if I wanted to define my pretransformed vertices in the range (0,0) to (1,1) (like texture coordinates), where (0,0) is top left and (1,1) bottom right? The problem is the viewport matrix, which would lead to wrong results. I found this page about the viewport matrix: http://msdn.microsoft.com/en-us/library/aa915188.aspx.
Lets just look at the x-axis: The pretransformed vertices are scaled by width/2 and then translated by (dwX + width/2). I would set dwX to zero, but the result would be wrong. For example the x-coordinate of the top left point would be 0 and after the multiplication with the viewport matrix it would be width/2 ( 0*width/2 + width/2 ), which is wrong. To put a long story short: If I wanted to define the vertices in the (0,0) to (1,1) range, I would need to skip the translation part of the viewport matrix, am I am right? Is there a way to do this?

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!