WHY Irrlicht engine don't support system fonts. Two years ago I began to write a game, but not finished it. In it I implemented using of system fonts in DirectX (I don't know OpenGL).
I hope that Niko will implement system fonts:
///////////////CSystemFont.h/////////////////////////
class DLLEXPORT CSystemFont
{
private:
D3DCOLOR Color;
LPD3DXFONT pFont;
RECT Rect;
bool bInitialized;
LPDIRECT3DDEVICE8 m_pD3D_Device;
public:
CSystemFont(void);
~CSystemFont(void);
void Init(LPDIRECT3DDEVICE8 pD3D_Device, HFONT, D3DCOLOR, int x, int y);
void SetColor(D3DCOLOR);
void SetPosition(int, int);
void Print(char *);
void Restore(void);
};
///////////CSystemFont.cpp///////////////////
CSystemFont::CSystemFont(void)
{
SAFE_RELEASE(pFont);
}
CSystemFont::~CSystemFont(void)
{
SAFE_RELEASE(pFont);
SAFE_RELEASE(m_pD3D_Device);
}
void CSystemFont::Init(LPDIRECT3DDEVICE8 pD3D_Device, HFONT in_hFont, D3DCOLOR in_Color, int in_x, int in_y)
{
HRESULT hr;
if (!pD3D_Device)
Except(999, "Invalid Direct3D device passed in", "CSystemFont::Init()");
m_pD3D_Device = pD3D_Device;
hr = D3DXCreateFont(m_pD3D_Device, in_hFont, &pFont);
if (FAILED(hr))
Except(999, "Failed to create D3D font", "CSystemFont::Init()");
Color = in_Color;
bInitialized = true;
Rect.left = in_x;
Rect.top = in_y;
Rect.right = 0;
Rect.bottom = 0;
};
void CSystemFont::SetColor(D3DCOLOR in_Color)
{
Color = in_Color;
};
void CSystemFont::SetPosition(int in_x, int in_y)
{
Rect.left = in_x;
Rect.top = in_y;
};
void CSystemFont::Print(char *in_text)
{
if (!bInitialized) return Except(999, "Failed to print text because the font wasn't initialized", "CSystemFont::Print");
pFont->Begin();
pFont->DrawTextA(in_text, -1, &Rect, 0, Color);
pFont->End();
};
void CSystemFont::Restore (void)
{
pFont->OnLostDevice();
pFont->OnResetDevice();
};
AND how to use this code:
//////////Main.cpp////////////////
CSystemFont test_font;
HFONT hFont = CreateFont(
10, // nHeight //
0, // nWidth //
0, // nEscapement //
0, // nOrientation //
FW_EXTRABOLD, // nWeight //
false, // bItalic //
false, // bUnderline //
0, // cStrikeOut //
ANSI_CHARSET, // nCharSet //
OUT_DEFAULT_PRECIS, //nOutPrecision //
CLIP_DEFAULT_PRECIS, // nClipPrecision //
PROOF_QUALITY, // nQuality //
DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily //
"Verdana"); // font name //
test_font.Init(D3DDevice8Obj, hFont, D3DCOLOR_ARGB(255, 255, 255, 255), 5, 5);
Then in loop we call test_font.Restore() before BeginScene func.
beginScene();
test_font.Print("IRRLICHT!!!!!!!!!!!!!!!!!!!");
endScence();
System fonts
System fonts
But, at first you can implement it in DirectX under the Windows and in the next releases you can finish work on it.
Re: System fonts
lolREAPER wrote:But, at first you can implement it in DirectX under the Windows and in the next releases you can finish work on it.
2D-Splatter-Action => http://www.walkover.de.vu <=