Click to See Complete Forum and Search --> : ID3DX Font probs


ZeroNerv
June 5th, 2006, 02:04 AM
i'm trying to just get a simple fps counter in top corner of screen but i keep getting errors (funny because i'm pulling this from some samples that are ment to work...

errors
c:\Documents and Settings\Hero\Desktop\C++ Projects\RCoderTank V.01\d3dinit.cpp(41): error C2664: 'D3DXCreateFontIndirectA' : cannot convert parameter 2 from 'LOGFONT *__w64 ' to 'const D3DXFONT_DESCA *'

line of code =
if(FAILED(D3DXCreateFontIndirect(Device, &lf, &Font)))
{
::MessageBox(0, "D3DXCreateFontIndirect() - FAILED", 0, 0);
::PostQuitMessage(0);
}



c:\Documents and Settings\Hero\Desktop\C++ Projects\RCoderTank V.01\d3dinit.cpp(80): error C2660: 'ID3DXFont::DrawTextA' : function does not take 4 arguments


line of code =
Font->DrawTextA( FPSString, -1, &rect, 0xff000000);

i'v also added the project.
i appreciate anyhelp..
take pitty on a noob :P i'm trying.

Mike Harnad
June 5th, 2006, 09:03 AM
1. You're using D3DXCreateFontIndirect() incorrectly. The 2nd param must be a D3DXFONT_DESC *. For example,

pFont->CreateFontIndirect(&lf);
pFont->GetLogFont(&lf);
D3DXFONT_DESC fontdesc;
ZeroMemory(&fontdesc, sizeof(D3DXFONT_DESC));
fontdesc.Height = lf.lfHeight;
fontdesc.Width = lf.lfWidth;
fontdesc.Weight = FW_BOLD;
strcpy(fontdesc.FaceName, lf.lfFaceName);
fontdesc.CharSet = lf.lfCharSet;
pDirect3DFont = NULL;
D3DXCreateFontIndirect(pDirect3DDevice, &fontdesc, &pDirect3DFont);

2. The compiler is confused as to which DrawText() you intend to use. Do you want CDC:: DrawText(), or, ID3DXFont:: DrawText ()?

ZeroNerv
June 6th, 2006, 12:11 AM
ID3DXFont:: DrawText ()

this is funny because it is exactly what was writen in the text book :P

Mike Harnad
June 6th, 2006, 07:52 AM
Your code does not reflect what ID3DXFont:: DrawText() expects:

INT DrawText(LPD3DXSPRITE pSprite,
LPCTSTR pString,
INT Count,
LPRECT pRect,
DWORD Format,
D3DCOLOR Color
);