Conquer Space 0.0.0
A space themed grand strategy game set in the near future, with realistic orbital mechanics, and an emphasis on economics and politics.
glfwdebug.h
Go to the documentation of this file.
1/* Conquer Space
2* Copyright (C) 2021 Conquer Space
3*
4* This program is free software: you can redistribute it and/or modify
5* it under the terms of the GNU General Public License as published by
6* the Free Software Foundation, either version 3 of the License, or
7* (at your option) any later version.
8*
9* This program is distributed in the hope that it will be useful,
10* but WITHOUT ANY WARRANTY; without even the implied warranty of
11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12* GNU General Public License for more details.
13*
14* You should have received a copy of the GNU General Public License
15* along with this program. If not, see <https://www.gnu.org/licenses/>.
16*/
17#pragma once
18
19#include <glad/glad.h>
20
21#include "engine/enginelogger.h"
22
23namespace cqsp::engine {
24const inline char* ParseType(GLenum type) {
25 switch (type) {
26 case GL_DEBUG_TYPE_ERROR:
27 return ("Error");
28 case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR:
29 return ("Deprecated Behaviour");
30 case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR:
31 return ("Undefined Behaviour");
32 case GL_DEBUG_TYPE_PORTABILITY:
33 return ("Portability");
34 case GL_DEBUG_TYPE_PERFORMANCE:
35 return ("Performance");
36 case GL_DEBUG_TYPE_MARKER:
37 return ("Marker");
38 case GL_DEBUG_TYPE_PUSH_GROUP:
39 return ("Push Group");
40 case GL_DEBUG_TYPE_POP_GROUP:
41 return ("Pop Group");
42 case GL_DEBUG_TYPE_OTHER:
43 default:
44 return ("Other");
45 }
46}
47
48const inline char* ParseSeverity(GLenum severity) {
49 switch (severity) {
50 case GL_DEBUG_SEVERITY_HIGH:
51 return ("high");
52 case GL_DEBUG_SEVERITY_MEDIUM:
53 return ("medium");
54 case GL_DEBUG_SEVERITY_LOW:
55 return ("low");
56 case GL_DEBUG_SEVERITY_NOTIFICATION:
57 default:
58 return ("notification");
59 }
60}
61
62const inline char* ParseSource(GLenum source) {
63 switch (source) {
64 case GL_DEBUG_SOURCE_API:
65 return ("API");
66 case GL_DEBUG_SOURCE_WINDOW_SYSTEM:
67 return ("Window System");
68 case GL_DEBUG_SOURCE_SHADER_COMPILER:
69 return ("Shader Compiler");
70 case GL_DEBUG_SOURCE_THIRD_PARTY:
71 return ("Third Party");
72 case GL_DEBUG_SOURCE_APPLICATION:
73 return ("Application");
74 case GL_DEBUG_SOURCE_OTHER:
75 default:
76 return ("Other");
77 }
78}
79
80void inline APIENTRY glDebugOutput(GLenum source, GLenum type, unsigned int id, GLenum severity, GLsizei length,
81 const char* message, const void* userParam) {
82 if (id == 131169 || id == 131185 || id == 131218 || id == 131204)
83 return; // ignore these non-significant error codes
84
85 ENGINE_LOG_INFO("{} message from {} ({}:{}): {}", ParseType(type), ParseSource(source), ParseSeverity(severity), id,
86 message);
87}
88} // namespace cqsp::engine
#define ENGINE_LOG_INFO(...)
Definition: enginelogger.h:29
Definition: application.cpp:54
void APIENTRY glDebugOutput(GLenum source, GLenum type, unsigned int id, GLenum severity, GLsizei length, const char *message, const void *userParam)
Definition: glfwdebug.h:80
const char * ParseType(GLenum type)
Definition: glfwdebug.h:24
const char * ParseSeverity(GLenum severity)
Definition: glfwdebug.h:48
const char * ParseSource(GLenum source)
Definition: glfwdebug.h:62