繪製部分是直接用VS2010寫的win32 DLL(懶得用易寫了),繪製函數代碼如下,不想用帶的這個DLL自己寫就行了。
__declspec(dllexport) BOOL DrawMyTextEx(LPDIRECT3DDEVICE9 pDxdevice,TCHAR* strText ,int nbuf,TCHAR* FontName ,int FontH,int FontW,int FWeight,int Rleft,int Rtop,int Rright,int Rbottom,int Fc)
{
RECT myrect;
//myrect=SRECT;
myrect.top=Rtop; //文本塊的y座標
myrect.left=Rleft; //文本塊的左座標
myrect.right=Rright;
myrect.bottom=Rbottom;
pDxdevice->BeginScene();//開始繪製
D3DXFONT_DESCA lf;
ZeroMemory(&lf, sizeof(D3DXFONT_DESCA));
lf.Height = FontH; //字體高度
lf.Width = FontW; // 字體寬度
lf.Weight = FWeight;
lf.Italic = false;
lf.CharSet = DEFAULT_CHARSET;
strcpy(lf.FaceName, FontName);
ID3DXFont* font=NULL;
if(D3D_OK!=D3DXCreateFontIndirect(pDxdevice, &lf, &font))
return false;
font->DrawText(
NULL,
strText,
nbuf,
&myrect,
DT_TOP | DT_LEFT,
Fc);
pDxdevice->EndScene();//結束繪製
font->Release();//釋放對象
return true;
}