-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcLabel.cpp
93 lines (82 loc) · 1.34 KB
/
cLabel.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include "cLabel.h"
cLabel::cLabel()
{
font = NULL;
x = 0;
y = 0;
r = 0;
g = 0;
b = 0;
}
cLabel::cLabel(void *f, const int *pos_col)
{
font = f;
x = pos_col[0];
y = pos_col[1];
r = pos_col[2];
g = pos_col[3];
b = pos_col[4];
}
cLabel::cLabel(const cLabel& lab)
{
x = lab.x;
y = lab.y;
r = lab.r;
g = lab.g;
b = lab.b;
font = lab.font;
}
cLabel& cLabel::operator =(const cLabel &lab)
{
if (this == &lab) return *this;
if (&lab != NULL) {
x = lab.x;
y = lab.y;
r = lab.r;
g = lab.g;
b = lab.b;
font = lab.font;
}
return *this;
}
cLabel::~cLabel()
{
font = NULL;
x = 0;
y = 0;
r = 0;
g = 0;
b = 0;
}
void cLabel::OutputLabel(char *str)
{
glDisable(GL_LIGHTING);
glDisable(GL_TEXTURE_2D);//îòêëþ÷àåì òåêñòóðó, ÷òîáû âêëþ÷èòü öâåò
glMatrixMode(GL_PROJECTION);//óñòàíîâêà ìàòðèöû ïðîåêöèè äëÿ âûâîäà òåêñòà
glPushMatrix();
glLoadIdentity();
gluOrtho2D(0, WinWidth, 0, WinHeight);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glColor3f(r, g, b);
//Óñòàíîâêà ïîçèöèè äëÿ âûâîäà ïîäïèñè
glRasterPos2f(x, y);
//Âûâîä ïîäïèñè
PrintLabel(str);
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glEnable(GL_TEXTURE_2D);
glEnable(GL_LIGHTING);
}
void cLabel::PrintLabel(char *tex)
{
char *c = tex;
while (*c)
{
glutBitmapCharacter(font, *c);
c++;
}
}