-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwindow.cpp
53 lines (38 loc) · 890 Bytes
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "window.h"
using namespace std;
Window::Window(const char* name, int* width, int* height)
{
gWindow = NULL;
if (!glfwInit())
{
const char* err;
glfwGetError(&err);
printf("GLFW failed to initialize: %s\n", err);
gWindow = NULL;
}
// Start OpenGL for GLFW
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
// Create window
gWindow = glfwCreateWindow(*width, *height, name, NULL, NULL);
glfwMakeContextCurrent(gWindow);
this->Initialize();
}
Window::~Window()
{
glfwDestroyWindow(gWindow);
gWindow = NULL;
glfwTerminate();
}
bool Window::Initialize()
{
// Start SDL
if (glewInit() != GLEW_OK) { exit(EXIT_FAILURE); }
glfwSwapInterval(1);
// Any other Window Initialization goes here
return true;
}
void Window::Swap()
{
glfwSwapBuffers(gWindow);
}