#include #include "rendering/wrapper/Window.h" Window::Window(const WindowSize& size, const char* windowName) : window(nullptr) { glfwDefaultWindowHints(); glfwWindowHint(GLFW_VISIBLE, 0); glfwWindowHint(GLFW_RESIZABLE, 1); glfwWindowHint(GLFW_DECORATED, 0); glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); window = glfwCreateWindow(size.width, size.height, windowName, glfwGetPrimaryMonitor(), nullptr); if(window == nullptr) { std::cout << "could not create window\n"; return; } glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN); glfwMakeContextCurrent(window); glfwSwapInterval(1); glfwSetWindowUserPointer(window, this); } Window::~Window() { if(window != nullptr) { glfwDestroyWindow(window); } } bool Window::hasError() const { return window == nullptr; } void Window::show() { glfwShowWindow(window); } bool Window::shouldClose() const { return glfwWindowShouldClose(window); } void Window::swapBuffers() { glfwSwapBuffers(window); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } void Window::setFramebufferSizeCallback(GLFWframebuffersizefun f) { glfwSetFramebufferSizeCallback(window, f); } void Window::setKeyCallback(GLFWkeyfun f) { glfwSetKeyCallback(window, f); } void Window::setMouseButtonCallback(GLFWmousebuttonfun f) { glfwSetMouseButtonCallback(window, f); } void Window::setCursorPosCallback(GLFWcursorposfun f) { glfwSetCursorPosCallback(window, f); }