From 09533ab9379a675a89638132fb6831b420ebb8f4 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 16 Jan 2026 02:53:57 +0000 Subject: Add glDebugScope Wrapper for glPushDebugGroup/glPopDebugGroup which allows neatly grouping OpenGL calls in diagnostic tools. --- gfx/gl/gldebug.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 gfx/gl/gldebug.cpp (limited to 'gfx/gl/gldebug.cpp') diff --git a/gfx/gl/gldebug.cpp b/gfx/gl/gldebug.cpp new file mode 100644 index 0000000..518d4fb --- /dev/null +++ b/gfx/gl/gldebug.cpp @@ -0,0 +1,20 @@ +#if GLDEBUG == 2 +// Level 2 is out of line because its "complex" + +# include "gldebug.h" +# include + +glDebugScope::glDebugScope(GLuint id, const std::source_location & location) +{ + const auto fullMsg = std::format("{} ({}:{})", location.function_name(), location.file_name(), location.line()); + glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, id, static_cast(fullMsg.length()), fullMsg.c_str()); +} + +glDebugScope::glDebugScope(GLuint id, const std::string_view msg, const std::source_location & location) +{ + const auto fullMsg + = std::format("{} @ {} ({}:{})", msg, location.function_name(), location.file_name(), location.line()); + glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, id, static_cast(fullMsg.length()), fullMsg.c_str()); +} + +#endif -- cgit v1.2.3