]> git.lizzy.rs Git - irrlicht.git/commitdiff
Add debug handler
authornumzero <numzer0@yandex.ru>
Mon, 27 Feb 2023 17:31:51 +0000 (20:31 +0300)
committernumzero <numzer0@yandex.ru>
Mon, 27 Feb 2023 17:31:51 +0000 (20:31 +0300)
source/Irrlicht/CIrrDeviceSDL.cpp
source/Irrlicht/OpenGL/Driver.cpp
source/Irrlicht/OpenGL/Driver.h

index 8a74719e1577e6403572a00b350a5ac656057d01..a5ba6f690904d3210f446a59ab45c4ecee4e4099 100644 (file)
@@ -393,6 +393,7 @@ bool CIrrDeviceSDL::createWindow()
                SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);\r
                SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);\r
                SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY);\r
+               SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG | SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG);\r
                if (CreationParams.Bits == 16) {\r
                        SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 4);\r
                        SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 4);\r
index 7c13e7c70ac832c016e83c4828ff186c15379137..671f338a1b5616947901ad38d69385738e1d6d3d 100644 (file)
@@ -31,6 +31,16 @@ namespace irr
 namespace video\r
 {\r
 \r
+void APIENTRY COpenGL3Driver::debugCb(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *userParam)\r
+{\r
+       ((COpenGL3Driver *)userParam)->debugCb(source, type, id, severity, length, message);\r
+}\r
+\r
+void COpenGL3Driver::debugCb(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message)\r
+{\r
+       printf("%04x %04x %x %x %.*s\n", source, type, id, severity, length, message);\r
+}\r
+\r
 COpenGL3Driver::COpenGL3Driver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, IContextManager* contextManager) :\r
        CNullDriver(io, params.WindowSize), COpenGL3ExtensionHandler(), CacheHandler(0),\r
        Params(params), ResetRenderStates(true), LockRenderStateMode(false), AntiAlias(params.AntiAlias),\r
@@ -52,6 +62,7 @@ COpenGL3Driver::COpenGL3Driver(const SIrrlichtCreationParameters& params, io::IF
        ExposedData = ContextManager->getContext();\r
        ContextManager->activateContext(ExposedData, false);\r
        GL.LoadAllProcedures(ContextManager);\r
+       GL.DebugMessageCallback(debugCb, this);\r
 }\r
 \r
 COpenGL3Driver::~COpenGL3Driver()\r
index dd2ad89eade60d4918257b73a6f76e4367bf784a..4920fdea6d973693052a24c97c3d0abd27d2bdab 100644 (file)
@@ -397,6 +397,9 @@ private:
                ECOLOR_FORMAT ColorFormat;\r
 \r
                IContextManager* ContextManager;\r
+\r
+               void debugCb(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message);\r
+               static void APIENTRY debugCb(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *userParam);\r
        };\r
 \r
 } // end namespace video\r