Hi again,
Im having a few problems with rendering TTF fonts, they display ok on the screen, but they move across the X axis rapidly when ever i call render.
I am probably missing something.. i have checked several sources on the net.
Heres my Font code:
Code:
function TXGUITTFFont.BuildFont: Boolean;
var
Font: HFONT;
_hdc: HDC;
begin
_hdc := wglGetCurrentDC;
If GlID > 0 Then glDeleteLists(GlID, 96);
GlID := glGenLists(96);
Font := CreateFont(-24,
0,
0,
0,
FW_BOLD,
0,
0,
0,
ANSI_CHARSET,
OUT_TT_PRECIS,
CLIP_DEFAULT_PRECIS,
ANTIALIASED_QUALITY,
FF_DONTCARE or DEFAULT_PITCH,
'Courier New');
SelectObject(_hdc, Font);
wglUseFontBitmaps(_hdc, 32, 96, GlID);
Result := True;
end;
destructor TXGUITTFFont.Destroy;
begin
If GlID > 0 Then glDeleteLists(GlID, 96);
inherited Destroy;
end;
function TXGUITTFFont.LoadFromFile(const Filename: String): Boolean;
begin
Result := BuildFont;
end;
procedure TXGUITTFFont.Render(const X,Y,Z: Single; const Value: String);
begin
If Value = '' Then Exit;
glPushMatrix;
glTranslatef(X, Y, Z);
glPushAttrib(GL_LIST_BIT);
glListBase(GlID-32);
glCallLists(Length(Value), GL_UNSIGNED_BYTE, PChar(Value));
glPopAttrib;
glPopMatrix;
end;
When i render the object i go through a loop,
Ortho On
glPushMatrix;
Render Controls
glPushMatrix;
Render Cursor
Render sample text (Cursor position)
glPopMatrix;
glPopMatrix;
Ortho Off
I cant see any where whats wrong, i checked if there's an extra Push/Pop matrix but cant find anything.
Any help will be great
Bookmarks