1.
open project > settings (alternativly u can press Alt+F7) and open the "Link" tab. in "object/library modules" u add:
Code:
OpenGL32.lib GLaux.lib GLu32.lib
click ok, we are done here.
2.
open your client.cpp and go to the top. where the vars are declared u add
Code:
HDC hDC=NULL;
GLuint base;
3.
now we have to add a function to build the ogl font list by adding this function (i recommend it near the other DrawHudString(..) functions):
Code:
GLvoid BuildFont(GLvoid)
{
hDC=wglGetCurrentDC();
HFONT font;
HFONT oldfont;
base = glGenLists(96);
font = CreateFont( -10 , // font size e.g. 10, 12 but with a minus!
0, // font width (0 is autowidth, using a value will set the width for each character)
0,
0,
FW_MEDIUM, // this is the style, plz see above
FALSE,
FALSE,
FALSE,
ANSI_CHARSET,
OUT_TT_PRECIS,
CLIP_DEFAULT_PRECIS,
ANTIALIASED_QUALITY, // font quality, see above
FF_DONTCARE|DEFAULT_PITCH,
"Verdana"); // font type, just add the name here, e.g. Arial, Tahoma, ... every font u have installed is possible
oldfont = (HFONT)SelectObject(hDC, font);
wglUseFontBitmaps(hDC, 32, 96, base);
SelectObject(hDC, oldfont);
DeleteObject(font);
}
the font style can be:
Code:
FW_THIN
FW_EXTRALIGHT
FW_LIGHT
FW_NORMAL
FW_MEDIUM
FW_SEMIBOLD
FW_BOLD
FW_EXTRABOLD
FW_HEAVY
th quality can be:
Code:
DEFAULT_QUALITY
DRAFT_QUALITY
PROOF_QUALITY
NONANTIALIASED_QUALITY
ANTIALIASED_QUALITY
(all following functions go above)
4.
this function we need to delete the font in memory:
Code:
GLvoid KillFont(GLvoid)
{
glDeleteLists(base, 96);
}
5.
now we add the print function:
Code:
GLvoid glPrint(const char *fmt, ...)
{
char text[256];
va_list ap;
if (fmt == NULL)
return;
va_start(ap, fmt);
vsprintf(text, fmt, ap);
va_end(ap);
glPushAttrib(GL_LIST_BIT);
glListBase(base - 32);
glCallLists(strlen(text), GL_UNSIGNED_BYTE, text);
glPopAttrib();
}
6.
... and the function to draw the text like we use AdminMod font when drawing a text:
Code:
void DrawOglText(int x, int y, int r, int g, int b, char *text)
{
float fr = (float) r/255.0f;
float fg = (float) g/255.0f;
float fb = (float) b/255.0f;
glDisable(GL_TEXTURE_2D);
glColor4f(fr,fg,fb,1.0f);
glRasterPos2f(x,y);
glPrint(text);
glEnable(GL_TEXTURE_2D);
}
7.
to draw a text we just use this function same way we use DrawHudString:
Code:
DrawOglFont(cvar.test_x,cvar.test_y,120,190,250,"This is my OpenGL text!");
int Initialize (cl_enginefunc_t *pEnginefuncs, int iVersion)
{
...
if(firstInitialize)
{
...
BuildFont();
...
}
}