Sign in to follow this  
red_sodium

Drawing ID3DXFont in front of the camera

Recommended Posts

Hey, Just wondering how I'd use ID3DXFont::DrawText to draw the text at a constant position on the screen, rather than in world co-ordinates. The camera will move around in 3D, but my text must remain centred on screen. Is there a way of disabling all transformations done on it by the projection matrix (i think) other than manually reversing what is done implicitly by DirectX (i think), like with ID3DXSprite you can flag it to go as D3DXSPRITE_OBJECTSPACE or not. Oh yeah, I am using my sprite interface to draw the text with, through ID3DXFont::DrawText(). Do I need a seperate sprite interface that doesn't have the D3DXSPRITE_OBJECTSPACE flag selected? Thanks for your help!

Share this post


Link to post
Share on other sites
Red,

Take a look through the SDK for the ID3DXSprite class and learn how to use it inside and out ^_^. This will make your life so much easier than trying to do it through transformations. Another option would be to set your world space transforms (such as view and projection), render your world using world space, and come time to render your text set an Orthographic projection -- D3DXMatrixOrthoLH() and reset your world and view to the defaults and set the porojection using the ortholh method:

OrthoLH Function

This will force anything drawn after it to a 2D plane which should always be facing the camera....I've implemented my entire HUD in my FPS this way and seems to be working out well so far.

Permafried-

Share this post


Link to post
Share on other sites
Although i'm more an OpenGL coder i use the Projection matrix to this kind of things and screen coordinates

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this