I'm trying to show the score on the screen. Following code works fine:
g_Font = NULL;
D3DXFONT_DESC f = {fontSize,
0,
400,
0,
false,
DEFAULT_CHARSET,
OUT_TT_PRECIS,
CLIP_DEFAULT_PRECIS,
DEFAULT_PITCH,
fontName};
fontDesc = f;
fontPosition.top = top;
fontPosition.left = left;
fontPosition.right = right;
fontPosition.bottom = bottom;
text = t;
D3DXCreateFontIndirect(device,&fontDesc,&g_Font);
Following part is rendered for each frame:
g_Font->DrawText(NULL,
text,
-1,
&fontPosition,
DT_CENTER,
0xffffffff); //draw text
What I want to do is, update the text during runtime. I simply update the text variable since drawing code runs for each frame, but it doesn't work. A simple text works but following construction doesn't work:
const size_t buflen = 100;
TCHAR buf[buflen];
_sntprintf(buf, buflen - 1, TEXT("Point: %d"), point);
text = (LPCTSTR)buf;
I tried almost every solution I could have found online, but they don't work. I can see that the integer is converted successfully, but there are absurd characters in the following rendering. Any solutions?