📄 game_font.cpp
字号:
#include "Game_User.h"
CFont::CFont(LPDIRECT3DDEVICE9 pDevice, LPCTSTR pFacename,
INT Height, BOOL Italic, BOOL Bold, BOOL Underline)
{
m_pd3dDevice = pDevice;
int iWeight = FW_NORMAL;
DWORD dwItalic = 0;
DWORD dwUnderline = 0;
if(Italic)
dwItalic = 1;
if(Bold)
iWeight = FW_BOLD;
if(Underline)
dwUnderline = 1;
#if( 32 == D3D_SDK_VERSION )
D3DXCreateFont(m_pd3dDevice, Height, 0, iWeight, 0, dwItalic, DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, 0, pFacename, &m_pFont);
#else
HFONT hFont = CreateFont(Height, 0, 1, 0, iWeight, dwItalic, dwUnderline, 0,
DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY,
0, pFacename);
D3DXCreateFont(m_pd3dDevice, hFont, &m_pFont);
#endif
}
CFont::~CFont()
{
ClearUp();
}
void CFont::RenderFont(LPCSTR pText, int x, int y, D3DCOLOR rgbFontColor)
{
RECT rect;
rect.left = x;
rect.top = y;
rect.right = 0;
rect.bottom = 0;
#if( 32 == D3D_SDK_VERSION )
//Calculate the rect width and height
m_pFont->DrawText( 0, pText, -1, &rect, DT_CALCRECT, 0 );
m_pFont->DrawText( 0, pText, -1, &rect, DT_SINGLELINE, rgbFontColor );
#else
m_pFont->DrawText( pText, -1, &rect, DT_CALCRECT, 0);
m_pFont->DrawText( pText, -1, &rect, DT_SINGLELINE, rgbFontColor );
#endif
}
void CFont::ClearUp()
{
SAFE_RELEASE(m_pFont);
m_pd3dDevice = NULL;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -