# dx10 drawing coordinates to screen coordinates

This topic is 3658 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

what is the equation for converting a point in my imaginary created dx10 world into screen coordinates? im mostly only interested in the y component and from whats in the stock vertex shaders its something like : output.Pos = mul( input.Pos, World ); output.Pos = mul( output.Pos, View ); output.Pos = mul( output.Pos, Projection ); but i want the coordinates in my nonshader code so i mocked it up like float temp = ImageTop; temp = temp * g_World.M22; temp = temp * g_View.M22; temp = temp * g_Projection.M22; MessageBox.Show(PointToScreen(new Point(0, (int)temp)).Y.ToString()); but its not accounting for the movement from the "eye" or the "at" in View so im assuming its way wrong as most of those values show up in the .M4x regions of the view and projection.

##### Share on other sites
I used the following code (in c#) for converting a point in 3d space to screen coordinates.

Vector2 WorldSpaceToScreenSpace(Vector3 worldSpacePos){    Vector4 clipSpacePos = Vector4.Transform(new Vector4(worldSpacePos, 1.0f), viewProjMatrix);    Vector2 screenSpacePos;    screenSpacePos.x = (clipSpacePos.x / clipSpacePos.w) * 0.5f + 0.5f;    screenSpacePos.y = 1.0f - ((clipSpacePos.y / clipSpacePos.w) * 0.5f + 0.5f);    screenSpacePos.x *= viewPortWidth;    screenSpacePos.y *= viewPortHeight;    return screenSpacePos;}

Hope it helps

##### Share on other sites
The code posted by FoDDa looks right. In case you want to do some further research and need some terms you can search for, these are the required steps:
Multiply your object space vector with the WorldViewProj Matrix
Perform homogeneous division
Apply Viewport Mapping

##### Share on other sites
Just call D3DXVec3Project (unless you have a general interest in implementing it yourself).

1. 1
Rutin
70
2. 2
3. 3
4. 4
5. 5

• 21
• 10
• 33
• 20
• 9
• ### Forum Statistics

• Total Topics
633430
• Total Posts
3011825
• ### Who's Online (See full list)

There are no registered users currently online

×