-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwindowConfig.h
More file actions
44 lines (34 loc) · 1.09 KB
/
windowConfig.h
File metadata and controls
44 lines (34 loc) · 1.09 KB
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
#ifndef WINDOW_CONFIG_H
#define WINDOW_CONFIG_H
#include <stdio.h>
GLFWwindow* initWindow(string title, const int resX, const int resY, GLFWkeyfun keyFunc)
{
if(!glfwInit())
{
fprintf(stderr, "Failed to initialize GLFW\n");
return NULL;
}
glfwWindowHint(GLFW_SAMPLES, 4); // 4x antialiasing
// Open a window and create its OpenGL context
GLFWwindow* window = glfwCreateWindow(resX, resY, title.c_str(), NULL, NULL);
if(window == NULL)
{
fprintf(stderr, "Failed to open GLFW window.\n");
glfwTerminate();
return NULL;
}
glfwMakeContextCurrent(window);
glfwSetKeyCallback(window, keyFunc);
// Get info of GPU and supported OpenGL version
cout << "Renderer: " << glGetString(GL_RENDERER) << endl;
cout << "OpenGL version supported " << glGetString(GL_VERSION) << endl;
glEnable(GL_DEPTH_TEST); // Depth Testing
glDepthFunc(GL_LEQUAL);
glDisable(GL_CULL_FACE);
glCullFace(GL_BACK);
int n;
glGetIntegerv(GL_MAX_LIGHTS, &n);
cout << "Max Lights: " << n << endl;
return window;
}
#endif