Sign in to follow this  
Juliean

D3DXFont Z-Positioning

Recommended Posts

Hello,

 

I want to use the D3DXFont to draw some texts for my DX9-driven level-editor. Only problem: The text always appears at the top of everything (2d rendering only), no matter what I do. Kind of what you expect since DrawText() doesn't use any "z"-related parameter. I've already set up a working Front-to-back ordered render using the D3DXSPRITE-interface, which I'm also using for the font-rendering:

 

m_lpFont->DrawText(m_lpD3DSprite, lpText, -1, &winRect, 0, m_Color);

Any chance to order the text to a certain z-value? Maybe some setting for the sprite? If possible I would want to be able to do this without having to render out the sprite (text is drawn all over the place in the code and using only one draw()->end() - sequenz is significantly faster). Any ideas?

Edited by The King2

Share this post


Link to post
Share on other sites

I personally prefer to avoid ID3DXFont when possible.  Instead, I wrote my own texture based font class and was ultimately happier using it.  This way, I could have more control over my code and even z-ordering if necessary.

 

This link does a decent job of explaining how it's done: http://cboard.cprogramming.com/game-programming/70990-font-rendering-direct3d.html

 

If you want, I can share mine.  ^^

 

Shogun.

Share this post


Link to post
Share on other sites

Thanks for the advice, I'll definately have a look at it,

 

but I managed to solve the ID3DXFont myself so for now I'm going to stick with it (I want to invest my time into other areas first). The problem was that first of all I forgot to set the ID3DXSprite-Object for my Font-class so it would draw with "NULL", and therefor without a sprite when calling DrawText. That way the transform didn't get applied to at all. With this fixed just setting an identity-matrix and calling "m_mTransform(3,2) = z;" before setting the transform, everything works just fine.

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