From 72e09659409431f24accc61a0735596bc54d6ec2 Mon Sep 17 00:00:00 2001
From: Robert Menzel <menzel@informatik.rwth-aachen.de>
Date: Tue, 13 Oct 2015 17:05:32 +0200
Subject: [PATCH] added debug labels for GL objects

---
 include/ACGL/OpenGL/Debug.hh                  | 26 +++++++++++++++++++
 include/ACGL/OpenGL/Objects/Buffer.hh         | 16 ++++++++++++
 .../ACGL/OpenGL/Objects/FrameBufferObject.hh  | 15 +++++++++++
 .../ACGL/OpenGL/Objects/ProgramPipeline.hh    | 15 +++++++++++
 include/ACGL/OpenGL/Objects/Query.hh          | 15 +++++++++++
 include/ACGL/OpenGL/Objects/RenderBuffer.hh   | 15 +++++++++++
 include/ACGL/OpenGL/Objects/Sampler.hh        | 15 +++++++++++
 include/ACGL/OpenGL/Objects/Shader.hh         | 17 +++++++++++-
 include/ACGL/OpenGL/Objects/ShaderProgram.hh  | 15 +++++++++++
 include/ACGL/OpenGL/Objects/Texture.hh        | 15 +++++++++++
 .../ACGL/OpenGL/Objects/VertexArrayObject.hh  |  9 +++++++
 src/ACGL/OpenGL/Data/TextureLoadStore.cc      |  5 ++--
 src/ACGL/OpenGL/Data/TextureLoadStoreDDS.cc   |  4 +--
 .../OpenGL/Data/VertexArrayObjectLoadStore.cc |  5 ++--
 src/ACGL/OpenGL/Debug.cc                      |  1 +
 src/ACGL/OpenGL/Objects/Shader.cc             |  4 +--
 src/ACGL/OpenGL/Objects/VertexArrayObject.cc  | 16 ++++++++++++
 17 files changed, 195 insertions(+), 13 deletions(-)

diff --git a/include/ACGL/OpenGL/Debug.hh b/include/ACGL/OpenGL/Debug.hh
index 47b70e4b..54529198 100644
--- a/include/ACGL/OpenGL/Debug.hh
+++ b/include/ACGL/OpenGL/Debug.hh
@@ -25,6 +25,32 @@ public:
     ~GLDebugAnnotation();
 };
 
+
+#ifdef ACGL_OPENGL_DEBUGGER_SUPPORT
+// only for internal use!
+// THE_GL_TYPE has to be:
+// GL_BUFFER, GL_SHADER, GL_PROGRAM, GL_VERTEX_ARRAY, GL_QUERY, GL_PROGRAM_PIPELINE,
+// GL_TRANSFORM_FEEDBACK, GL_SAMPLER, GL_TEXTURE, GL_RENDERBUFFER or GL_FRAMEBUFFER
+template <unsigned int THE_GL_TYPE>
+void setObjectLabelT( GLuint _objectName, const std::string &_label ) {
+    glObjectLabel( THE_GL_TYPE, _objectName, -1, _label.c_str() );
+}
+
+template <unsigned int THE_GL_TYPE>
+std::string getObjectLabelT( GLuint _objectName )
+{
+    GLsizei labelLenght;
+    glGetObjectLabel(THE_GL_TYPE, _objectName, 0, &labelLenght, NULL);
+    GLchar *tmp = new GLchar[labelLenght+1]; // +1 to have space for the 0-termination
+
+    glGetObjectLabel(THE_GL_TYPE, _objectName, labelLenght+1, NULL, tmp);
+    std::string labelName(tmp);
+    delete[] tmp;
+
+    return labelName;
+}
+#endif
+
 //! converts a KHR debug source enum to a human readable string
 const char *debugSourceName( GLenum _source );
 
diff --git a/include/ACGL/OpenGL/Objects/Buffer.hh b/include/ACGL/OpenGL/Objects/Buffer.hh
index 5d9fd42f..6185d549 100644
--- a/include/ACGL/OpenGL/Objects/Buffer.hh
+++ b/include/ACGL/OpenGL/Objects/Buffer.hh
@@ -24,6 +24,7 @@
 #include <ACGL/Base/Macros.hh>
 #include <ACGL/OpenGL/GL.hh>
 #include <ACGL/OpenGL/Tools.hh>
+#include <ACGL/OpenGL/Debug.hh>
 
 #include <string>
 #include <vector>
@@ -107,6 +108,21 @@ public:
 
     virtual ~Buffer(){}
 
