mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-09 15:45:40 +12:00
Add DebugScope
utility-class for RAII-based OpenGL debug-scopes
Simply define this object in a C++ scope like: ```cpp OpenGL::DebugScope glScope("Renderer::display"); ``` and it will associate all functions within the current scope within a named group. Supports `printf` formatting.
This commit is contained in:
parent
1251cecc88
commit
dbf0597bd8
1 changed files with 20 additions and 0 deletions
|
@ -73,6 +73,26 @@ namespace OpenGL {
|
|||
glObjectLabel(identifier, name, length, label);
|
||||
}
|
||||
|
||||
class DebugScope {
|
||||
inline static GLuint scopeDepth = 0;
|
||||
const GLuint m_scope_depth;
|
||||
|
||||
public:
|
||||
OPENGL_PRINTF_FORMAT_ATTR(2, 3)
|
||||
DebugScope(OPENGL_PRINTF_FORMAT const char* format, ...) : m_scope_depth(scopeDepth++) {
|
||||
GLchar message[256] = {};
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
const GLsizei length = vsnprintf(message, std::size(message), format, args);
|
||||
va_end(args);
|
||||
glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, m_scope_depth, length, message);
|
||||
}
|
||||
~DebugScope() {
|
||||
glPopDebugGroup();
|
||||
scopeDepth--;
|
||||
}
|
||||
};
|
||||
|
||||
struct VertexArray {
|
||||
GLuint m_handle = 0;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue