Sign in to follow this  
orphankill

Font flickering with DX9

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

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