Emil
Instead of using the Font.tga, try to translate this one to Delphi, it would let you use any True Type font with OpenGL without the need to provide an extra file.
%GL_LIGHTING = &H0B50
%GL_TEXTURE_2D = &H0DE1
%GL_MODELVIEW = &H1700
%GL_PROJECTION = &H1701
%GL_LIST_BIT = &H00020000
%GL_UNSIGNED_BYTE = &H1401
#IF %BBP_NO_GLFONT = 0
TYPE ZGLFONT
fontName AS ASCIIZ * 64 ' The True Type font name.
fontBase AS LONG ' The OpenGL FontBase (do not set this).
charStart AS LONG ' OpenGL starting ASCII character (usually 32).
charNum AS LONG ' OpenGL number of glyphe characters to create(usually 96).
fontHeight AS LONG ' The font size (72 DPI).
fontWeight AS LONG ' The font weigt.
fontHandle AS LONG ' The Win32 font handle
END TYPE
TYPE SIZEL
cx AS LONG
cy AS LONG
END TYPE
TYPE RECT
nLeft AS LONG
nTop AS LONG
nRight AS LONG
nBottom AS LONG
END TYPE
%FW_BOLD = 700
%OUT_TT_PRECIS = 4
%ANTIALIASED_QUALITY = 4
DECLARE FUNCTION GetStockObject LIB "GDI32.DLL" ALIAS "GetStockObject" (BYVAL nIndex AS LONG) AS DWORD
DECLARE FUNCTION GetDeviceCaps LIB "GDI32.DLL" ALIAS "GetDeviceCaps" (BYVAL hdc AS DWORD, BYVAL nIndex AS LONG) AS LONG
DECLARE FUNCTION CreateFont LIB "GDI32.DLL" ALIAS "CreateFontA" (BYVAL nHeight AS LONG, BYVAL nWidth AS LONG, BYVAL nEscapement AS LONG, BYVAL nOrientation AS LONG, BYVAL fnWeight AS LONG, BYVAL fdwItalic AS DWORD, _
BYVAL fdwUnderline AS DWORD, BYVAL fdwStrikeOut AS DWORD, BYVAL fdwCharSet AS DWORD, BYVAL fdwOutputPrecision AS DWORD, BYVAL fdwClipPrecision AS DWORD, BYVAL fdwQuality AS DWORD, _
BYVAL fdwPitchAndFamily AS DWORD, lpszFace AS ASCIIZ) AS DWORD
DECLARE FUNCTION glGenLists LIB "opengl32.dll" ALIAS "glGenLists" (BYVAL range&) AS DWORD
DECLARE FUNCTION wglUseFontBitmaps LIB "OPENGL32.DLL" ALIAS "wglUseFontBitmapsA" (BYVAL hdc AS DWORD, BYVAL dFirst AS DWORD, BYVAL dCount AS DWORD, BYVAL dListBase AS DWORD) AS LONG
DECLARE FUNCTION GetTextExtentPoint32 LIB "GDI32.DLL" ALIAS "GetTextExtentPoint32A" (BYVAL hdc AS DWORD, lpsz AS ASCIIZ, BYVAL cbString AS LONG, lpSize AS SIZEL) AS LONG
DECLARE SUB glDeleteLists LIB "opengl32.dll" ALIAS "glDeleteLists" (BYVAL list AS DWORD, BYVAL range&)
DECLARE FUNCTION GetClientRect LIB "USER32.DLL" ALIAS "GetClientRect" (BYVAL hwnd AS DWORD, lpRect AS RECT) AS LONG
DECLARE FUNCTION glIsEnabled LIB "opengl32.dll" ALIAS "glIsEnabled" (BYVAL cap AS DWORD) AS BYTE
DECLARE SUB glDisable LIB "opengl32.dll" ALIAS "glDisable" (BYVAL cap AS DWORD)
DECLARE SUB glMatrixMode LIB "opengl32.dll" ALIAS "glMatrixMode" (BYVAL mode AS DWORD)
DECLARE SUB glPushMatrix LIB "opengl32.dll" ALIAS "glPushMatrix" ()
DECLARE SUB glLoadIdentity LIB "opengl32.dll" ALIAS "glLoadIdentity" ()
DECLARE SUB glOrtho LIB "opengl32.dll" ALIAS "glOrtho" (BYVAL nleft AS DOUBLE, BYVAL nright AS DOUBLE, BYVAL bottom AS DOUBLE, BYVAL top AS DOUBLE, BYVAL zNear AS DOUBLE, BYVAL zFar AS DOUBLE)
DECLARE SUB glColor3f LIB "opengl32.dll" ALIAS "glColor3f" (BYVAL red AS SINGLE, BYVAL green AS SINGLE, BYVAL blue AS SINGLE)
DECLARE SUB glRasterPos2i LIB "opengl32.dll" ALIAS "glRasterPos2i" (BYVAL x&, BYVAL y&)
DECLARE SUB glPushAttrib LIB "opengl32.dll" ALIAS "glPushAttrib" (BYVAL mask AS DWORD)
DECLARE SUB glListBase LIB "opengl32.dll" ALIAS "glListBase" (BYVAL nbase AS DWORD)
DECLARE SUB glCallLists LIB "opengl32.dll" ALIAS "glCallLists" (BYVAL n&, BYVAL ntype AS DWORD, lists AS ANY)
DECLARE SUB glPopAttrib LIB "opengl32.dll" ALIAS "glPopAttrib" ()
DECLARE SUB glPopMatrix LIB "opengl32.dll" ALIAS "glPopMatrix"
FUNCTION BBP_DefaultFont() AS LONG
STATIC hDefault AS LONG
IF hDefault = 0 THEN hDefault = GetStockObject(12) ' %ANSI_VAR_FONT
FUNCTION = hDefault
END FUNCTION
SUB BBP_BuildGLfont (BYVAL hDC AS LONG, UseFont AS ZGLFONT)
LOCAL OldFont AS LONG, lpSize AS SIZEL, hFont AS LONG, LenFontName AS LONG
UseFont.charStart = 32
UseFont.charNum = 96
UseFont.fontBase = glGenLists(UseFont.charNum) ' Storage For 96 Characters
LenFontName = LEN(UseFont.fontName)
IF hDC = 0 THEN LenFontName = 0
IF LenFontName THEN
IF UseFont.fontHeight < 1 THEN UseFont.fontHeight = 10
UseFont.fontHeight = -1 * (UseFont.fontHeight * GetDeviceCaps(hDC, 90)) \ 72
IF UseFont.fontWeight = 0 THEN UseFont.fontWeight = %FW_BOLD
hFont = CreateFont(UseFont.fontHeight, _ ' Height Of Font
0, _ ' Width Of Font
0, _ ' Angle Of Escapement
0, _ ' Orientation Angle
UseFont.fontWeight, _ ' Font Weight
0, _ ' Italic
0, _ ' Underline
0, _ ' Strikeout
0, _ ' %ANSI_CHARSET Character Set Identifier
%OUT_TT_PRECIS, _ ' Output Precision
0, _ ' %CLIP_DEFAULT_PRECIS Clipping Precision
%ANTIALIASED_QUALITY, _ ' Output Quality
0, _ ' %FF_DONTCARE OR %DEFAULT_PITCH Family And Pitch
UseFont.fontName) ' Font Name
ELSE
hFont = BBP_DefaultFont()
END IF
IF hFont THEN
OldFont = SelectObject(hDC, hFont) ' Selects our font
' Builds 96 Characters Starting At Character 32
CALL wglUseFontBitmaps(hDC, UseFont.charStart, UseFont.charNum, UseFont.fontBase)
' Get font height
CALL GetTextExtentPoint32(hDC, "W", 1, lpSize)
UseFont.fontHeight = lpSize.cy
CALL SelectObject(hDC, oldfont) ' Restore previous selected font
IF LenFontName THEN UseFont.fontHandle = hFont ' Save the Win32 font handle
END IF
END SUB
SUB BBP_DeleteGLFont (UseFont AS ZGLFONT)
IF UseFont.fontBase THEN
CALL glDeleteLists(UseFont.fontBase, UseFont.charNum) ' Delete All 96 Characters
IF UseFont.fontHandle THEN DeleteObject(UseFont.fontHandle) ' The Win32 font handle
END IF
END SUB
SUB BBP_DrawGLText (BYVAL glWnd AS LONG, UseFont AS ZGLFONT, BYVAL x AS LONG, BYVAL y AS LONG, zTxt AS ASCIIZ, BYVAL ARGB AS LONG)
LOCAL rc AS RECT, A, R, G, B AS BYTE, cAlpha, cRed, cGreen, cBlue AS SINGLE, WasTexture, WasLighting AS LONG
CALL GetClientRect(glWnd, rc)
WasTexture = glIsEnabled(%GL_TEXTURE_2D)
IF WasTexture THEN CALL glDisable(%GL_TEXTURE_2D) ' Turn off textures, didn't want our text textured
WasLighting = glIsEnabled(%GL_LIGHTING)
IF WasLighting THEN CALL glDisable(%GL_LIGHTING) ' Disable Lighting
CALL glMatrixMode(%GL_PROJECTION)
CALL glPushMatrix()
CALL glLoadIdentity()
CALL glOrtho(0.0, rc.nRight, 0.0, rc.nBottom, -1.0, 1.0)
CALL glMatrixMode(%GL_MODELVIEW)
CALL glPushMatrix()
CALL glLoadIdentity()
' Set color
CALL BBP_SplitColorARGB(ARGB, A, R, G, B)
cAlpha = A + 1: cRed = R + 1: cGreen = G + 1: cBlue = B + 1
CALL glColor3f(cRed / 256, cGreen / 256, cBlue / 256)
' Set X,Y location
CALL glRasterPos2i(x, rc.nBottom - (UseFont.fontHeight - 4) - y)
' Draw the text
CALL glPushAttrib(%GL_LIST_BIT) ' Pushes The Display List Bits
CALL glListBase(UseFont.fontBase - UseFont.charStart)' Sets The Base Character to 0
CALL glCallLists(LEN(zTxt), %GL_UNSIGNED_BYTE, zTxt) ' Draws The Display List Text
CALL glPopAttrib() ' Pops The Display List Bits
CALL glPopMatrix()
CALL glMatrixMode(%GL_PROJECTION)
CALL glPopMatrix()
CALL glMatrixMode(%GL_MODELVIEW)
IF WasTexture THEN CALL glEnable(%GL_TEXTURE_2D) ' Enable texture mode
IF WasLighting THEN CALL glEnable(%GL_LIGHTING) ' Enable Lighting
CALL glColor3f(1, 1, 1) ' Back to default color
END SUB
#ENDIF