Jump to content
  • Advertisement
Sign in to follow this  
orphankill

Font flickering with DX9

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

Hi, I've been experiencing a problem with text since I started the development of game. Most of the time (but not always, say 3/4 times) I start my game, the text on the screen will flicker. Disappear and then come back less then a second later, and repeat this forever. The text flickers in the order that it's displayed. For instance, the game title flickers, then immediately afterwards the menu flickers, then the fps display, and then version number. I'm using ID3DXFONT and passing a sprite that I created, but it was still flickering before I started passing my own sprite. It flickers VERY badly if I open the game settings menu and switch resolutions. In fact, if I do that it will disappear for almost an entire seconds before quickly coming and leaving again. Has anyone else experienced this and fixed it? Or have a better way to display text? (and no, it's not because I'm making a random device->Clear() call somewhere in my code, which is what I first suspected)

Share this post


Link to post
Share on other sites
Advertisement
Aere you using a Z buffer and not clearing it? Or are you only rendering the text every other frame or something? Text normally works fine...

Share this post


Link to post
Share on other sites
d3ddev->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);

That's my clear call, it's right isn't it?. All text is rendered once. I am making several sprite->begin/end calls every frame with the same sprite. Would that effect anything?

Share this post


Link to post
Share on other sites
Yup, that looks correct. Why do you need several sprite Begin() End() pairs per frame?

Sounds like we'll need to see some code.

Share this post


Link to post
Share on other sites
Because I'm writing text more then once in the frame, and at different times in different functions so I can't contain it in a single Begin() End(). Here's the function I call more than once:


void RenderText(LPSTR text_to_write, RECT *location = NULL, LPD3DXFONT myfont = NULL, DWORD alignment = DT_CENTER | DT_VCENTER, DWORD color = D3DCOLOR_RGBA(255, 255, 255, 255))
{
if (!location)
{
RECT temp = { 300, 300, 800, 600 };
location = &temp;
}

BeginSprite();
if (!myfont)
font->DrawTextA(d3dspr, text_to_write, -1, location, alignment | DT_NOCLIP, color);
else
myfont->DrawTextA(d3dspr, text_to_write, -1, location, alignment | DT_NOCLIP, color);
EndSprite();

location = NULL;
}

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!