-
Notifications
You must be signed in to change notification settings - Fork 0
/
font.cpp
45 lines (34 loc) · 958 Bytes
/
font.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "font.h"
Font::Font ()
{
}
Font::~Font ()
{
free ();
}
void Font::write (float xpos, float ypos, const char *string)
{
glRasterPos2f (xpos, ypos);
glPushAttrib (GL_LIST_BIT);
glListBase (fontbase - 32);
glCallLists ((GLsizei) strlen (string), GL_UNSIGNED_BYTE, string);
glPopAttrib ();
}
void Font::init (int height, char *font_name, Window win)
{
init (height, 100, font_name, win);
}
void Font::init (int height, int weight, char *font_name, Window win)
{
HFONT font, hfont;
fontbase = glGenLists (96);
font = CreateFont (height, 0, 0, 0, weight, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, FF_DONTCARE|DEFAULT_PITCH, font_name);
HDC myHDC = win.getDC();
hfont = (HFONT) SelectObject (myHDC, font);
wglUseFontBitmaps (myHDC, 32, 96, fontbase);
SelectObject (myHDC, hfont);
}
void Font::free ()
{
glDeleteLists (fontbase, 96);
}