-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathButton.cpp
63 lines (56 loc) · 1.36 KB
/
Button.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
#include "Button.hpp"
Button::Button(int Px, int Py, int Pz, int Rx,
int Ry, int Rz, std::string const &path)
: AObject(Px, Py, Pz, Rx, Ry ,Rz)
{
_path = path;
}
bool Button::initialize()
{
_speed = 10.0f;
_pos = 0;
if (_texture.load(_path) == false)
return (false);
// back side
_geometry.pushVertex(glm::vec3(1, -2, -2));
_geometry.pushVertex(glm::vec3(1, 2, -2));
_geometry.pushVertex(glm::vec3(-1, 2, -2));
_geometry.pushVertex(glm::vec3(-1, -2, -2));
_geometry.pushUv(glm::vec2(0.0f, 0.0f));
_geometry.pushUv(glm::vec2(1.0f, 0.0f));
_geometry.pushUv(glm::vec2(1.0f, 1.0f));
_geometry.pushUv(glm::vec2(0.0f, 1.0f));
_geometry.build();
return (true);
}
void Button::update(gdl::Clock const &clock, gdl::Input &input)
{
static_cast<void>(clock);
static_cast<void>(input);
/* if (input.getKey(SDLK_UP))
{
if (_pos == 0)
_pos = 3;
else
_pos -= 1;
translate(glm::vec3(-1, 0, 0) * static_cast<float>(clock.getElapsed()) * _speed);
}
if (input.getKey(SDLK_DOWN))
{
if (_pos == 3)
_pos = 0;
else
_pos += 1;
translate(glm::vec3(1, 0, 0) * static_cast<float>(clock.getElapsed()) * _speed);
}*/
}
void Button::draw(gdl::AShader &shader, gdl::Clock const &clock)
{
static_cast<void>(clock);
_texture.bind();
_geometry.draw(shader, getTransformation(), GL_QUADS);
}
char Button::getLetter() const
{
return _letter;
}