home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2006 July & August
/
PCWorld_2006-07-08_cd.bin
/
temacd
/
planearcade
/
planearcade.exe
/
Tank3.bmp
/
dxfont.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
2004-08-18
|
2KB
|
93 lines
#include "main.h"
//------------------------------------------------------------------
// Name: DXFONT()
// Desc: konstruktor
//------------------------------------------------------------------
DXFONT::DXFONT()
{
Font = NULL;
}
//------------------------------------------------------------------
// Name: ~DXFONT()
// Desc: destruktor
//------------------------------------------------------------------
DXFONT::~DXFONT()
{
if(Font != NULL)
Font->Release();
Font = NULL;
}
/*
AtributeFlag - FW_NORMAL, FW_BOLD
FontFace - Arial, CourierNew
*/
//------------------------------------------------------------------
// Name: Create()
// Desc: inicializacia fontu
//------------------------------------------------------------------
void DXFONT::Create(int Size,DWORD AtributeFlag,char *FontFace)
{
LogPrint("Vytvaram DXFONT");
HFONT hFont = CreateFont(Size, 0, 0, 0, AtributeFlag, false, false, false,
DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial");
if(!hFont)
{
LogPrint(" Chyba pri vytvarani fontu");
}
if(FAILED(D3DXCreateFont(g_pd3dDevice, hFont, &Font)))
{
LogPrint(" Chyba pri vytvarani fontu");
}
DeleteObject(hFont);
FontPosition.top = 0;
FontPosition.left = 0;
FontPosition.right = Engine.Width;
FontPosition.bottom = Engine.Height;
}
//------------------------------------------------------------------
// Name: Print()
// Desc: vytlacenie na obrazovku
//------------------------------------------------------------------
void DXFONT::Print(int x,int y,COLOR Color,char *Text)
{
FontPosition.left = x;
FontPosition.top = y;
Font->DrawText(TEXT(Text), -1, &FontPosition, DT_LEFT, D3DXCOLOR(Color.R,Color.G,Color.B,Color.A));
}
//------------------------------------------------------------------
// Name: PrintCenter()
// Desc: vytlacenie na obrazovku
//------------------------------------------------------------------
void DXFONT::PrintCenter(int x,int y,COLOR Color,char *Text)
{
FontPosition.left = 0;
FontPosition.top = y;
Font->DrawText(TEXT(Text), -1, &FontPosition, DT_CENTER, D3DXCOLOR(Color.R,Color.G,Color.B,Color.A));
}