Jump to content
  • Advertisement
Sign in to follow this  
simonloach

Projecting 3D coordinates to 2D for text drawing

This topic is 4115 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'm trying to draw text on screen using ID3DXFont but this only takes 2D coordinates. So far I've got:
	D3DXMATRIX n = viewmatrix * projectionmatrix;

	D3DXMATRIX textposition3d;
	D3DXMatrixIdentity(&textposition3d);
	D3DXMatrixTranslation(&textposition3d, 6.0f, 0.0f, 0.0f);

	D3DXMATRIX textposition2d = textposition3d * n;

	r->rendertext(L"text on screen", <x coordinate>, <y coordinate>);
I'm not sure whether this is the correct way to go about it and I also have no idea how to extract the coordinates from the textposition2d matrix. Any help would be appreciated :)

Share this post


Link to post
Share on other sites
Advertisement
You can use the handy D3DXVec3Project() function to project a vector from object space to screen space.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!