I'm having trouble with my depthstate. I want to render text and a terrain but I cant seem to restore the depthstate after written some text.
Whats wrong: my app should shown me a terrain with text but I only get the text. If i remove the DrawFont the terrain appears prefectly.
My DrawFont func:
void DrawFont()
{
// Create and Initialize the destination rectangle
RECT rc;
SetRectEmpty(&rc);
rc.top = 100;
rc.left = 100;
// Use the GetFontRectangle helper function to get the proper size
// of the rectangle.
GetFontRectangle(TEXT("This is a test string"), &rc);
pFontSprite->Begin(D3DX10_SPRITE_SORT_TEXTURE | D3DX10_SPRITE_SAVE_STATE );
// Draw the text to the screen
HRESULT hr = pFont->DrawText(
pFontSprite,
TEXT("This is a test string"),
-1,
&rc,
DT_LEFT,
D3DXCOLOR(1.0f, 0.0f, 0.0f, 1.0f) );
// Save the current blend state
pD3DDevice->OMGetBlendState(&pOriginalBlendState10, OriginalBlendFactor, &OriginalSampleMask);
// Set the blend state for font drawing
if(pFontBlendState10)
{
FLOAT NewBlendFactor[4] = {0,0,0,0};
pD3DDevice->OMSetBlendState(pFontBlendState10, NewBlendFactor, 0xffffffff);
}
pFontSprite->End();
// Restore the previous blend state
pD3DDevice->OMSetBlendState(pOriginalBlendState10, OriginalBlendFactor, OriginalSampleMask);
}
Notice that I use pFontSprite->Begin(D3DX10_SPRITE_SORT_TEXTURE | D3DX10_SPRITE_SAVE_STATE );, and I though it would save my state then later on restore on pFontSprite->End();... but I'm wrong and all i get is text in my little app.