+    // ===================================================================================================== \/
+    // =========================================================================================== KHR_DEBUG \/
+    // ===================================================================================================== \/
+public:
+    // Sets and gets a label visible inside of a OpenGL debugger if KHR_debug is supported at runtime *and*
+    // if ACGL_OPENGL_DEBUGGER_SUPPORT was defined during compile time. Does nothing otherwise!
+#ifdef ACGL_OPENGL_DEBUGGER_SUPPORT
+    void setObjectLabel( const std::string &_label ) { setObjectLabelT<GL_BUFFER>(getObjectName(),_label); }
+    std::string getObjectLabel() { return getObjectLabelT<GL_BUFFER>(getObjectName()); }
+#else
+    void setObjectLabel( const std::string & ) {}
+    std::string getObjectLabel() { return ""; }
+#endif
+
+
     // ==================================================================================================== \/
     // ============================================================================================ GETTERS \/
     // ==================================================================================================== \/
diff --git a/include/ACGL/OpenGL/Objects/FrameBufferObject.hh b/include/ACGL/OpenGL/Objects/FrameBufferObject.hh
index fe99279f..fb5c67f3 100644
--- a/include/ACGL/OpenGL/Objects/FrameBufferObject.hh
+++ b/include/ACGL/OpenGL/Objects/FrameBufferObject.hh
@@ -29,6 +29,7 @@
 #include <ACGL/Utils/StringHelpers.hh>
 #include <ACGL/OpenGL/GL.hh>
 #include <ACGL/OpenGL/Tools.hh>
+#include <ACGL/OpenGL/Debug.hh>
 #include <ACGL/OpenGL/Objects/RenderBuffer.hh>
 #include <ACGL/OpenGL/Objects/Texture.hh>
 #include <ACGL/OpenGL/Data/LocationMappings.hh>
@@ -103,6 +104,20 @@ public:
         glDeleteFramebuffers(1, &mObjectName);
     }
 
+    // ===================================================================================================== \/
+    // =========================================================================================== KHR_DEBUG \/
+    // ===================================================================================================== \/
+public:
+    // Sets and gets a label visible inside of a OpenGL debugger if KHR_debug is supported at runtime *and*
+    // if ACGL_OPENGL_DEBUGGER_SUPPORT was defined during compile time. Does nothing otherwise!
+#ifdef ACGL_OPENGL_DEBUGGER_SUPPORT
+    void setObjectLabel( const std::string &_label ) { setObjectLabelT<GL_FRAMEBUFFER>(getObjectName(),_label); }
+    std::string getObjectLabel() { return getObjectLabelT<GL_FRAMEBUFFER>(getObjectName()); }
+#else
+    void setObjectLabel( const std::string & ) {}
+    std::string getObjectLabel() { return ""; }
+#endif
+
     // ==================================================================================================== \/
     // ============================================================================================ GETTERS \/
     // ==================================================================================================== \/
diff --git a/include/ACGL/OpenGL/Objects/ProgramPipeline.hh b/include/ACGL/OpenGL/Objects/ProgramPipeline.hh
index e6a15660..84e72d15 100644
--- a/include/ACGL/OpenGL/Objects/ProgramPipeline.hh
+++ b/include/ACGL/OpenGL/Objects/ProgramPipeline.hh
@@ -12,6 +12,7 @@
 #include <ACGL/Base/Macros.hh>
 #include <ACGL/OpenGL/GL.hh>
 #include <ACGL/OpenGL/Tools.hh>
+#include <ACGL/OpenGL/Debug.hh>
 
 #include <ACGL/OpenGL/Objects/ShaderProgram.hh>
 
@@ -38,6 +39,20 @@ public:
     ProgramPipeline();
     ~ProgramPipeline(void);
 
+    // ===================================================================================================== \/
+    // =========================================================================================== KHR_DEBUG \/
+    // ===================================================================================================== \/
+public:
+    // Sets and gets a label visible inside of a OpenGL debugger if KHR_debug is supported at runtime *and*
+    // if ACGL_OPENGL_DEBUGGER_SUPPORT was defined during compile time. Does nothing otherwise!
+#ifdef ACGL_OPENGL_DEBUGGER_SUPPORT
+    void setObjectLabel( const std::string &_label ) { setObjectLabelT<GL_PROGRAM_PIPELINE>(getObjectName(),_label); }
+    std::string getObjectLabel() { return getObjectLabelT<GL_PROGRAM_PIPELINE>(getObjectName()); }
+#else
+    void setObjectLabel( const std::string & ) {}
+    std::string getObjectLabel() { return ""; }
+#endif
+
     // ==================================================================================================== \/
     // ============================================================================================ GETTERS \/
     // ==================================================================================================== \/
