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
559c5253
Commit
559c5253
authored
Oct 09, 2015
by
Robert Menzel
Browse files
added debug label support and tests for object label names
parent
d18b216c
Changes
10
Hide whitespace changes
Inline
Side-by-side
include/ACGL/OpenGL/Debug.hh
View file @
559c5253
...
...
@@ -12,6 +12,19 @@
namespace
ACGL
{
namespace
OpenGL
{
/*
* Pushes the message onto the debug message stack from KHR_debug
* and pops it when the scope ends (== this object gets destroyed).
*
* Will be visible in debuggers.
*/
class
GLDebugAnnotation
{
public:
GLDebugAnnotation
(
const
char
*
_message
);
~
GLDebugAnnotation
();
};
//! converts a KHR debug source enum to a human readable string
const
char
*
debugSourceName
(
GLenum
_source
);
...
...
include/ACGL/OpenGL/GL.hh
View file @
559c5253
...
...
@@ -129,6 +129,7 @@
// prevents QT from redefining the debug functions
#define GL_ARB_debug_output
#define GL_KHR_debug
#define ACGL_OPENGL_DEBUGGER_SUPPORT
#endif
void
CHECKGLERROR
();
...
...
include/ACGL/OpenGL/Objects/Shader.hh
View file @
559c5253
...
...
@@ -72,9 +72,9 @@ public:
protected:
// could get reactivated if needed, might get removed later (thus protected):
bool
setFromFileNoImportParsing
(
const
std
::
string
&
_filename
);
//
bool setFromFileNoImportParsing(const std::string& _filename);
bool
compile
()
const
;
bool
compile
()
const
;
// get a log and a bool whether the log contains an error (or just a warning), not done
// automatically by compile() but called by all public source setting functions:
void
getCompileLog
(
std
::
string
&
_log
,
bool
&
_wasErrorLog
)
const
;
...
...
include/ACGL/OpenGL/Tools.hh
View file @
559c5253
...
...
@@ -220,8 +220,6 @@ inline bool openGLErrorOccuredDummy() { return false; }
# define openGLRareErrorOccured() ACGL::OpenGL::openGLErrorOccuredDummy()
#endif
}
// OpenGL
}
// ACGL
...
...
src/ACGL/OpenGL/Data/TextureLoadStore.cc
View file @
559c5253
...
...
@@ -32,6 +32,9 @@ 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
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 @
559c5253
...
...
@@ -91,6 +91,9 @@ 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
return
texture
;
}
...
...
src/ACGL/OpenGL/Data/VertexArrayObjectLoadStore.cc
View file @
559c5253
...
...
@@ -68,6 +68,9 @@ 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
return
vao
;
}
...
...
src/ACGL/OpenGL/Debug.cc
View file @
559c5253
...
...
@@ -17,6 +17,22 @@ using namespace ACGL::Utils;
namespace
ACGL
{
namespace
OpenGL
{
#ifdef ACGL_OPENGL_DEBUGGER_SUPPORT
GLDebugAnnotation
::
GLDebugAnnotation
(
const
char
*
_message
)
{
GLuint
messageID
=
0
;
glPushDebugGroup
(
GL_DEBUG_SOURCE_APPLICATION
,
messageID
,
-
1
,
_message
);
}
GLDebugAnnotation
::~
GLDebugAnnotation
()
{
glPopDebugGroup
();
}
#else
GLDebugAnnotation
::
GLDebugAnnotation
(
const
char
*
_message
){}
GLDebugAnnotation
::~
GLDebugAnnotation
(){}
#endif
const
char
*
debugSourceName
(
GLenum
_source
)
{
if
(
_source
==
GL_DEBUG_SOURCE_API
)
return
"API"
;
...
...
@@ -25,7 +41,7 @@ const char *debugSourceName( GLenum _source )
if
(
_source
==
GL_DEBUG_SOURCE_THIRD_PARTY
)
return
"Third Party"
;
if
(
_source
==
GL_DEBUG_SOURCE_APPLICATION
)
return
"Application"
;
if
(
_source
==
GL_DEBUG_SOURCE_OTHER
)
return
"Unknown"
;
return
"Unknown"
;
return
"Unknown
Source
"
;
}
const
char
*
debugTypeName
(
GLenum
_type
)
...
...
@@ -37,7 +53,9 @@ const char *debugTypeName( GLenum _type )
if
(
_type
==
GL_DEBUG_TYPE_PERFORMANCE
)
return
"Performance Issue"
;
if
(
_type
==
GL_DEBUG_TYPE_MARKER
)
return
"Marker"
;
if
(
_type
==
GL_DEBUG_TYPE_OTHER
)
return
"Issue"
;
return
"Issue"
;
if
(
_type
==
GL_DEBUG_TYPE_POP_GROUP
)
return
"Debug group pop"
;
if
(
_type
==
GL_DEBUG_TYPE_PUSH_GROUP
)
return
"Debug group push"
;
return
"Unknown Type"
;
}
const
char
*
debugSeverityName
(
GLenum
_type
)
...
...
@@ -46,7 +64,7 @@ const char *debugSeverityName( GLenum _type )
if
(
_type
==
GL_DEBUG_SEVERITY_MEDIUM
)
return
"medium"
;
if
(
_type
==
GL_DEBUG_SEVERITY_HIGH
)
return
"high"
;
if
(
_type
==
GL_DEBUG_SEVERITY_NOTIFICATION
)
return
"notification"
;
return
"
u
nknown"
;
return
"
U
nknown
Severity
"
;
}
void
ACGLRegisterDefaultDebugCallback
()
...
...
@@ -73,14 +91,14 @@ void APIENTRY ACGL_KHR_default_debug_callback( GLenum _source, GLenum _type, GLu
// be printed first...
if
(
_type
==
GL_DEBUG_TYPE_ERROR
)
{
error
()
<<
"<"
<<
_id
<<
"> severity: "
<<
debugSeverityName
(
_severity
)
<<
" source: "
<<
debugSourceName
(
_source
)
<<
": "
<<
_message
<<
endl
;
}
else
if
(
_type
==
GL_DEBUG_TYPE_POP_GROUP
||
_type
==
GL_DEBUG_TYPE_PUSH_GROUP
)
{
// push and pop groups are ignored because they are intended for a debugger
}
else
{
debug
()
<<
"<"
<<
_id
<<
"> severity: "
<<
debugSeverityName
(
_severity
)
<<
" source: "
<<
debugSourceName
(
_source
)
<<
": "
<<
_message
<<
endl
;
}
// delete all errors to not create another error log for the same problem:
int
tries
(
100
);
while
(
glGetError
()
!=
GL_NO_ERROR
&&
--
tries
>
0
)
{}
while
(
glGetError
()
!=
GL_NO_ERROR
)
{}
}
}
// OpenGL
...
...
src/ACGL/OpenGL/Objects/Shader.cc
View file @
559c5253
...
...
@@ -15,7 +15,7 @@
using
namespace
ACGL
::
Utils
;
using
namespace
ACGL
::
OpenGL
;
/*
bool Shader::setFromFileNoImportParsing(const std::string& _filename)
{
std::string line = "";
...
...
@@ -51,7 +51,7 @@ bool Shader::setFromFileNoImportParsing(const std::string& _filename)
}
}
return !compileErrors; // return true iff there were no errors
}
}
*/
bool
Shader
::
setFromFile
(
SharedShaderParser
const
&
_sp
)
{
...
...
@@ -69,6 +69,11 @@ bool Shader::setFromFile(SharedShaderParser const& _sp)
}
}
}
#ifdef ACGL_OPENGL_DEBUGGER_SUPPORT
glObjectLabel
(
GL_SHADER
,
mObjectName
,
-
1
,
_sp
->
getSources
()[
0
].
c_str
()
);
#endif
return
!
compileErrors
;
// return true iff there were no errors
}
...
...
src/ACGL/OpenGL/Tools.cc
View file @
559c5253
...
...
@@ -291,7 +291,6 @@ GLenum openGLError_( const char *_fileName, const unsigned long _lineNumber )
return
lastError
;
// returns the last real error (in case there was at least one!)
}
}
// OpenGL
}
// ACGL
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