# converting to 2d screen space

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

## Recommended Posts

I have a camera positioned at (0,0,-10) with positive Z-values going into the screen. I want to place a texture centered around and located at (0,0,0) that will have dimensions of 128X128 on the screen. Eventually I will want to move this 128X128 square around. Basically, Im trying to make a 2.5D game and I want the Z=0 plane to be where all the 2D action takes place. So I need a method of placing objects in this plane by only needing to specify the (x,y) screen coordinates. And in addition I want them to appear at the z=0 with their screen size dimension (128X128) intact. suggestions?

##### Share on other sites
I'm no opengl expert, but my guess would be to look into the gluOrtho2D() function.

gluOrtho2D(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top);

##### Share on other sites
Whats the equivalent of that function in DirectX?

Also, If I was to use orthographic projection on the 2D item ,placing it at (x,y,z) and then placed on top of it an item of the same size using 3D perspective projected coordinates at the same (x,y,z) world wouldnt the two items be somewhat off? It would make for some bad collision detection (visually) I think.

##### Share on other sites
You probably seek the D3DX math helper functions, they are very good. D3DXVec3Project might be what you are looking for?

##### Share on other sites
I'm not sure if this works for 2.5D, but it's worked for me in 2D: device.Transform.Projection=Matrix.OrthoOffCenterLH(0.0f,screenWidth,screenHeight,0.0f,0.0f,1.0f);

##### Share on other sites
hi,

look at these articles:
http://www.andypike.com/tutorials/directx8/011.asp

i had the same problem recently, and succeded with the help of these.

kp

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 15
• 9
• 11
• 9
• 9
• ### Forum Statistics

• Total Topics
634134
• Total Posts
3015751
×