-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCOverlayText.cpp
More file actions
72 lines (64 loc) · 1.38 KB
/
COverlayText.cpp
File metadata and controls
72 lines (64 loc) · 1.38 KB
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
#include "COverlayText.h"
COverlayText::COverlayText(const std::string& text, void* font, const vec3& position, bool is3d, const vec3& color) :
CObject(0, position), Text(text), Font(font), Is3D(is3d), Color(color)
{
}
COverlayText::~COverlayText()
{
}
void COverlayText::render()
{
GLboolean alpha = glIsEnabled(GL_ALPHA_TEST);
GLboolean ztest = glIsEnabled(GL_DEPTH_TEST);
GLboolean light = glIsEnabled(GL_LIGHTING);
GLboolean bcull = glIsEnabled(GL_CULL_FACE);
if (alpha)
glDisable(GL_ALPHA_TEST);
if (ztest)
;//glDisable(GL_DEPTH_TEST);
if (light)
glDisable(GL_LIGHTING);
if (bcull)
glDisable(GL_CULL_FACE);
if (Is3D)
{
glPushMatrix();
transform();
}
else
{
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
int w = glutGet(GLUT_WINDOW_WIDTH);
int h = glutGet(GLUT_WINDOW_HEIGHT);
gluOrtho2D(0, 1, 0, 1);
}
vec3 pos = getPosition();
glBindTexture(GL_TEXTURE_2D, 0);
glRasterPos2f(pos.X, pos.Y);
glColor3f(Color.X, Color.Y, Color.Z);
glutBitmapString(Font, (unsigned char*) Text.c_str());
if (Is3D)
{
CObject::render();
glPopMatrix();
}
else
{
glPopMatrix();
glMatrixMode( GL_MODELVIEW );
glPopMatrix();
}
if (alpha)
glEnable(GL_ALPHA_TEST);
if (ztest)
glEnable(GL_DEPTH_TEST);
if (light)
glEnable(GL_LIGHTING);
if (bcull)
glEnable(GL_CULL_FACE);
}