diff --git a/include/ACGL/OpenGL/Objects/Query.hh b/include/ACGL/OpenGL/Objects/Query.hh
index c7e82335..83a73bd4 100644
--- a/include/ACGL/OpenGL/Objects/Query.hh
+++ b/include/ACGL/OpenGL/Objects/Query.hh
@@ -12,6 +12,7 @@
 #include <ACGL/Base/Macros.hh>
 #include <ACGL/OpenGL/GL.hh>
 #include <ACGL/OpenGL/Tools.hh>
+#include <ACGL/OpenGL/Debug.hh>
 
 #ifndef ACGL_OPENGLES_VERSION_20
 
@@ -44,6 +45,20 @@ public:
         glDeleteQueries( 1, &mObjectName );
     }
 
+    // ===================================================================================================== \/
+    // =========================================================================================== KHR_DEBUG \/
+    // ===================================================================================================== \/
+public:
+    // Sets and gets a label visible inside of a OpenGL debugger if KHR_debug is supported at runtime *and*
+    // if ACGL_OPENGL_DEBUGGER_SUPPORT was defined during compile time. Does nothing otherwise!
+#ifdef ACGL_OPENGL_DEBUGGER_SUPPORT
+    void setObjectLabel( const std::string &_label ) { setObjectLabelT<GL_QUERY>(getObjectName(),_label); }
+    std::string getObjectLabel() { return getObjectLabelT<GL_QUERY>(getObjectName()); }
+#else
+    void setObjectLabel( const std::string & ) {}
+    std::string getObjectLabel() { return ""; }
+#endif
+
     //! start the query, only one query per type is allowed to be active at any time.
     void begin(void) {
         glBeginQuery( mTarget, mObjectName );
diff --git a/include/ACGL/OpenGL/Objects/RenderBuffer.hh b/include/ACGL/OpenGL/Objects/RenderBuffer.hh
index 771ee720..a35d0b3f 100644
--- a/include/ACGL/OpenGL/Objects/RenderBuffer.hh
+++ b/include/ACGL/OpenGL/Objects/RenderBuffer.hh
@@ -20,6 +20,7 @@
 #include <ACGL/Base/Macros.hh>
 #include <ACGL/OpenGL/GL.hh>
 #include <ACGL/OpenGL/Tools.hh>
+#include <ACGL/OpenGL/Debug.hh>
 #include <ACGL/Math/Math.hh>
 
 namespace ACGL{
@@ -50,6 +51,20 @@ public:
         glDeleteRenderbuffers(1, &mObjectName);
     }
 
+    // ===================================================================================================== \/
+    // =========================================================================================== KHR_DEBUG \/
+    // ===================================================================================================== \/
+public:
+    // Sets and gets a label visible inside of a OpenGL debugger if KHR_debug is supported at runtime *and*
+    // if ACGL_OPENGL_DEBUGGER_SUPPORT was defined during compile time. Does nothing otherwise!
+#ifdef ACGL_OPENGL_DEBUGGER_SUPPORT
+    void setObjectLabel( const std::string &_label ) { setObjectLabelT<GL_RENDERBUFFER>(getObjectName(),_label); }
+    std::string getObjectLabel() { return getObjectLabelT<GL_RENDERBUFFER>(getObjectName()); }
+#else
+    void setObjectLabel( const std::string & ) {}
+    std::string getObjectLabel() { return ""; }
+#endif
+
     // ==================================================================================================== \/
     // ============================================================================================ GETTERS \/
     // ==================================================================================================== \/
diff --git a/include/ACGL/OpenGL/Objects/Sampler.hh b/include/ACGL/OpenGL/Objects/Sampler.hh
index 36cedb4e..ceb33fe2 100644
--- a/include/ACGL/OpenGL/Objects/Sampler.hh
+++ b/include/ACGL/OpenGL/Objects/Sampler.hh
@@ -12,6 +12,7 @@
 #include <ACGL/Base/Macros.hh>
 #include <ACGL/OpenGL/GL.hh>
 #include <ACGL/OpenGL/Tools.hh>
+#include <ACGL/OpenGL/Debug.hh>
 
 #include <ACGL/Math/Math.hh>
 
@@ -43,6 +44,20 @@ public:
     Sampler();
     ~Sampler(void);
 
+    // ===================================================================================================== \/
+    // =========================================================================================== KHR_DEBUG \/
+    // ===================================================================================================== \/
+public:
+    // Sets and gets a label visible inside of a OpenGL debugger if KHR_debug is supported at runtime *and*
+    // if ACGL_OPENGL_DEBUGGER_SUPPORT was defined during compile time. Does nothing otherwise!
+#ifdef ACGL_OPENGL_DEBUGGER_SUPPORT
+    void setObjectLabel( const std::string &_label ) { setObjectLabelT<GL_SAMPLER>(getObjectName(),_label); }
+    std::string getObjectLabel() { return getObjectLabelT<GL_SAMPLER>(getObjectName()); }
+#else
+    void setObjectLabel( const std::string & ) {}
+    std::string getObjectLabel() { return ""; }
+#endif
+
     // ==================================================================================================== \/
     // ============================================================================================ GETTERS \/
     // ==================================================================================================== \/
diff --git a/include/ACGL/OpenGL/Objects/Shader.hh b/include/ACGL/OpenGL/Objects/Shader.hh
index af1a3c71..7b67837a 100644
--- a/include/ACGL/OpenGL/Objects/Shader.hh
+++ b/include/ACGL/OpenGL/Objects/Shader.hh
@@ -26,6 +26,7 @@
 #include <ACGL/Base/Macros.hh>
 #include <ACGL/OpenGL/GL.hh>
 #include <ACGL/OpenGL/Tools.hh>
+#include <ACGL/OpenGL/Debug.hh>
 #include <ACGL/OpenGL/Creator/ShaderParser.hh>
 
 namespace ACGL{
@@ -54,7 +55,21 @@ public:
         // "DeleteShader will silently ignore the value zero." - GL Spec
         glDeleteShader(mObjectName);
     }
-    
+
+    // ===================================================================================================== \/
+    // =========================================================================================== KHR_DEBUG \/
+    // ===================================================================================================== \/
+public:
+    // Sets and gets a label visible inside of a OpenGL debugger if KHR_debug is supported at runtime *and*
+    // if ACGL_OPENGL_DEBUGGER_SUPPORT was defined during compile time. Does nothing otherwise!
+#ifdef ACGL_OPENGL_DEBUGGER_SUPPORT
+    void setObjectLabel( const std::string &_label ) { setObjectLabelT<GL_SHADER>(getObjectName(),_label); }
+    std::string getObjectLabel() { return getObjectLabelT<GL_SHADER>(getObjectName()); }
+#else
+    void setObjectLabel( const std::string & ) {}
+    std::string getObjectLabel() { return ""; }
+#endif
+
     // ==================================================================================================== \/
     // ============================================================================================ GETTERS \/
     // ==================================================================================================== \/
diff --git a/include/ACGL/OpenGL/Objects/ShaderProgram.hh b/include/ACGL/OpenGL/Objects/ShaderProgram.hh
index 0c805804..0b4658eb 100644
--- a/include/ACGL/OpenGL/Objects/ShaderProgram.hh
+++ b/include/ACGL/OpenGL/Objects/ShaderProgram.hh
@@ -45,6 +45,7 @@
 
 #include <ACGL/Base/Macros.hh>
 #include <ACGL/OpenGL/GL.hh>
+#include <ACGL/OpenGL/Debug.hh>
 #include <ACGL/OpenGL/Objects/Shader.hh>
 #include <ACGL/OpenGL/Objects/Texture.hh>
 #include <ACGL/OpenGL/Objects/TextureBuffer.hh>
@@ -83,6 +84,20 @@ public:
         glDeleteProgram(mObjectName);
     }
 
