SHARE
TWEET

Untitled

a guest Sep 15th, 2019 93 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const char* source_to_string(GLenum source) {
  2.     switch (source) {
  3.         case GL_DEBUG_SOURCE_API:
  4.             return "GL_DEBUG_SOURCE_API";
  5.         case GL_DEBUG_SOURCE_WINDOW_SYSTEM:
  6.             return "GL_DEBUG_SOURCE_WINDOW_SYSTEM";
  7.         case GL_DEBUG_SOURCE_SHADER_COMPILER:
  8.             return "GL_DEBUG_SOURCE_SHADER_COMPILER";
  9.         case GL_DEBUG_SOURCE_THIRD_PARTY:
  10.             return "GL_DEBUG_SOURCE_THIRD_PARTY";
  11.         case GL_DEBUG_SOURCE_APPLICATION:
  12.             return "GL_DEBUG_SOURCE_APPLICATION";
  13.         case GL_DEBUG_SOURCE_OTHER:
  14.             return "GL_DEBUG_SOURCE_OTHER";
  15.         default:
  16.             return "INVALID_SOURCE";
  17.     }
  18. }
  19.  
  20. const char* type_to_string(GLenum type) {
  21.     switch (type) {
  22.         case GL_DEBUG_TYPE_ERROR:
  23.             return "GL_DEBUG_TYPE_ERROR";
  24.         case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR:
  25.             return "GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR";
  26.         case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR:
  27.             return "GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR";
  28.         case GL_DEBUG_TYPE_PORTABILITY:
  29.             return "GL_DEBUG_TYPE_PORTABILITY";
  30.         case GL_DEBUG_TYPE_PERFORMANCE:
  31.             return "GL_DEBUG_TYPE_PERFORMANCE";
  32.         case GL_DEBUG_TYPE_MARKER:
  33.             return "GL_DEBUG_TYPE_MARKER";
  34.         case GL_DEBUG_TYPE_PUSH_GROUP:
  35.             return "GL_DEBUG_TYPE_PUSH_GROUP";
  36.         case GL_DEBUG_TYPE_POP_GROUP:
  37.             return "GL_DEBUG_TYPE_POP_GROUP";
  38.         case GL_DEBUG_TYPE_OTHER:
  39.             return "GL_DEBUG_TYPE_OTHER";
  40.         default:
  41.             return "INVALID_TYPE";
  42.     }
  43. }
  44.  
  45. const char* severity_to_string(GLenum severity) {
  46.     switch (severity) {
  47.         case GL_DEBUG_SEVERITY_LOW:
  48.             return "GL_DEBUG_SEVERITY_LOW";
  49.         case GL_DEBUG_SEVERITY_MEDIUM:
  50.             return "GL_DEBUG_SEVERITY_MEDIUM";
  51.         case GL_DEBUG_SEVERITY_HIGH:
  52.             return "GL_DEBUG_SEVERITY_HIGH";
  53.         case GL_DEBUG_SEVERITY_NOTIFICATION:
  54.             return "GL_DEBUG_SEVERITY_NOTIFICATION";
  55.         default:
  56.             return "INVALID_SEVERITY";
  57.     }
  58. }
  59.  
  60. void gl_log_func(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* userParam) {
  61.     fprintf(stdout, "source: %s, type: %s, id: %u, severity: %s, msg: %s\n",
  62.             source_to_string(source),
  63.             type_to_string(type),
  64.             id,
  65.             severity_to_string(severity),
  66.             message);
  67.     fflush(stdout);
  68. }
  69.  
  70. ...
  71. glEnable(GL_DEBUG_OUTPUT);
  72. glDebugMessageCallback(gl_log_func, 0);
  73. glDebugMessageControl( GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_NOTIFICATION, 0, 0, GL_FALSE)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top