# D3DXFont Z-Positioning

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

## 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 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 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.

1. 1
Rutin
27
2. 2
3. 3
4. 4
5. 5

• 11
• 9
• 9
• 9
• 14
• ### Forum Statistics

• Total Topics
633312
• Total Posts
3011312
• ### Who's Online (See full list)

There are no registered users currently online

×