-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuttons.cpp
30 lines (22 loc) · 944 Bytes
/
buttons.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
#include "buttons.h"
#include "textures.h"
namespace game {
/* Close Button */
CloseButtonGuiElem::CloseButtonGuiElem(Geometry* geom, Shader* shader, GLFWwindow* window) : ClickableGuiElem(geom, shader, window, glm::vec2(1, 1), GameObject::textures.GetTexture("gui_close_button")) {
type_ = ObjType::CLICKABLE_GUI_ELEM;
// Set Position to top right corner
SetPosition(glm::vec3(0.95f, 0.95f, 0.0f));
SetScale(glm::vec2(0.1, 0.1));
}
void CloseButtonGuiElem::Update(double delta_time, GuiState* gui_state) {
ProcessInput(gui_state);
ClickableGuiElem::Update(delta_time, gui_state);
}
void CloseButtonGuiElem::ProcessInput(GuiState* gui_state) {
// If the user presses left click on the button, close the window
if (hover_ && glfwGetMouseButton(window_, GLFW_MOUSE_BUTTON_LEFT) == GLFW_PRESS) {
glfwSetWindowShouldClose(window_, true);
}
}
/* Other Button Class Implementations Go Here: */
} // namespace game