-
Notifications
You must be signed in to change notification settings - Fork 0
/
Window.h
84 lines (75 loc) · 1.85 KB
/
Window.h
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#pragma once
#include <glad/glad.h>
#include <GLFW/glfw3.h>
class Window {
public:
Window();
~Window();
int getWidth() const { return width; };
int getHeight() const { return height; };
inline bool isOpen() { return !glfwWindowShouldClose(window); };
void swapBuffers();
GLFWwindow* window;
friend class Camera;
private:
int width = 800, height = 600;
const std::string& title = "Portals";
double prevTime = glfwGetTime();
unsigned int framesPassed = 0;
};
inline void APIENTRY glDebugCallback(GLenum source, GLenum mType, GLuint id, GLenum severity, GLsizei length,
const GLchar* message, const void* userParam) {
std::string src;
switch(source) {
case GL_DEBUG_SOURCE_API:
src = "Windows";
break;
case GL_DEBUG_SOURCE_SHADER_COMPILER:
src = "Shader Compiler";
break;
case GL_DEBUG_SOURCE_THIRD_PARTY:
src = "Third Party";
break;
case GL_DEBUG_SOURCE_APPLICATION:
src = "Application";
break;
case GL_DEBUG_SOURCE_OTHER:
src = "Other";
break;
}
std::string type;
switch(mType) {
case GL_DEBUG_TYPE_ERROR:
type = "Error";
break;
case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR:
type = "Deprecated Behavior";
break;
case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR:
type = "Undefined Behavior";
break;
case GL_DEBUG_TYPE_PORTABILITY:
type = "Portability Error";
break;
case GL_DEBUG_TYPE_PERFORMANCE:
type = "Performance Error";
break;
case GL_DEBUG_TYPE_OTHER:
type = "Other Message";
break;
}
switch(severity) {
case GL_DEBUG_SEVERITY_NOTIFICATION:
SPDLOG_INFO("GL NOTIFICATION - {} {}: {}", src, type, message);
break;
case GL_DEBUG_SEVERITY_LOW:
SPDLOG_WARN("GL LOW - {} {}: {}", src, type, message);
break;
case GL_DEBUG_SEVERITY_MEDIUM:
SPDLOG_ERROR("GL MEDIUM - {} {}: {}", src, type, message);
break;
case GL_DEBUG_SEVERITY_HIGH:
SPDLOG_CRITICAL("GL HIGH - {} {}: {}", src, type, message);
break;
}
}