-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmodel.cpp
More file actions
72 lines (52 loc) · 1.61 KB
/
model.cpp
File metadata and controls
72 lines (52 loc) · 1.61 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 "model.hpp"
#include <SDL3/SDL_opengl.h>
model::model()
{
mMatrix.Identity();
mIsLineLoop = false;
}
model::~model()
{
}
void model::draw(const vector::pen& pen)
{
if (mIsLineLoop) {
glColor4f(pen.r, pen.g, pen.b, pen.a);
glLineWidth(pen.lineRadius * .3);
glBegin(GL_LINE_STRIP);
Point3d from = mVertexList[mEdgeList[0].from];
mMatrix.TransformVertex(from, &from);
glVertex3f(from.x, from.y, 0);
for (std::size_t i = 1; i < mEdgeList.size(); i++) {
Point3d to = mVertexList[mEdgeList[i].to];
mMatrix.TransformVertex(to, &to);
glVertex3f(to.x, to.y, 0);
}
glEnd();
} else {
glColor4f(pen.r, pen.g, pen.b, pen.a);
glLineWidth(pen.lineRadius * .3);
glBegin(GL_LINES);
for (std::size_t i = 0; i < mEdgeList.size(); i++) {
Point3d from = mVertexList[mEdgeList[i].from];
Point3d to = mVertexList[mEdgeList[i].to];
mMatrix.TransformVertex(from, &from);
mMatrix.TransformVertex(to, &to);
glVertex3f(from.x, from.y, 0);
glVertex3f(to.x, to.y, 0);
}
glEnd();
}
}
void model::emit(const vector::pen& pen)
{
glColor4f(pen.r, pen.g, pen.b, pen.a);
for (std::size_t i = 0; i < mEdgeList.size(); i++) {
Point3d from = mVertexList[mEdgeList[i].from];
Point3d to = mVertexList[mEdgeList[i].to];
mMatrix.TransformVertex(from, &from);
mMatrix.TransformVertex(to, &to);
glVertex3f(from.x, from.y, 0);
glVertex3f(to.x, to.y, 0);
}
}