diff --git a/src/Magnum/GL/DebugOutput.cpp b/src/Magnum/GL/DebugOutput.cpp index f434116ee..a1df9bce2 100644 --- a/src/Magnum/GL/DebugOutput.cpp +++ b/src/Magnum/GL/DebugOutput.cpp @@ -145,7 +145,8 @@ Int DebugOutput::maxMessageLength() { } void DebugOutput::setCallback(const Callback callback, const void* userParam) { - Context::current().state().debug.callbackImplementation(callback, userParam); + Context::current().state().debug.messageCallback.userParam = userParam; + Context::current().state().debug.callbackImplementation(callback); } void DebugOutput::setDefaultCallback() { @@ -172,38 +173,38 @@ void DebugOutput::controlImplementationKhrES(const GLenum source, const GLenum t } #endif -void DebugOutput::callbackImplementationNoOp(Callback, const void*) {} +void DebugOutput::callbackImplementationNoOp(Callback) {} #ifndef MAGNUM_TARGET_GLES2 -void DebugOutput::callbackImplementationKhrDesktopES32(const Callback callback, const void* userParam) { +void DebugOutput::callbackImplementationKhrDesktopES32(const Callback callback) { /* Replace the callback */ - const Callback original = Context::current().state().debug.messageCallback.callback; + const bool setPreviously = !!Context::current().state().debug.messageCallback.callback; + Context::current().state().debug.messageCallback.callback = callback; - Context::current().state().debug.messageCallback.userParam = userParam; /* Adding callback */ - if(!original && callback) + if(!setPreviously && callback) glDebugMessageCallback(callbackWrapper, &Context::current().state().debug.messageCallback); /* Deleting callback */ - else if(original && !callback) + else if(setPreviously && !callback) glDebugMessageCallback(nullptr, nullptr); } #endif #ifdef MAGNUM_TARGET_GLES -void DebugOutput::callbackImplementationKhrES(const Callback callback, const void* userParam) { +void DebugOutput::callbackImplementationKhrES(const Callback callback) { /* Replace the callback */ - const Callback original = Context::current().state().debug.messageCallback.callback; + const bool setPreviously = !!Context::current().state().debug.messageCallback.callback; + Context::current().state().debug.messageCallback.callback = callback; - Context::current().state().debug.messageCallback.userParam = userParam; /* Adding callback */ - if(!original && callback) + if(!setPreviously && callback) glDebugMessageCallbackKHR(callbackWrapper, &Context::current().state().debug.messageCallback); /* Deleting callback */ - else if(original && !callback) + else if(setPreviously && !callback) glDebugMessageCallbackKHR(nullptr, nullptr); } #endif diff --git a/src/Magnum/GL/DebugOutput.h b/src/Magnum/GL/DebugOutput.h index 345a11398..f85d13dc1 100644 --- a/src/Magnum/GL/DebugOutput.h +++ b/src/Magnum/GL/DebugOutput.h @@ -422,12 +422,12 @@ class MAGNUM_GL_EXPORT DebugOutput { static MAGNUM_GL_LOCAL void controlImplementationKhrES(GLenum source, GLenum type, GLenum severity, std::initializer_list ids, bool enabled); #endif - static MAGNUM_GL_LOCAL void callbackImplementationNoOp(Callback, const void*); + static MAGNUM_GL_LOCAL void callbackImplementationNoOp(Callback callback); #ifndef MAGNUM_TARGET_GLES2 - static MAGNUM_GL_LOCAL void callbackImplementationKhrDesktopES32(Callback callback, const void* userParam); + static MAGNUM_GL_LOCAL void callbackImplementationKhrDesktopES32(Callback callback); #endif #ifdef MAGNUM_TARGET_GLES - static MAGNUM_GL_LOCAL void callbackImplementationKhrES(Callback callback, const void* userParam); + static MAGNUM_GL_LOCAL void callbackImplementationKhrES(Callback callback); #endif }; diff --git a/src/Magnum/GL/Implementation/DebugState.h b/src/Magnum/GL/Implementation/DebugState.h index 912bd5e71..050ff3d9f 100644 --- a/src/Magnum/GL/Implementation/DebugState.h +++ b/src/Magnum/GL/Implementation/DebugState.h @@ -42,7 +42,7 @@ struct DebugState { void(*messageInsertImplementation)(DebugMessage::Source, DebugMessage::Type, UnsignedInt, DebugOutput::Severity, Containers::ArrayView); void(*controlImplementation)(GLenum, GLenum, GLenum, std::initializer_list, bool); - void(*callbackImplementation)(DebugOutput::Callback, const void*); + void(*callbackImplementation)(DebugOutput::Callback); void(*pushGroupImplementation)(DebugGroup::Source, UnsignedInt, Containers::ArrayView); void(*popGroupImplementation)();