-
Notifications
You must be signed in to change notification settings - Fork 0
/
Window.cpp
38 lines (30 loc) · 1.07 KB
/
Window.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
#include "Window.h"
#include "Input.h"
void Window::Init(const std::string& name, int width, int height, unsigned int flags)
{
// Not specifying a monitor
GLFWmonitor* monitor = nullptr;
// Setting the width and height of the window
this->_width = width;
this->_height = height;
// Applying various window flags
if (flags & WindowFlag::HIDDEN)
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
if (flags & WindowFlag::FULLSCREEN)
monitor = glfwGetPrimaryMonitor();
if (flags & WindowFlag::RESIZABLE)
glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE);
// Creating the window
this->_window = glfwCreateWindow(width, height, name.c_str(), monitor, nullptr);
// Setting the current context to the new window
glfwMakeContextCurrent(this->_window);
// Creating an input manager using the new window
this->_inputManager = new InputManager;
this->_inputManager->Init(this);
}
void Window::Destroy()
{
// Garbage collecting window and input manager
this->_inputManager->Destroy();
glfwDestroyWindow(this->_window);
}