I'm writing a simple game engine and the first thing I decided to do was to make it output text, but the problem is the text wont show up
Here is my code
Code:
//Initializing font and sprite object
hr = D3DX10CreateSprite(m_pD3DDevice, 512, &m_pSpriteObject);
if(hr != S_OK)
MessageBox(NULL, TEXT("Can't create the sprite object"), TEXT("ERROR!"), MB_OK);
if(FAILED(D3DX10CreateFont(m_pD3DDevice, 30, 0, FW_BOLD, 1, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY,
DEFAULT_PITCH | FF_DONTCARE, TEXT("Helvetica"), &m_pFont)))
return FALSE;
Code:
//Render function
void GameEngine::Render()
{
m_pD3DDevice->ClearRenderTargetView(m_pRenderTargetView, D3DXCOLOR(0.0f, 0.0f, 0.0f, 0.0f));
m_pSpriteObject->SetProjectionTransform(&m_mxProjection);
GamePaint();
m_pSwapChain->Present(0, 0);
}
Code:
//Game Paint Function
void GamePaint()
{
g_pGame->DrawText(TEXT("This is a test"));
}
Code:
//Draw Text Function
void BimanEngine::DrawText(LPCWSTR szText)
{
RECT rect;
SetRectEmpty(&rect);
//Get the size of rect
HRESULT hr = m_pFont->DrawTextW(NULL, szText, -1, &rect, DT_CALCRECT | DT_LEFT, D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f));
if(FAILED(hr))
MessageBox(m_hWindow, TEXT("DrawText failed"), TEXT("Error"), MB_OK);
//Display rect
hr = m_pFont->DrawTextW(m_pSpriteObject, szText, -1, &rect, DT_LEFT, D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f));
if(FAILED(hr))
MessageBox(m_hWindow, TEXT("DrawText failed"), TEXT("Error"), MB_OK);
}
Thank you in advance