1 #pragma once 2 3 #include <mbgl/gl/extension.hpp> 4 #include <mbgl/gl/gl.hpp> 5 6 #define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242 7 #define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243 8 #define GL_DEBUG_CALLBACK_FUNCTION 0x8244 9 #define GL_DEBUG_CALLBACK_USER_PARAM 0x8245 10 #define GL_DEBUG_SOURCE_API 0x8246 11 #define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247 12 #define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248 13 #define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249 14 #define GL_DEBUG_SOURCE_APPLICATION 0x824A 15 #define GL_DEBUG_SOURCE_OTHER 0x824B 16 #define GL_DEBUG_TYPE_ERROR 0x824C 17 #define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D 18 #define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E 19 #define GL_DEBUG_TYPE_PORTABILITY 0x824F 20 #define GL_DEBUG_TYPE_PERFORMANCE 0x8250 21 #define GL_DEBUG_TYPE_OTHER 0x8251 22 #define GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143 23 #define GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144 24 #define GL_DEBUG_LOGGED_MESSAGES 0x9145 25 #define GL_DEBUG_SEVERITY_HIGH 0x9146 26 #define GL_DEBUG_SEVERITY_MEDIUM 0x9147 27 #define GL_DEBUG_SEVERITY_LOW 0x9148 28 #define GL_DEBUG_TYPE_MARKER 0x8268 29 #define GL_DEBUG_TYPE_PUSH_GROUP 0x8269 30 #define GL_DEBUG_TYPE_POP_GROUP 0x826A 31 #define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B 32 #define GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C 33 #define GL_DEBUG_GROUP_STACK_DEPTH 0x826D 34 #define GL_BUFFER 0x82E0 35 #define GL_SHADER 0x82E1 36 #define GL_PROGRAM 0x82E2 37 #define GL_QUERY 0x82E3 38 #define GL_PROGRAM_PIPELINE 0x82E4 39 #define GL_SAMPLER 0x82E6 40 #define GL_MAX_LABEL_LENGTH 0x82E8 41 #define GL_DEBUG_OUTPUT 0x92E0 42 #define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002 43 #define GL_DISPLAY_LIST 0x82E7 44 #define GL_VERTEX_ARRAY 0x8074 45 #define GL_TRANSFORM_FEEDBACK 0x8E22 46 #define GL_TEXTURE 0x1702 47 #define GL_RENDERBUFFER 0x8D41 48 #define GL_FRAMEBUFFER 0x8D40 49 50 namespace mbgl { 51 namespace gl { 52 namespace extension { 53 54 class Debugging { 55 public: 56 using Callback = void (*)(GLenum source, 57 GLenum type, 58 GLuint id, 59 GLenum severity, 60 GLsizei length, 61 const GLchar* message, 62 const void* userParam); 63 64 static void DebugCallback(GLenum source, 65 GLenum type, 66 GLuint id, 67 GLenum severity, 68 GLsizei /* length */, 69 const GLchar* message, 70 const void* /* userParam */); 71 72 template <typename Fn> Debugging(const Fn & loadExtension)73 Debugging(const Fn& loadExtension) 74 : 75 #ifndef NDEBUG 76 pushDebugGroup( 77 loadExtension({ { "GL_KHR_debug", "glPushDebugGroup" } })), 78 popDebugGroup( 79 loadExtension({ { "GL_KHR_debug", "glPopDebugGroup" } })), 80 pushGroupMarkerEXT( 81 loadExtension({ { "GL_EXT_debug_marker", "glPushGroupMarkerEXT" } })), 82 popGroupMarkerEXT( 83 loadExtension({ { "GL_EXT_debug_marker", "glPopGroupMarkerEXT" } })), 84 #endif 85 debugMessageControl( 86 loadExtension({ { "GL_KHR_debug", "glDebugMessageControl" }, 87 { "GL_ARB_debug_output", "glDebugMessageControlARB" } })), 88 debugMessageCallback( 89 loadExtension({ { "GL_KHR_debug", "glDebugMessageCallback" }, 90 { "GL_ARB_debug_output", "glDebugMessageCallbackARB" } })) { 91 } 92 93 #ifndef NDEBUG 94 const ExtensionFunction<void(GLenum source, 95 GLuint id, 96 GLsizei length, 97 const GLchar* message)> pushDebugGroup; 98 99 const ExtensionFunction<void()> popDebugGroup; 100 101 const ExtensionFunction<void(GLsizei length, 102 const GLchar* marker)> pushGroupMarkerEXT; 103 104 const ExtensionFunction<void()> popGroupMarkerEXT; 105 #endif 106 107 const ExtensionFunction<void(GLenum source, 108 GLenum type, 109 GLenum severity, 110 GLsizei count, 111 const GLuint* ids, 112 GLboolean enabled)> debugMessageControl; 113 114 const ExtensionFunction<void(Callback callback, 115 const void* userParam)> debugMessageCallback; 116 }; 117 118 } // namespace extension 119 } // namespace gl 120 } // namespace mbgl 121