13 #ifndef OGLPLUS_EXT_KHR_DEBUG_1308270710_HPP
14 #define OGLPLUS_EXT_KHR_DEBUG_1308270710_HPP
17 #include <oglplus/config/compiler.hpp>
30 #include <unordered_set>
35 #if OGLPLUS_DOCUMENTATION_ONLY || GL_KHR_debug
47 OGLPLUS_EXTENSION_CLASS(KHR, debug)
59 OGLPLUS_GLFUNC(DebugMessageControl)(
64 enable ? GL_TRUE : GL_FALSE
66 OGLPLUS_VERIFY_SIMPLE(DebugMessageControl);
77 Control(source, type, severity, 0,
nullptr, enable);
81 template <std::
size_t N>
86 const GLuint (&ids)[N],
90 Control(source, type, severity, N, ids, enable);
122 typedef std::function<void (const CallbackData&)>
Callback;
133 static void GLAPIENTRY _gl_debug_proc(
139 const GLchar* message,
154 self->_callback(data);
159 GLDEBUGPROC _prev_callback;
164 : _callback(callback)
165 , _prev_callback(nullptr)
166 , _prev_context(nullptr)
169 GLDEBUGPROC _tmp_callback =
nullptr;
170 void** _tmp_ptr=
reinterpret_cast<void**
>(&_tmp_callback);
171 OGLPLUS_GLFUNC(GetPointerv)(
172 GL_DEBUG_CALLBACK_FUNCTION,
175 OGLPLUS_IGNORE(GetPointerv);
176 _prev_callback = _tmp_callback;
179 OGLPLUS_GLFUNC(GetPointerv)(
180 GL_DEBUG_CALLBACK_USER_PARAM,
183 OGLPLUS_IGNORE(GetPointerv);
185 OGLPLUS_GLFUNC(DebugMessageCallback)(
186 GLDEBUGPROC(&LogSink::_gl_debug_proc),
187 static_cast<void*
>(
this)
189 OGLPLUS_VERIFY_SIMPLE(DebugMessageCallback);
192 #if !OGLPLUS_NO_DELETED_FUNCTIONS
206 OGLPLUS_GLFUNC(DebugMessageCallback)(
224 OGLPLUS_GLFUNC(DebugMessageInsert)(
232 OGLPLUS_VERIFY_SIMPLE(DebugMessageInsert);
255 template <std::
size_t N>
261 const GLchar (&message)[N]
279 const GLchar* message
282 OGLPLUS_GLFUNC(PushDebugGroup)(
288 OGLPLUS_VERIFY_SIMPLE(PushDebugGroup);
302 template <std::
size_t N>
306 const GLchar (&message)[N]
315 OGLPLUS_GLFUNC(PopDebugGroup)();
316 OGLPLUS_VERIFY_SIMPLE(PopDebugGroup);
324 OGLPLUS_GLFUNC(
Enable)(GL_DEBUG_OUTPUT_SYNCHRONOUS);
325 OGLPLUS_VERIFY_SIMPLE(
Enable);
329 OGLPLUS_GLFUNC(Disable)(GL_DEBUG_OUTPUT_SYNCHRONOUS);
330 OGLPLUS_VERIFY_SIMPLE(Disable);
342 template <
typename Essence>
343 class KHR_debug_CallbackWithEssence
346 std::shared_ptr<Essence> essence;
350 KHR_debug_CallbackWithEssence(
351 typename Essence::CtrParam param
352 ): essence(std::make_shared<Essence>(param))
355 void operator()(
const KHR_debug::CallbackData& data)
360 operator Callback (
void)
const
362 return Callback(*
this);
366 class KHR_debug_UniqueEssence
373 std::unordered_set<String> already_done;
375 KHR_debug_UniqueEssence(
const KHR_debug_UniqueEssence&);
377 typedef const Callback& CtrParam;
379 KHR_debug_UniqueEssence(
const Callback& callback)
380 : _callback(callback)
383 void Call(
const KHR_debug::CallbackData& data);
386 #if OGLPLUS_DOCUMENTATION_ONLY
405 typedef KHR_debug_CallbackWithEssence<KHR_debug_UniqueEssence>
410 class KHR_debug_TreeEssence
413 std::ostream& dbgout;
415 KHR_debug_TreeEssence(
const KHR_debug_TreeEssence&);
417 typedef std::ostream& CtrParam;
419 KHR_debug_TreeEssence(std::ostream& out);
420 ~KHR_debug_TreeEssence(
void);
425 #if OGLPLUS_DOCUMENTATION_ONLY
443 typedef KHR_debug_CallbackWithEssence<KHR_debug_TreeEssence>
448 class KHR_debug_ToXMLEssence
451 std::ostream& dbgout;
453 KHR_debug_ToXMLEssence(
const KHR_debug_ToXMLEssence&);
455 typedef std::ostream& CtrParam;
457 KHR_debug_ToXMLEssence(std::ostream& out);
458 ~KHR_debug_ToXMLEssence(
void);
463 #if OGLPLUS_DOCUMENTATION_ONLY
480 typedef KHR_debug_CallbackWithEssence<KHR_debug_ToXMLEssence>
488 #if !OGLPLUS_LINK_LIBRARY || defined(OGLPLUS_IMPLEMENTING_LIBRARY)
489 #include <oglplus/ext/KHR_debug.ipp>
490 #endif // OGLPLUS_LINK_LIBRARY
492 #endif // include guard
const Char * c_str(void) const
Returns the null-terminated c-string.
Definition: ref_tpl.hpp:200
static void PushGroup(DebugSource source, GLuint id, const GLchar(&message)[N])
Pushes a debug group.
Definition: KHR_debug.hpp:303
DebugType type
The type of the debug message.
Definition: KHR_debug.hpp:100
Funcions and classes for handling and wrapping OpenGL extensions.
The DebugSeverity enumeration.
Structure containing data passed to Callback functor.
Definition: KHR_debug.hpp:94
DebugType
Debug output type enumeration.
Definition: type.hpp:27
static void Control(DebugSource source, DebugType type, DebugSeverity severity, const GLuint(&ids)[N], bool enable)
Enables/disables messages with specific parameters.
Definition: KHR_debug.hpp:82
static void Synchronous(bool enable=true)
Enables or disables synchronous debug output.
Definition: KHR_debug.hpp:320
std::function< void(const CallbackData &)> Callback
Type of a callback functor processing debug output.
Definition: KHR_debug.hpp:122
static void PopGroup(void)
Pops a debug group.
Definition: KHR_debug.hpp:313
String type definition and related functions.
DebugSeverity severity
The severity of the debug message.
Definition: KHR_debug.hpp:106
static void Control(DebugSource source, DebugType type, DebugSeverity severity, GLsizei count, const GLuint *ids, bool enable)
Enables/disables messages with specific parameters.
Definition: KHR_debug.hpp:50
KHR_debug_Tree(std::ostream &)
Constructor takes a reference to standard output stream.
::std::basic_string< ALchar > String
Wrapper for the KHR_debug extension.
Definition: KHR_debug.hpp:44
DebugSeverity
Debug output severity enumeration.
Definition: severity.hpp:27
static void PushGroup(DebugSource source, GLuint id, GLsizei length, const GLchar *message)
Pushes a debug group.
Definition: KHR_debug.hpp:275
LogSink(Callback callback)
Installs the callback and remembers the previous.
Definition: KHR_debug.hpp:163
std::size_t size(void) const
Return the size (length) string.
Definition: ref_tpl.hpp:149
GLsizei length
The length of th debug message.
Definition: KHR_debug.hpp:109
String const reference wrapper template.
Definition: ref_tpl.hpp:72
static void InsertMessage(DebugSource source, DebugType type, GLuint id, DebugSeverity severity, const GLchar(&message)[N])
Inserts a new message into the debug output.
Definition: KHR_debug.hpp:256
Helper macro for optional checking of availability of GL function.
KHR_debug_ToXML(std::ostream &)
Constructor takes a reference to standard output stream.
Filter for KHR_debug printing a simple tree to a standard output.
Definition: KHR_debug.hpp:433
static void PushGroup(DebugSource source, GLuint id, StrCRef message)
Pushes a debug group.
Definition: KHR_debug.hpp:292
static void Asynchronous(bool enable=true)
Enables or disables asynchronous debug output.
Definition: KHR_debug.hpp:335
KHR_debug_Unique(KHR_debug::Callback)
Construction takes another callback implementation.
The DebugSource enumeration.
The DebugType enumeration.
static void InsertMessage(DebugSource source, DebugType type, GLuint id, DebugSeverity severity, GLint length, const GLchar *buffer)
Inserts a new message into the debug output.
Definition: KHR_debug.hpp:215
static void InsertMessage(DebugSource source, DebugType type, GLuint id, DebugSeverity severity, StrCRef message)
Inserts a new message into the debug output.
Definition: KHR_debug.hpp:236
const GLchar * message
The debug message.
Definition: KHR_debug.hpp:112
~LogSink(void)
Restores the previous callback and its context.
Definition: KHR_debug.hpp:202
GLuint id
The id of the debug message.
Definition: KHR_debug.hpp:103
static void Control(DebugSource source, DebugType type, DebugSeverity severity, bool enable)
Enables/disables messages with specific parameters.
Definition: KHR_debug.hpp:70
Filter for KHR_debug removing duplicate messages.
Definition: KHR_debug.hpp:395
DebugSource
Debug output source enumeration.
Definition: source.hpp:27
DebugSource source
The source of the debug message.
Definition: KHR_debug.hpp:97
Filter for KHR_debug formatting the debug output into XML.
Definition: KHR_debug.hpp:470
Installs a custom callback processing the debug output.
Definition: KHR_debug.hpp:130