First method (best in my opinion) -
Code:
void PrintText1(double x, double y, DWORD dwColor, LPD3DXFONT pFont, char *Text, ...)
{
char buffer[256];
//This is for handling the "..." parameters
va_list argList;
va_start(argList, Text);
vsnprintf_s(buffer, sizeof(buffer), sizeof(buffer) - strlen(buffer), Text, argList);
va_end(argList);
//Our Rect to where the text will be printed
RECT Rect =
{
x,
y,
x + 500,
y + 50
};
pFont->DrawText(NULL, buffer, -1, &Rect, DT_NOCLIP, dwColor);
}
Second method -
Code:
void PrintText2(char *Text, double x, double y, DWORD dwColor, LPD3DXFONT pFont)
{
RECT FontR =
{
x,
y,
x + 500,
y + 30
};
pFont->DrawText(NULL, Text, -1, &FontR, DT_LEFT | DT_WORDBREAK, dwColor);
}
It's really just the same thing except without the extra arguments.
CREDITS TO ME FOR BOTH FUNCTIONS!