-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwindow.cpp
49 lines (40 loc) · 1.13 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
39
40
41
42
43
44
45
46
47
48
49
#include "settings.h"
#include "window.h"
#include <cstdio>
#include <vector>
#define GLAD_GL_IMPLEMENTATION
#include <glad/gl.h>
#include <GLFW/glfw3.h>
void error_callback(int error, const char* description)
{
fprintf(stderr, "Error to: %s\n", description);
}
static GLFWwindow* window = NULL;
bool create_window(void){
glfwSetErrorCallback(error_callback);
if (!glfwInit()){
fprintf(stderr, "Failed to initialize GLFW\n");
return false;
}
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_VISIBLE, GL_FALSE);
window = glfwCreateWindow(WINDOW_WIDTH, WINDOW_HEIGHT, "Ray-Marching", NULL, NULL);
if (!window){
fprintf(stderr, "Failed to create GLFW window\n");
glfwTerminate();
return false;
}
glfwMakeContextCurrent(window);
if(!gladLoadGL(glfwGetProcAddress)){
fprintf(stderr, "Failed to initialize GLAD\n");
glfwTerminate();
return false;
}
return true;
}
void destroy_window(void) {
glfwDestroyWindow(window);
glfwTerminate();
}