+    // ===================================================================================================== \/
+    // =========================================================================================== KHR_DEBUG \/
+    // ===================================================================================================== \/
+public:
+    // Sets and gets a label visible inside of a OpenGL debugger if KHR_debug is supported at runtime *and*
+    // if ACGL_OPENGL_DEBUGGER_SUPPORT was defined during compile time. Does nothing otherwise!
+#ifdef ACGL_OPENGL_DEBUGGER_SUPPORT
+    void setObjectLabel( const std::string &_label ) { setObjectLabelT<GL_PROGRAM>(getObjectName(),_label); }
+    std::string getObjectLabel() { return getObjectLabelT<GL_PROGRAM>(getObjectName()); }
+#else
+    void setObjectLabel( const std::string & ) {}
+    std::string getObjectLabel() { return ""; }
+#endif
+
     // ==================================================================================================== \/
     // ============================================================================================ GETTERS \/
     // ==================================================================================================== \/
diff --git a/include/ACGL/OpenGL/Objects/Texture.hh b/include/ACGL/OpenGL/Objects/Texture.hh
index 99133eef..fcc29d33 100644
--- a/include/ACGL/OpenGL/Objects/Texture.hh
+++ b/include/ACGL/OpenGL/Objects/Texture.hh
@@ -17,6 +17,7 @@
 #include <ACGL/Base/Macros.hh>
 #include <ACGL/OpenGL/GL.hh>
 #include <ACGL/OpenGL/Tools.hh>
