- procedure TGLBitmapFont.BuildFont(Size : Integer; Bold : Boolean; const aFont : String = 'Comic Sans MS');
- var
- pFont : array[0..63] of Char;
- oFont : HFont;
- iBold : Word;
- begin
- fBase := glGenLists(256);
- StrPCopy(pFont, aFont);
- iBold := 0;
- if Bold then begin
- iBold := FW_BOLD;
- end;
- fFont := CreateFont(-Size, 0, 0, 0, iBold, 0, 0, 0, ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, FF_DONTCARE or DEFAULT_PITCH, pFont);
- try
- oFont := SelectObject(Owner.DC, fFont);
- try
- wglUseFontBitmaps(Owner.DC, 0, 256, fBase);
- finally
- SelectObject(Owner.DC, oFont);
- end;
- except
- DeleteObject(fFont);
- fFont := 0;
- raise;
- end;
- end;
- procedure TGLBitmapFont.Write(X, Y : Integer; const aText : String);
- var
- pText : array[0..255] of Char;
- begin
- if (aText = '') then begin
- Exit;
- end;
- StrPLCopy(pText, aText, SizeOf(pText) - 1);
- glPushAttrib(GL_LIST_BIT);
- glListBase(fBase);
- glCallLists(Length(pText), GL_UNSIGNED_BYTE, @pText);
- glPopAttrib();
- end;