D3DXCreateFont is from D3D
X9 Api (d3dx9.lib)
From msdn
Code:
HRESULT D3DXCreateFont(
__in LPDIRECT3DDEVICE9 pDevice,
__in INT Height,
__in UINT Width,
__in UINT Weight,
__in UINT MipLevels,
__in BOOL Italic,
__in DWORD CharSet,
__in DWORD OutputPrecision,
__in DWORD Quality,
__in DWORD PitchAndFamily,
__in LPCTSTR pFacename,
__out LPD3DXFONT *ppFont
);
Quote:
The compiler setting also determines the function version. If Unicode is defined, the function call resolves to D3DXCreateFontW. Otherwise, the function call resolves to D3DXCreateFontA because ANSI strings are being used.
http://msdn.microsoft.com/en-us/library ... 85%29.aspxyou must use D3DXCreateFontW for unicode or D3DXCreateFontA for ascii
Import of D3DXCreateFontA
Code:
Import "lib\d3dx9.lib" ; DirectX SDX
D3DXCreateFontA(*pDevice, Height.i, Width.l, Weight.l, MipLevels.l, Italic.b, CharSet.l, OutputPrecision.l, Quality.l, PitchAndFamily.l, *pFacename, *ppFont)
EndImport
Creation of the font
Code:
*testfont.ID3DXFont
name.s = "Courrier New"
D3DXCreateFontA(*D3DDevice, 12, 0,0,1,0, #DEFAULT_CHARSET, #OUT_DEFAULT_PRECIS, #DEFAULT_QUALITY, #DEFAULT_PITCH, @name,@*testfont)
to draw text you must call drawtext()
Code:
INT DrawText(
[in] LPD3DXSPRITE pSprite,
[in] LPCTSTR pString,
[in] INT Count,
[in] LPRECT pRect,
[in] DWORD Format,
[in] D3DCOLOR Color
);
Quote:
This method must be called inside a BeginScene ... EndScene block. The only exception is when an application calls DrawText with DT_CALCRECT to calculate the size of a given block of text.
http://msdn.microsoft.com/en-us/library ... 85%29.aspxFirst you must create a new rectangle
Code:
textrect.RECT
textrect\left= 10 ; X
textrect\top= 10 ; Y
Then calculate the size of the rectangle with DrawText and DT_CALCRECT as parameter
Quote:
DT_CALCRECT
Determines the width and height of the rectangle. If there are multiple lines of text, DrawText uses the width of the rectangle pointed to by the pRect parameter and extends the base of the rectangle to bound the last line of text. If there is only one line of text, DrawText modifies the right side of the rectangle so that it bounds the last character in the line. In either case, DrawText returns the height of the formatted text but does not draw the text.
Code:
*testfont\DrawTextA(NULL, "HelloWorld", -1, textrect, #DT_CALCRECT | #DT_LEFT, NULL)
Debug textrect\right
Debug textrect\bottom
and finally draw the text
Code:
*D3DDevice\Clear(0, 0, #D3DCLEAR_TARGET, D3DRGBA(0,0,0,255), 0.0, 0)
*D3DDevice\BeginScene()
*testfont\DrawTextA(NULL, "HelloWorld", -1, textrect, #DT_LEFT, D3DRGBA(0,0,255,255))
*D3DDevice\EndScene()
*D3DDevice\Present(NULL, NULL, NULL, NULL)
You can't use RGBA() with directx, here is a compatible macro
Code:
Macro D3DRGBA (r, g, b, a)
(a&$ff)<<24 | (r&$ff)<<16 | (g&$ff)<<8 | (b&$ff)
EndMacro