⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 myfont.cpp

📁 MIRROR001程序是关于ALPHA混合透明的应用
💻 CPP
字号:
// MyFont.cpp: implementation of the CMyFont class.
//
//////////////////////////////////////////////////////////////////////

#include "MyFont.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CMyFont::CMyFont(LPDIRECT3DDEVICE9 d3dDevice,LPSTR pFontface,int nHeight,bool fBold,
		bool fItalic,bool fUnderlined)
{
	g_pDevice=d3dDevice;


	int nWidth=0;
	DWORD nItalic=0;
	DWORD nUnderlined=0;
	if(fBold)
		nWidth=FW_BOLD;
	else 
		nWidth=FW_NORMAL;
	if(fItalic)
		nItalic=1;
	if(fUnderlined)
		nUnderlined=1;
	HFONT  hFont;
	hFont=CreateFont(nHeight,0,0,0,nWidth,nItalic,nUnderlined,0,
		ANSI_CHARSET,0,0,0,0,pFontface);
	D3DXCreateFont(g_pDevice,hFont,&g_pFont);
}

CMyFont::~CMyFont()
{
	if(g_pFont)
	{
		g_pFont->Release();
		g_pFont=NULL;
	}

}

void CMyFont::DrawText(LPSTR pText, int x, int y, D3DCOLOR color)
{
	RECT  rect;
	rect.top=y;
	rect.bottom=y;
	rect.right=x;
	rect.left=x;
    g_pFont->Begin();
	g_pFont->DrawTextA(pText,-1,&rect,DT_CALCRECT,0);
	g_pFont->DrawTextA(pText,-1,&rect,DT_LEFT,color);
	g_pFont->End();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -