Hello Bubba, nice shots. I had already setted up the fog effect and it works fine, but I have find a derived effect: on writing text with the DX DrawText() function it sets the text color to the fog color (only if D3DRS_FOGENABLE is TRUE). I haven't find any reference to that secondary effect on the DirectX Programer's Reference, so for the moment to avoid it I disable the fog effect (also works if I set the fog color to the text color), draw the text, and re-set the fog to it's original. A second way could be drawing 2D sprites from a charset map, but I think that maybe it would be slower (althought for the moment the game speed isn't the problem). Let me append two images: in the first I set up the linear fog (start 1.0f, end 2000.0f, red) and draw green text without disabling the fog; the result is that the text is auto setted to the fog color. On the second I set up the fog, disable before draw the text, and re-set the fog effect. The code I used to do it:
Code:
//setting up the fog
float inici=1.0f;
float final=2000.0f;
g_pd3ddevice->SetRenderState(D3DRS_FOGENABLE,TRUE);
g_pd3ddevice->SetRenderState(D3DRS_FOGCOLOR,D3DCOLOR_XRGB(255,0,0));
g_pd3ddevice->SetRenderState(D3DRS_FOGVERTEXMODE,D3DFOG_LINEAR);
g_pd3ddevice->SetRenderState(D3DRS_FOGSTART,*(DWORD*)(&inici));
g_pd3ddevice->SetRenderState(D3DRS_FOGEND,*(DWORD*)(&final));
Code:
//creating the font
LOGFONT LogFont={16,0,0,0,FW_NORMAL,false,false,false,DEFAULT_CHARSET,OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS,PROOF_QUALITY,DEFAULT_PITCH,"Verdana"};
D3DXCreateFontIndirect(g_pd3ddevice,&LogFont,&g_Font);
//g_Font is a LPD3DXFONT
Code:
/*
The draw text function from a call such like
m_pTipog1->mostraTexte("the text",10,10,D3DCOLOR_XRGB(0,255,0));
where m_pTipog1 is an object created with an HFONT created with the CreateFont() Win32 API standard function, and D3DXCreateFont(device,HFONT_last_created,LPD3DXFONT);
That LPD3DXFONT is wich I'll use to draw the text
*/
void CTipografia::mostraTexte(LPSTR tx,int x,int y,D3DCOLOR color)
{
RECT area;
area.left=x;
area.top=y;
area.right=0;
area.bottom=0;
m_pTipog->Begin();
g_pd3ddevice->SetRenderState(D3DRS_FOGENABLE,FALSE);
m_pTipog->DrawTextA(tx,-1,&area,DT_CALCRECT,0);
m_pTipog->DrawTextA(tx,-1,&area,DT_LEFT,color);
g_pd3ddevice->SetRenderState(D3DRS_FOGENABLE,TRUE);
m_pTipog->End();
/*
where m_pTipog is the LPD3DXFONT previously created
*/
}
I think I haven't forgot anything.
Is that secondary fog effect normal and the disabling the fog before draw text a right solution?
Thank's
Niara