+#include <ACGL/OpenGL/Debug.hh>
 #include <ACGL/OpenGL/Data/TextureData.hh>
 #include <ACGL/Math/Math.hh>
 
@@ -92,6 +93,20 @@ public:
         glDeleteTextures(1, &mObjectName);
     }
 
+    // ===================================================================================================== \/
+    // =========================================================================================== KHR_DEBUG \/
+    // ===================================================================================================== \/
+public:
+    // Sets and gets a label visible inside of a OpenGL debugger if KHR_debug is supported at runtime *and*
+    // if ACGL_OPENGL_DEBUGGER_SUPPORT was defined during compile time. Does nothing otherwise!
+#ifdef ACGL_OPENGL_DEBUGGER_SUPPORT
+    void setObjectLabel( const std::string &_label ) { setObjectLabelT<GL_TEXTURE>(getObjectName(),_label); }
+    std::string getObjectLabel() { return getObjectLabelT<GL_TEXTURE>(getObjectName()); }
+#else
+    void setObjectLabel( const std::string & ) {}
+    std::string getObjectLabel() { return ""; }
+#endif
+
     // ==================================================================================================== \/
     // ============================================================================================ GETTERS \/
     // ==================================================================================================== \/
diff --git a/include/ACGL/OpenGL/Objects/VertexArrayObject.hh b/include/ACGL/OpenGL/Objects/VertexArrayObject.hh
index 0d0c26a6..c532d5fa 100644
--- a/include/ACGL/OpenGL/Objects/VertexArrayObject.hh
+++ b/include/ACGL/OpenGL/Objects/VertexArrayObject.hh
@@ -79,6 +79,15 @@ public:
         glDeleteVertexArrays(1, &mObjectName);
     }
 
+    // ===================================================================================================== \/
+    // =========================================================================================== KHR_DEBUG \/
+    // ===================================================================================================== \/
+public:
+    // Sets and gets a label visible inside of a OpenGL debugger if KHR_debug is supported at runtime *and*
+    // if ACGL_OPENGL_DEBUGGER_SUPPORT was defined during compile time. Does nothing otherwise!
+    void setObjectLabel( const std::string &_label );
+    std::string getObjectLabel();
+
     // ==================================================================================================== \/
     // ============================================================================================ SETTERS \/
     // ==================================================================================================== \/
diff --git a/src/ACGL/OpenGL/Data/TextureLoadStore.cc b/src/ACGL/OpenGL/Data/TextureLoadStore.cc
index 091b8746..8c0ad941 100644
--- a/src/ACGL/OpenGL/Data/TextureLoadStore.cc
+++ b/src/ACGL/OpenGL/Data/TextureLoadStore.cc
@@ -32,9 +32,8 @@ SharedTexture2D loadTexture2D(const std::string& _filename, ColorSpace _colorSpa
             SharedTexture2D texture = SharedTexture2D( new Texture2D(data->getRecommendedInternalFormat()) );
             texture->setImageData( data );
             texture->generateMipmaps(); // calculates all remaining mipmap levels
-            #ifdef ACGL_OPENGL_DEBUGGER_SUPPORT
-                glObjectLabel( GL_TEXTURE, texture->getObjectName(), -1, _filename.c_str() );
-            #endif
+            texture->setObjectLabel( _filename );
+
             return texture;
         } else {
             ACGL::Utils::error() << "can't create Texture from file " << _filename << " creating small empty texture instead." << std::endl;
diff --git a/src/ACGL/OpenGL/Data/TextureLoadStoreDDS.cc b/src/ACGL/OpenGL/Data/TextureLoadStoreDDS.cc
index b577cc5a..cec2bb6b 100644
--- a/src/ACGL/OpenGL/Data/TextureLoadStoreDDS.cc
+++ b/src/ACGL/OpenGL/Data/TextureLoadStoreDDS.cc
@@ -91,9 +91,7 @@ SharedTexture2D loadTexture2DFromDDS(const std::string& _filename, ColorSpace _c
         ACGL::Utils::error() << "could not open " << _filename << std::endl;
     }
 
-#ifdef ACGL_OPENGL_DEBUGGER_SUPPORT
-    glObjectLabel( GL_TEXTURE, texture->getObjectName(), -1, _filename.c_str() );
-#endif
+    texture->setObjectLabel( _filename );
     return texture;
 }
 
