unit font;

interface

uses Windows, OpenGL, variables;

procedure InitializeFont(hdc : HDC; font_name : string);
procedure WriteText(tx, ty : integer; text : String);

implementation

var
  fontbase : GLuint;

procedure InitializeFont(hdc : HDC; font_name : string);
var
  font : HFONT;
begin
fontbase := glGenLists(96);  
font := CreateFont(font_scale_x, font_scale_y, 0, 0, 0, 0, 0, 0, DEFAULT_CHARSET, OUT_TT_PRECIS,
CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, FF_DONTCARE or DEFAULT_PITCH,
PChar(font_name));
SelectObject(hdc, font);
//wglUseFontBitmaps(hdc, 32, 96, fontbase);
wglUseFontBitmaps(hdc, 32, 224, fontbase);
DeleteObject(font);
end;

procedure PutChar(text : PChar);
begin
if (text = '') then exit;
glPushAttrib(GL_LIST_BIT);
glListBase(fontbase - 32);
glCallLists(length(text), GL_UNSIGNED_BYTE, text);
glPopAttrib;
end;

procedure WriteText(tx, ty : integer; text : String);
begin
glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
glDisable(GL_TEXTURE_2D);

glRasterPos2i(tx, ty);
PutChar(PChar(text));

glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glEnable(GL_TEXTURE_2D);
end;

end.
 