-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwindow.cpp
More file actions
37 lines (25 loc) · 961 Bytes
/
window.cpp
File metadata and controls
37 lines (25 loc) · 961 Bytes
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
#include "window.hpp"
void windowSizeCallback(GLFWwindow *win, int w, int h) {
glfwSetWindowSize(win, w, h);
}
void windowPosCallback(GLFWwindow *win, int x, int y) {
glfwSetWindowPos(win, x, y);
}
Window::Window(void) : width(800), height(600) {}
Window::Window(const uint32_t &w, const uint32_t &h) : width(w), height(h) {}
void Window::initWin(void) {
glfwInit();
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE);
window = glfwCreateWindow(width, height, "Application", nullptr, nullptr);
glfwSetWindowSizeCallback(window, windowSizeCallback);
glfwSetWindowPosCallback(window, windowPosCallback);
}
void Window::processInput(void) {
if(glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
glfwSetWindowShouldClose(window, true);
}
void Window::destWin(void) {
glfwDestroyWindow(window);
glfwTerminate();
}