diff --git a/src/ACGL/OpenGL/Data/VertexArrayObjectLoadStore.cc b/src/ACGL/OpenGL/Data/VertexArrayObjectLoadStore.cc
index e6063d88..a7f4eaea 100644
--- a/src/ACGL/OpenGL/Data/VertexArrayObjectLoadStore.cc
+++ b/src/ACGL/OpenGL/Data/VertexArrayObjectLoadStore.cc
@@ -68,9 +68,8 @@ SharedVertexArrayObject loadVertexArrayObject(const std::string& _filename, bool
         saveVertexArrayObjectToVAO(vao, _filename + ".vao");
     }
 
-#ifdef ACGL_OPENGL_DEBUGGER_SUPPORT
-    glObjectLabel( GL_VERTEX_ARRAY, vao->getObjectName(), -1, _filename.c_str() );
-#endif
+    vao->setObjectLabel( _filename );
+
     return vao;
 }
 
diff --git a/src/ACGL/OpenGL/Debug.cc b/src/ACGL/OpenGL/Debug.cc
index b814427a..a3ed93c5 100644
--- a/src/ACGL/OpenGL/Debug.cc
+++ b/src/ACGL/OpenGL/Debug.cc
@@ -28,6 +28,7 @@ GLDebugAnnotation::~GLDebugAnnotation()
 {
     glPopDebugGroup();
 }
+
 #else
 GLDebugAnnotation::GLDebugAnnotation( const char *_message ){}
 GLDebugAnnotation::~GLDebugAnnotation(){}
diff --git a/src/ACGL/OpenGL/Objects/Shader.cc b/src/ACGL/OpenGL/Objects/Shader.cc
index 2dde60ed..5bd3ecbe 100644
--- a/src/ACGL/OpenGL/Objects/Shader.cc
+++ b/src/ACGL/OpenGL/Objects/Shader.cc
@@ -70,9 +70,7 @@ bool Shader::setFromFile(SharedShaderParser const& _sp)
         }
     }
 
-#ifdef ACGL_OPENGL_DEBUGGER_SUPPORT
-    glObjectLabel( GL_SHADER, mObjectName, -1, _sp->getSources()[0].c_str() );
-#endif
+    setObjectLabel( _sp->getSources()[0].c_str() );
 
     return !compileErrors; // return true iff there were no errors
 }
diff --git a/src/ACGL/OpenGL/Objects/VertexArrayObject.cc b/src/ACGL/OpenGL/Objects/VertexArrayObject.cc
index 8d7727d8..0eeb09b3 100644
--- a/src/ACGL/OpenGL/Objects/VertexArrayObject.cc
+++ b/src/ACGL/OpenGL/Objects/VertexArrayObject.cc
@@ -5,6 +5,7 @@
  **********************************************************************/
 
 #include <ACGL/OpenGL/Objects/VertexArrayObject.hh>
+#include <ACGL/OpenGL/Debug.hh>
 #if (ACGL_OPENGL_VERSION >= 30)
 
 using namespace ACGL;
@@ -24,6 +25,21 @@ VertexArrayObject::VertexArrayObject( GLenum _mode ) :
     mAttributes.resize( maxAttributes ); // reserve probably 16 slots, the size() can now be used to query the MAX_VERTEX_ATTRIBS
 }
 
+#ifdef ACGL_OPENGL_DEBUGGER_SUPPORT
+void VertexArrayObject::setObjectLabel( const std::string &_label )
+{
+    setObjectLabelT<GL_VERTEX_ARRAY>(getObjectName(),_label);
+}
+
+std::string VertexArrayObject::getObjectLabel()
+{
+    return getObjectLabelT<GL_VERTEX_ARRAY>(getObjectName());
+}
+#else
+void VertexArrayObject::setObjectLabel( const std::string & ) {}
+std::string VertexArrayObject::getObjectLabel() { return ""; }
+#endif
+
 void VertexArrayObject::bind() const
 {
     glBindVertexArray( mObjectName );
-- 
GitLab