I want to tell the player his/her health via the DrawText function, but the only problem is that by doing so it messes with the how the meshes are drawn. What I mean by that is it seems like the square in the back is being drawn in front of the one in front. For example:
When firing missiles it looks like this
Instead of this
And the "aliens" look like this
Instead of this (ignore the missile)
Here is my code
Thank you.Code://Render function void BimanEngine::Render() { //Clear the render target view m_pD3DDevice->ClearRenderTargetView(m_pRenderTargetView, D3DXCOLOR(0.02f, 0.04f, 0.2f, 0.0f)); //Clear the depth/stencil view m_pD3DDevice->ClearDepthStencilView(m_pDepthStencilView, D3D10_CLEAR_DEPTH|D3D10_CLEAR_STENCIL, 1.0f, 0); GamePaint(); m_pSwapChain->Present(0, 0); } //GamePaint function void GamePaint() { g_pGame->GetDevice()->IASetInputLayout(g_pInputLayout); for(auto it = g_pAliens.begin(); it != g_pAliens.end(); it++) (*it)->Draw(); for(auto it = gMissiles.begin(); it != gMissiles.end(); it++) (*it).pModel->Draw(); //Display the health g_pGame->GetFontSprite()->Begin(D3DX10_SPRITE_SORT_TEXTURE); TCHAR szHealth[64]; wsprintf(szHealth, TEXT("Health: %d"), g_iHealth); g_pGame->DrawText(szHealth, 10, 10, D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f)); g_pGame->GetFontSprite()->End(); } //Draw text function void BimanEngine::DrawText(LPCWSTR szText, int x, int y, D3DXCOLOR TextColor) { RECT rect = {x, y, 0, 0}; //Display rect HRESULT hr = m_pFont->DrawText(m_pFontSprite, szText, -1, &rect, DT_NOCLIP, TextColor); if(FAILED(hr)) Error(TEXT("DrawText Failed")); } //The Draw function void ModelObject::Draw() { //Make sure the mesh is valid if(!m_pMesh) return; //Render the object D3D10_TECHNIQUE_DESC TechniqueDesc; m_pTechnique->GetDesc(&TechniqueDesc); for(UINT p = 0; p < TechniqueDesc.Passes; ++p) { m_pTechnique->GetPassByIndex(p)->Apply(0); //Draw the mesh m_pMesh->DrawSubset(0); } }



LinkBack URL
About LinkBacks






