Original Post
I am trying to display text onto a game surface through my d3d8.dll wrapper. Here is the code I am using.
m_pFont->DrawText( "Testing Text", 200, 120, ( 0,0,0 ) );
CFont::CFont(LPDIRECT3DDEVICE8 pD3DDevice, LPSTR pFontFace, int nHeight, bool fBold, bool fItalic, bool fUnderlined)
{
HFONT hFont;
m_pD3DDevice = pD3DDevice;
int nWeight = FW_NORMAL;
DWORD dwItalic = 0;
DWORD dwUnderlined = 0;
if(fBold)
{
nWeight = FW_BOLD;
}
if(fItalic)
{
dwItalic = 1;
}
if(fUnderlined)
{
dwUnderlined = 1;
}
hFont = CreateFont(nHeight, 0, 0, 0, nWeight, dwItalic, dwUnderlined, 0, ANSI_CHARSET, 0, 0, 0, 0, pFontFace);
D3DXCreateFont(m_pD3DDevice, hFont, &m_pFont);
}
CFont::~CFont()
{
SafeRelease(m_pFont);
}
void CFont::DrawText(LPSTR pText, int x, int y, D3DCOLOR rgbFontColour)
{
RECT Rect;
Rect.left = x;
Rect.top = y;
Rect.right = 0;
Rect.bottom = 0;
m_pFont->Begin();
m_pFont->DrawTextA(pText, -1, &Rect, DT_CALCRECT, 0); //Calculate the size of the rect needed
m_pFont->DrawTextA(pText, -1, &Rect, DT_LEFT, rgbFontColour); //Draw the text
m_pFont->End();
}
All it does is crash the game. Does anyone have any suggestions?