-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathError.cpp
More file actions
71 lines (65 loc) · 2.37 KB
/
Copy pathError.cpp
File metadata and controls
71 lines (65 loc) · 2.37 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
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
#include "Error.h"
#include <iostream>
#include <cstdlib>
#include <string>
void APIENTRY debugMessageCallback(
GLenum source,
GLenum type,
GLuint id,
GLenum severity,
GLsizei length,
const GLchar *message,
const void *userParam)
{
std::string sourceString ("Unknown");
if(source == GL_DEBUG_SOURCE_API)
sourceString = "API";
else if(source == GL_DEBUG_SOURCE_WINDOW_SYSTEM)
sourceString = "Window system API";
else if(source == GL_DEBUG_SOURCE_SHADER_COMPILER)
sourceString = "Shading laguage compiler";
else if(source == GL_DEBUG_SOURCE_THIRD_PARTY)
sourceString = "Application associated with OpenGL";
else if(source == GL_DEBUG_SOURCE_APPLICATION)
sourceString = "User generated";
else if(source == GL_DEBUG_SOURCE_OTHER)
sourceString = "Other";
std::string severityString ("Unknown");
if(severity == GL_DEBUG_SEVERITY_HIGH)
severityString = "High";
else if(severity == GL_DEBUG_SEVERITY_MEDIUM)
severityString = "Medium";
else if(severity == GL_DEBUG_SEVERITY_LOW)
severityString = "Low";
else if(severity == GL_DEBUG_SEVERITY_NOTIFICATION)
severityString = "Notification";
std::string typeString ("Unknown");
if(type == GL_DEBUG_TYPE_ERROR)
typeString = "Error";
else if(type == GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR)
typeString = "Deprecated behavior";
else if(type == GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR)
typeString = "Undefined behavior";
else if(type == GL_DEBUG_TYPE_PORTABILITY)
typeString = "Portability issue";
else if(type == GL_DEBUG_TYPE_PERFORMANCE)
typeString = "Performance issue";
else if(type == GL_DEBUG_TYPE_MARKER)
typeString = "Command stream annotation";
else if(type == GL_DEBUG_TYPE_PUSH_GROUP)
typeString = "Group pushing";
else if(type == GL_DEBUG_TYPE_POP_GROUP)
typeString = "Group popping";
else if(type == GL_DEBUG_TYPE_OTHER)
typeString = "Other";
std::cerr <<
"----------------" << std::endl <<
"[OpenGL Callback Message]: " << ( type == GL_DEBUG_TYPE_ERROR ? "** CRITICAL **" : "** NON CRITICAL **" ) << std::endl <<
" source = " << sourceString << std::endl <<
" type = " << typeString << std::endl <<
" severity = " << severityString << std::endl <<
" message = " << message << std::endl << std::endl <<
"----------------" << std::endl;
if(type == GL_DEBUG_TYPE_ERROR)
std::exit(EXIT_FAILURE);
}