Jump to content
  • Advertisement
Sign in to follow this  
Knight52

[dx9] hide text behind some 2d object

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

My texts are always on front, over every objects and textures. In draw commands, I put drawText command before objects that should be over the text, but it doesn't work. How can I draw texts with correct orders? They all use same instance but I don't think that's the issue.

Some codes that should be relevant

#define CUSTOMFVF2D (D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1)//FVF used to draw texts
HRESULT result;
void initialize(LPDIRECT3DDEVICE9 device, LPCSTR text)
{
result = D3DXCreateFont(device, 22, 0, FW_NORMAL, 1, false, DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY, (DEFAULT_PITCH | FF_DONTCARE), text, &font);
}
void draw(int textCount, char text[], int x, int y, DWORD format, DWORD color)
{
RECT rect; SetRect(&rect, x, y, 1024, 768);
result = font->DrawTextA(NULL, text, -1, &rect, format, color);
}

Share this post


Link to post
Share on other sites
Advertisement
AFAIK D3DXFont batches DrawText Calls and send them in a more optimized way to graphics card. You could try to use your own D3DXSprite object as first parameter in your DrawText call, which will be filled by the function. Then you can flush this object to draw immediately. But this way doesn't boost your fps...

There is an example here:
http://www.angelfire.com/sd2/glenfield/Coding/DirectX/DirectX-DisplayText.html

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!