Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ACGL
acgl
Commits
72e09659
Commit
72e09659
authored
Oct 13, 2015
by
Robert Menzel
Browse files
added debug labels for GL objects
parent
559c5253
Changes
17
Hide whitespace changes
Inline
Side-by-side
include/ACGL/OpenGL/Debug.hh
View file @
72e09659
...
...
@@ -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
);
...
...
include/ACGL/OpenGL/Objects/Buffer.hh
View file @
72e09659
...
...
@@ -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 \/
// ==================================================================================================== \/
...
...
include/ACGL/OpenGL/Objects/FrameBufferObject.hh
View file @
72e09659
...
...
@@ -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 \/
// ==================================================================================================== \/
...
...
include/ACGL/OpenGL/Objects/ProgramPipeline.hh
View file @
72e09659
...
...
@@ -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 \/
// ==================================================================================================== \/
...
...
include/ACGL/OpenGL/Objects/Query.hh
View file @
72e09659
...
...
@@ -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
);
...
...
include/ACGL/OpenGL/Objects/RenderBuffer.hh
View file @
72e09659
...
...
@@ -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 \/
// ==================================================================================================== \/
...
...
include/ACGL/OpenGL/Objects/Sampler.hh
View file @
72e09659
...
...
@@ -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 \/
// ==================================================================================================== \/
...
...
include/ACGL/OpenGL/Objects/Shader.hh
View file @
72e09659
...
...
@@ -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 \/
// ==================================================================================================== \/
...
...
include/ACGL/OpenGL/Objects/ShaderProgram.hh
View file @
72e09659
...
...
@@ -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 \/
// ==================================================================================================== \/
...
...
include/ACGL/OpenGL/Objects/Texture.hh
View file @
72e09659
...
...
@@ -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 \/
// ==================================================================================================== \/
...
...
include/ACGL/OpenGL/Objects/VertexArrayObject.hh
View file @
72e09659
...
...
@@ -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 \/
// ==================================================================================================== \/
...
...
src/ACGL/OpenGL/Data/TextureLoadStore.cc
View file @
72e09659
...
...
@@ -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
;
...
...
src/ACGL/OpenGL/Data/TextureLoadStoreDDS.cc
View file @
72e09659
...
...
@@ -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
;
}
...
...
src/ACGL/OpenGL/Data/VertexArrayObjectLoadStore.cc
View file @
72e09659
...
...
@@ -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
;
}
...
...
src/ACGL/OpenGL/Debug.cc
View file @
72e09659
...
...
@@ -28,6 +28,7 @@ GLDebugAnnotation::~GLDebugAnnotation()
{
glPopDebugGroup
();
}
#else
GLDebugAnnotation
::
GLDebugAnnotation
(
const
char
*
_message
){}
GLDebugAnnotation
::~
GLDebugAnnotation
(){}
...
...
src/ACGL/OpenGL/Objects/Shader.cc
View file @
72e09659
...
...
@@ -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
}
...
...
src/ACGL/OpenGL/Objects/VertexArrayObject.cc
View file @
72e09659
...
...
@@ -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
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment