全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:1003
推到 Plurk!
推到 Facebook!

使用ID3DXFont確無法正確顯示文字]

缺席
李國維
高階會員


發表:42
回覆:287
積分:235
註冊:2003-02-07

發送簡訊給我
#1 引用回覆 回覆 發表時間:2005-01-13 12:51:29 IP:220.130.xxx.xxx 未訂閱
請想問有用過ID3DXFont的大大: 小弟的程式碼如下.
LPDIRECT3D9       g_pD3D;
LPDIRECT3DDEVICE9 g_Device;
ID3DXFont*        font;
bool __fastcall TForm1::InitD3D9()
{
 HWND              g_hwnd;
 g_hwnd = Form1->Handle;
 g_pD3D = Direct3DCreate9(D3D_SDK_VERSION);
 if(g_pD3D == NULL)
 {
   return false;
 }
 D3DDISPLAYMODE d3ddm;
 if(FAILED(g_pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm)))
 {
   return false;
 }
  //Create a structure to hold the settings for our device
 D3DPRESENT_PARAMETERS d3dpp;
 ZeroMemory(&d3dpp, sizeof(d3dpp));      //Fill the structure.
  //We want our program to be windowed, and set the back buffer to a format
  //that matches our current display mode
 d3dpp.Windowed = true;
 d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
 d3dpp.BackBufferFormat = d3ddm.Format;
 d3dpp.hDeviceWindow = g_hwnd;
  //Create a Direct3D device.
 if(FAILED(g_pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,g_hwnd,D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &g_Device)))
 {
    return false;
 }
 LOGFONT lf;
 ZeroMemory(&lf, sizeof(LOGFONT));
 lf.lfHeight = 24; // in logical units
 lf.lfWidth = 24; // in logical units
 lf.lfWeight = 500; // boldness, range 0(light) - 1000(bold)
 lf.lfItalic = false;
 lf.lfUnderline = false;
 lf.lfStrikeOut = false;
 lf.lfCharSet = DEFAULT_CHARSET;
 strcpy(lf.lfFaceName, "Times New Roman"); // font style
 D3DXCreateFontIndirect(g_Device, &lf, &font);
 return true;
}
void __fastcall TForm1::DrawText()
{
 TRect rect;
 rect.top = 200;
 rect.left = 200;
 rect.Bottom = 400;
 rect.right = 400; 
 font->Begin();
 font->DrawText("Hello World",-1,&rect,DT_TOP | DT_LEFT,0xff000000);
 font->End();
}
不知道小弟有哪裡設定出了問題.執行後卻沒有看到文字.煩請大大指導.
系統時間:2024-05-21 0:45:34
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!