directx9学習(フォント)
- フォント作成(CMyFont::Init関数内)
D3DXFONT_DESC font;
font.Height = 16;
font.Width = 0;
font.Weight = FW_NORMAL;
font.Italic = FALSE;
font.CharSet = SHIFTJIS_CHARSET;
font.OutputPrecision = OUT_DEFAULT_PRECIS;
font.Quality = DEFAULT_QUALITY;
font.PitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
lstrcpy(font.FaceName, "");
if( FAILED( D3DXCreateFontIndirect( lpD3DDEV, &font, &m_lpFont ) ) ) {
MessageBox( 0, "D3DXCreateFontIndirect FALSE", "ok", MB_OK);
return;
}
- 表示(CMyFont::Print関数内)
m_lpFont->DrawText(NULL, str, -1, &rect
,DT_LEFT | DT_EXPANDTABS
,color
);
- 初期化(WinMain関数内)
// Create the scene geometry
if( SUCCEEDED( InitGeometry() ) )
{
// Show the window
ShowWindow( hWnd, SW_SHOWDEFAULT );
UpdateWindow( hWnd );sFont.Init(g_pd3dDevice, 12, 24);
// Enter the message loop
MSG msg;
ZeroMemory( &msg, sizeof(msg) );
while( msg.message!=WM_QUIT )
- 表示(Render関数内)
// Draw the mesh subset
g_pMesh->DrawSubset( i );
}sFont.Print("Hello world!", 0,0);
// End the scene
g_pd3dDevice->EndScene();
- 結果