-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCLS_Line.cpp
More file actions
82 lines (55 loc) · 1.48 KB
/
CLS_Line.cpp
File metadata and controls
82 lines (55 loc) · 1.48 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
73
74
75
76
77
78
79
80
81
82
#include "CLS_Line.h"
#include "glm\gtc\matrix_transform.hpp"
CLS_Line::CLS_Line()
{
this->setType(LINE);
}
CLS_Line::~CLS_Line()
{
}
void CLS_Line::draw(GLuint shaderProgram)
{
GLuint modelMatrixLoc = glGetUniformLocation(shaderProgram, "modelMatrix");
GLuint colorLoc = glGetUniformLocation(shaderProgram, "objectColor");
glm::mat4 transMat = glm::translate(glm::mat4(1.0f), glm::vec3(this->getLocation().x, this->getLocation().y, 0.0f));
glm::mat4 scaleMat = glm::scale(glm::mat4(1.0f), glm::vec3(this->getScale(), this->getScale(), this->getScale()));
glm::mat4 modelMat = transMat * scaleMat;
glm::vec4 color;
#ifdef SHOW_COLLISION_HIGHLIGHT
if (this->getIsColliding())
{
color = glm::vec4(1.0f, 0.0f, 0.0f, 1.0f);
}
else
{
color = this->getColor();
}
#else
color = this->getColor();
#endif
glUniform4fv(colorLoc, 1, (GLfloat*)&color);
glUniformMatrix4fv(modelMatrixLoc, 1, GL_FALSE, &modelMat[0][0]);
glBegin(GL_LINES);
glColor3f(0, 1, 1);
glVertex2f(this->point1.x, this->point1.y);
glVertex2f(this->point2.x, this->point2.y);
glEnd();
color = glm::vec4(1.0f, 1.0f, 1.0f, 1.0f);
glUniform4fv(colorLoc, 1, (GLfloat*)&color);
}
void CLS_Line::setPointOne(double p1, double p2, double p3)
{
this->point1 = glm::vec3(p1, p2, p3);
}
void CLS_Line::setPointTwo(double p1, double p2, double p3)
{
this->point2 = glm::vec3(p1, p2, p3);
}
glm::vec3 CLS_Line::getPointOne()
{
return this->point1;
}
glm::vec3 CLS_Line::getPointTwo()
{
return this->point2;
}