-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathglDraw.cpp
More file actions
57 lines (51 loc) · 1.37 KB
/
Copy pathglDraw.cpp
File metadata and controls
57 lines (51 loc) · 1.37 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
#include "glDraw.h"
void GL::SetupOrtho()
{
glPushAttrib(GL_ALL_ATTRIB_BITS);
glPushMatrix();
GLint viewport[4];
glGetIntegerv(GL_VIEWPORT, viewport);
glViewport(0, 0, viewport[2], viewport[3]);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, viewport[2], viewport[3], 0, -1, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glDisable(GL_DEPTH_TEST);
}
void GL::RestoreGL()
{
glPopMatrix();
glPopAttrib();
}
void GL::DrawFilledRect(float x, float y, float width, float height, const GLubyte color[3])
{
glColor3ub(color[0], color[1], color[2]);
glBegin(GL_QUADS);
glVertex2f(x, y);
glVertex2f(x + width, y);
glVertex2f(x + width, y + height);
glVertex2f(x, y + height);
glEnd();
}
void GL::DrawOutline(float x, float y, float width, float height, float lineWidth, const GLubyte color[3])
{
glLineWidth(lineWidth);
glBegin(GL_LINE_STRIP);
glColor3ub(color[0], color[1], color[2]);
glVertex2f(x - 0.5f, y - 0.5f);
glVertex2f(x + width + 0.5f, y - 0.5f);
glVertex2f(x + width + 0.5f, y + height + 0.5f);
glVertex2f(x - 0.5f, y + height + 0.5f);
glVertex2f(x - 0.5f, y - 0.5f);
glEnd();
}
void GL::DrawLine(float x1, float y1, float x2, float y2, const GLubyte color[3])
{
glBegin(GL_LINES);
glColor3ub(color[0], color[1], color[2]);
glVertex2f(x1, y1);
glVertex2f(x2, y2);
glEnd();
glPopAttrib();
}