Skip to content
GitLab
Menu
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
294b0abb
Commit
294b0abb
authored
Sep 03, 2013
by
Robert Menzel
Browse files
comments and cleanups
parent
a6f63dd3
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/ACGL/OpenGL/glloaders/KHR_debug_emulator.cc
View file @
294b0abb
// include your OpenGL header here:
#include <ACGL/OpenGL/GL.hh>
//#include <iostream>
//using namespace std;
/*
* Simulates KHR_debug
*
* Use-cases:
* ----------
*
* Use this as a fallback on systems that don't implement KHR_debug for debugging only,
* don't use this code in shipping release builds - it will slow down the application!
* Using a debug callback instead of lots of glGetError() calls should work fine,
* MessageControl, DebugGroups and DebugLabels are only implemented as fallbacks, in case
* you have to rely on those features, you want to reimplement them in a more efficient way.
*
*
* Known restrictions:
* -------------------
*
* Wrong behavior:
* ---------------
*
* * Does not support multiple OpenGL contexts, all errors from all contexts are mixed.
* All settings (including the debug callback) are set for all contexts.
*
* * glObjectLabel and glObjectPtrLabel do not check if the object to label exists and thus
* will not generate a GL_INVALID_VALUE.
*
* * glObjectLabel can label GL_DISPLAY_LIST even in Core profiles.
*
* Inefficiency:
* -------------
*
* * Using this, the number of GL calls doubles as each call will get followed by a glGetError.
* * This will also force OpenGL to run synchronous which will reduce the performance!
* * ObjectLabels are implemented inefficiently and are not used internally. The functionality is
* only present to be compatible with KHR_debug.
* * DebugGroups and glDebugMessageControl are not efficiently implemented.
* * Some memory will not get released.
*
* Implementation dependent limits:
* --------------------------------
*
* * GL_MAX_DEBUG_MESSAGE_LENGTH and Gl_MAX_LABEL_LENGTH are arbitrary and can be changed.
* * GL_MAX_DEBUG_GROUP_STACK_DEPTH is set to the lowest allowed value of 64 but can be changed
* * GL_DEBUG_LOGGED_MESSAGES is set to 1 - increasing this will be more work.
*
* * This implementation always behaves synchronous, even if GL_DEBUG_OUTPUT_SYNCHRONOUS is
* disabled (the default btw.). This is legal by the spec.
*/
#include <string.h>
#include <stdio.h>
...
...
@@ -264,15 +310,27 @@ GLuint KHR_DEBUG_EMULATOR_GetDebugMessageLog(GLuint count, GLsizei bufsize, GLen
return
1
;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
///
/// Handling of ObjectLabels:
/// ( not very pretty, just for compatibility )
///
///////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef GL_TRANSFORM_FEEDBACK
#define GL_TRANSFORM_FEEDBACK 0x8E22
#endif
#ifndef GL_DISPLAY_LIST
#define GL_DISPLAY_LIST 0x82E7
#endif
GLboolean
isValidObjectLabelNamespace
(
GLenum
e
)
{
if
(
e
==
GL_BUFFER
||
e
==
GL_SHADER
||
e
==
GL_PROGRAM
||
e
==
GL_VERTEX_ARRAY
||
e
==
GL_QUERY
||
e
==
GL_PROGRAM_PIPELINE
||
e
==
GL_TRANSFORM_FEEDBACK
||
e
==
GL_SAMPLER
||
e
==
GL_TEXTURE
||
e
==
GL_RENDERBUFFER
||
e
==
GL_FRAMEBUFFER
)
{
||
e
==
GL_SAMPLER
||
e
==
GL_TEXTURE
||
e
==
GL_RENDERBUFFER
||
e
==
GL_FRAMEBUFFER
||
e
==
GL_DISPLAY_LIST
)
{
return
true
;
}
...
...
@@ -407,6 +465,12 @@ void KHR_DEBUG_EMULATOR_GetObjectLabel(GLenum identifier, GLuint name, GLsizei b
*
length
=
size
;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
///
/// Handling of ObjectPtrLabels:
/// ( not very pretty, just for compatibility )
///
///////////////////////////////////////////////////////////////////////////////////////////////////
void
KHR_DEBUG_EMULATOR_ObjectPtrLabel
(
const
void
*
ptr
,
GLsizei
length
,
const
GLchar
*
label
)
{
...
...
@@ -418,6 +482,12 @@ void KHR_DEBUG_EMULATOR_GetObjectPtrLabel(const void * ptr, GLsizei bufSize, GLs
KHR_DEBUG_EMULATOR_insertMissingFeatureError
(
"function not simulated yet - ignored"
);
}
///////////////////////////////////////////////////////////////////////////////////////////////////
///
/// Handling of DebugGroups
///
///////////////////////////////////////////////////////////////////////////////////////////////////
struct
DebugGroupDescription
{
GLenum
source
;
GLuint
id
;
...
...
@@ -529,6 +599,12 @@ GLboolean isValidSource( GLenum e )
return
false
;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
///
/// Generating errors:
///
///////////////////////////////////////////////////////////////////////////////////////////////////
const
char
*
KHR_DEBUG_EMULATOR_GET_ERROR_STRING
(
GLenum
_errorCode
)
{
if
(
_errorCode
==
GL_INVALID_ENUM
)
{
return
(
char
*
)
"OpenGL error: GL_INVALID_ENUM"
;
}
...
...
@@ -628,21 +704,27 @@ GLboolean KHR_DEBUG_EMULATOR_IsEnabled(GLenum cap){
// needs to recognize a few new tokens
//
void
KHR_DEBUG_EMULATOR_GetIntegerv
(
GLenum
pname
,
GLint
*
params
){
if
(
pname
==
GL_CONTEXT_FLAGS
)
{
_original_glGetIntegerv
(
pname
,
params
);
*
params
|=
GL_CONTEXT_FLAG_DEBUG_BIT
;
// we make this a debug context ;-)
}
else
if
(
pname
==
GL_MAX_DEBUG_MESSAGE_LENGTH
)
{
*
params
=
KHR_DEBUG_EMULATOR_MAX_DEBUG_MESSAGE_LENGTH
;
}
else
if
(
pname
==
GL_MAX_DEBUG_LOGGED_MESSAGES
)
{
*
params
=
KHR_DEBUG_EMULATOR_MAX_DEBUG_LOGGED_MESSAGES
;
}
else
if
(
pname
==
GL_MAX_DEBUG_GROUP_STACK_DEPTH
)
{
*
params
=
KHR_DEBUG_EMULATOR_MAX_DEBUG_GROUP_STACK_DEPTH
;
}
else
if
(
pname
==
GL_MAX_LABEL_LENGTH
)
{
*
params
=
KHR_DEBUG_EMULATOR_MAX_LABEL_LENGTH
;
}
else
{
_original_glGetIntegerv
(
pname
,
params
);
}
KHR_DEBUG_EMULATOR_CHECK_GL_ERROR
();
if
(
pname
==
GL_CONTEXT_FLAGS
)
{
_original_glGetIntegerv
(
pname
,
params
);
*
params
|=
GL_CONTEXT_FLAG_DEBUG_BIT
;
// we make this a debug context ;-)
}
else
if
(
pname
==
GL_MAX_DEBUG_MESSAGE_LENGTH
)
{
*
params
=
KHR_DEBUG_EMULATOR_MAX_DEBUG_MESSAGE_LENGTH
;
}
else
if
(
pname
==
GL_MAX_DEBUG_LOGGED_MESSAGES
)
{
*
params
=
KHR_DEBUG_EMULATOR_MAX_DEBUG_LOGGED_MESSAGES
;
}
else
if
(
pname
==
GL_MAX_DEBUG_GROUP_STACK_DEPTH
)
{
*
params
=
KHR_DEBUG_EMULATOR_MAX_DEBUG_GROUP_STACK_DEPTH
;
}
else
if
(
pname
==
GL_MAX_LABEL_LENGTH
)
{
*
params
=
KHR_DEBUG_EMULATOR_MAX_LABEL_LENGTH
;
}
else
if
(
pname
==
GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH
)
{
if
(
g_LastDebugMessageEmpty
)
{
*
params
=
0
;
}
else
{
*
params
=
g_LastDebugMessage
.
length
;
}
}
else
{
_original_glGetIntegerv
(
pname
,
params
);
}
KHR_DEBUG_EMULATOR_CHECK_GL_ERROR
();
}
//
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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