This topic is now archived and is closed to further replies.

"Easy" 2D in Direct3D?

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

Well assuming your are using ortho projection (and a LeftHand system i.e D3DXMatrixOrthoLH) for your projection matrix then the following world transformation will aloow you to use top left of the screen as 0,0

D3DXMatrixTranslation(&World,X - (ScreenWidth/2),(ScreenHeight/2) - Y,0);

Direct3DDevice->SetTransform( D3DTS_WORLD, &World);

or you can make your ortho projection as D3DXMatrixOrthoOffCenterLH

Deadpan Studios

Share this post

Link to post
Share on other sites
Why not use transformed and lit vertices defined as follows:



D3DXVECTOR4 p; // Vertex position

D3DCOLOR color; // Vertex color

float tu, tv; // Vertex texture coordinates


As far as I''m aware, p.x and p.y in this case are the screen coordinates.

p.z is the value to write to the Z-Buffer (between 0.0f and 1.0f), will be translated by Direct 3D

and p.w is the arbitrary w coordinate.

Just set up the vertex buffer as a CUSTOMVERTEX vertices as normal, using VERTEXSHADER as the Flexible Vertex Format Flags, and then you should be able to draw this as normal. Although, I''m not sure how matrix tranformations work for T&L buffer

Share this post

Link to post
Share on other sites