Changeset View
Changeset View
Standalone View
Standalone View
source/lib/ogl.cpp
/* Copyright (C) 2017 Wildfire Games. | /* Copyright (C) 2021 Wildfire Games. | ||||
* | * | ||||
* Permission is hereby granted, free of charge, to any person obtaining | * Permission is hereby granted, free of charge, to any person obtaining | ||||
* a copy of this software and associated documentation files (the | * a copy of this software and associated documentation files (the | ||||
Context not available. | |||||
} | } | ||||
void APIENTRY ogl_OnDebugMessage(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei UNUSED(length), const GLchar* message, const void* UNUSED(user_param)) | |||||
vladislavbelov: Space. | |||||
{ | |||||
std::string str_source = "unknown"; | |||||
std::string str_type = "unknown"; | |||||
std::string str_severity = "unknown"; | |||||
Not Done Inline ActionsMaybe CC, Idr snake case for lib? vladislavbelov: Maybe CC, Idr snake case for `lib`? | |||||
switch (source) | |||||
{ | |||||
case GL_DEBUG_SOURCE_API: | |||||
str_source = "the API"; | |||||
break; | |||||
case GL_DEBUG_SOURCE_WINDOW_SYSTEM: | |||||
str_source = "the window system"; | |||||
break; | |||||
case GL_DEBUG_SOURCE_SHADER_COMPILER: | |||||
str_source = "the shader compiler"; | |||||
break; | |||||
case GL_DEBUG_SOURCE_THIRD_PARTY: | |||||
str_source = "a third party"; | |||||
break; | |||||
case GL_DEBUG_SOURCE_APPLICATION: | |||||
str_source = "the application"; | |||||
break; | |||||
case GL_DEBUG_SOURCE_OTHER: | |||||
str_source = "somewhere"; | |||||
break; | |||||
} | |||||
switch (type) | |||||
{ | |||||
case GL_DEBUG_TYPE_ERROR: | |||||
str_type = "error"; | |||||
break; | |||||
case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR: | |||||
str_type = "deprecated behaviour"; | |||||
break; | |||||
case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR: | |||||
str_type = "undefined behaviour"; | |||||
break; | |||||
case GL_DEBUG_TYPE_PORTABILITY: | |||||
str_type = "portability"; | |||||
break; | |||||
case GL_DEBUG_TYPE_PERFORMANCE: | |||||
str_type = "performance"; | |||||
break; | |||||
case GL_DEBUG_TYPE_OTHER: | |||||
str_type = "other"; | |||||
break; | |||||
case GL_DEBUG_TYPE_MARKER: | |||||
str_type = "marker"; | |||||
break; | |||||
case GL_DEBUG_TYPE_PUSH_GROUP: | |||||
str_type = "push group"; | |||||
break; | |||||
case GL_DEBUG_TYPE_POP_GROUP: | |||||
str_type = "pop group"; | |||||
break; | |||||
} | |||||
switch (severity) | |||||
{ | |||||
case GL_DEBUG_SEVERITY_HIGH: | |||||
str_severity = "high"; | |||||
break; | |||||
case GL_DEBUG_SEVERITY_MEDIUM: | |||||
str_severity = "medium"; | |||||
break; | |||||
case GL_DEBUG_SEVERITY_LOW: | |||||
str_severity = "low"; | |||||
break; | |||||
case GL_DEBUG_SEVERITY_NOTIFICATION: | |||||
str_severity = "notification"; | |||||
break; | |||||
} | |||||
Not Done Inline ActionsMight use a macro to reduce the code duplication. vladislavbelov: Might use a macro to reduce the code duplication. | |||||
debug_printf("OpenGL | %s: %s id %d: %s\n", str_severity.c_str(), str_type.c_str(), str_source.c_str(), id, message); | |||||
Not Done Inline ActionsI suppose it won't be visible on Windows. But I might fix it later. vladislavbelov: I suppose it won't be visible on Windows. But I might fix it later. | |||||
} | |||||
// ignore and reset the specified error (as returned by glGetError). | // ignore and reset the specified error (as returned by glGetError). | ||||
// any other errors that have occurred are reported as ogl_WarnIfError would. | // any other errors that have occurred are reported as ogl_WarnIfError would. | ||||
// | // | ||||
Context not available. | |||||
#if !CONFIG2_GLES | #if !CONFIG2_GLES | ||||
glGetIntegerv(GL_MAX_TEXTURE_UNITS, &ogl_max_tex_units); | glGetIntegerv(GL_MAX_TEXTURE_UNITS, &ogl_max_tex_units); | ||||
#endif | #endif | ||||
#ifndef NDEBUG | |||||
#if CONFIG2_GLES | |||||
bool is_core = ogl_HaveVersion("3.2"); | |||||
#else | |||||
bool is_core = ogl_HaveVersion("4.3"); | |||||
#endif | |||||
if (is_core || ogl_HaveExtension("GL_KHR_debug")) | |||||
{ | |||||
glEnable(GL_DEBUG_OUTPUT); | |||||
pglDebugMessageCallbackKHR(ogl_OnDebugMessage, nullptr); | |||||
// Filter out our own debug group messages | |||||
GLuint id = 0x0ad; | |||||
pglDebugMessageControlKHR(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_PUSH_GROUP, GL_DONT_CARE, 1, &id, GL_FALSE); | |||||
pglDebugMessageControlKHR(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_POP_GROUP, GL_DONT_CARE, 1, &id, GL_FALSE); | |||||
} | |||||
#endif | |||||
} | } | ||||
Context not available. |
Wildfire Games · Phabricator
Space.