13 #ifndef OGLPLUS_EXT_ARB_DEBUG_OUTPUT_1203031902_HPP
14 #define OGLPLUS_EXT_ARB_DEBUG_OUTPUT_1203031902_HPP
17 #include <oglplus/config/compiler.hpp>
29 #include <unordered_set>
34 #if OGLPLUS_DOCUMENTATION_ONLY || GL_ARB_debug_output
46 OGLPLUS_EXTENSION_CLASS(ARB, debug_output)
56 OGLPLUS_GLFUNC(DebugMessageControlARB)(
61 enable ? GL_TRUE : GL_FALSE
63 OGLPLUS_VERIFY_SIMPLE(DebugMessageControlARB);
95 typedef std::function<void (const CallbackData&)>
Callback;
106 static void GLAPIENTRY _gl_debug_proc(
112 const GLchar* message,
127 self->_callback(data);
132 GLDEBUGPROCARB _prev_callback;
137 : _callback(callback)
138 , _prev_callback(nullptr)
139 , _prev_context(nullptr)
142 GLDEBUGPROCARB _tmp_callback =
nullptr;
143 void** _tmp_ptr=
reinterpret_cast<void**
>(&_tmp_callback);
144 OGLPLUS_GLFUNC(GetPointerv)(
145 GL_DEBUG_CALLBACK_FUNCTION_ARB,
148 OGLPLUS_IGNORE(GetPointerv);
149 _prev_callback = _tmp_callback;
152 OGLPLUS_GLFUNC(GetPointerv)(
153 GL_DEBUG_CALLBACK_USER_PARAM_ARB,
156 OGLPLUS_IGNORE(GetPointerv);
158 OGLPLUS_GLFUNC(DebugMessageCallbackARB)(
159 GLDEBUGPROCARB(&LogSink::_gl_debug_proc),
160 static_cast<void*
>(
this)
162 OGLPLUS_VERIFY_SIMPLE(DebugMessageCallbackARB);
165 #if !OGLPLUS_NO_DELETED_FUNCTIONS
179 OGLPLUS_GLFUNC(DebugMessageCallbackARB)(
192 OGLPLUS_GLFUNC(
Enable)(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
193 OGLPLUS_VERIFY_SIMPLE(
Enable);
197 OGLPLUS_GLFUNC(Disable)(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
198 OGLPLUS_VERIFY_SIMPLE(Disable);
208 const GLchar* buffer,
212 OGLPLUS_GLFUNC(DebugMessageInsertARB)(
220 OGLPLUS_VERIFY_SIMPLE(DebugMessageInsertARB);
232 OGLPLUS_GLFUNC(DebugMessageInsertARB)(
240 OGLPLUS_VERIFY_SIMPLE(DebugMessageInsertARB);
244 template <
typename Essence>
245 class ARB_debug_output_CallbackWithEssence
248 std::shared_ptr<Essence> essence;
252 ARB_debug_output_CallbackWithEssence(
253 typename Essence::CtrParam param
254 ): essence(std::make_shared<Essence>(param))
257 void operator()(
const ARB_debug_output::CallbackData& data)
262 operator Callback (
void)
const
264 return Callback(*
this);
268 class ARB_debug_output_UniqueEssence
275 std::unordered_set<String> already_done;
277 ARB_debug_output_UniqueEssence(
const ARB_debug_output_UniqueEssence&);
279 typedef const Callback& CtrParam;
281 ARB_debug_output_UniqueEssence(
const Callback& callback)
282 : _callback(callback)
285 void Call(
const ARB_debug_output::CallbackData& data);
288 #if OGLPLUS_DOCUMENTATION_ONLY
307 typedef ARB_debug_output_CallbackWithEssence<ARB_debug_output_UniqueEssence>
312 class ARB_debug_output_TreeEssence
315 std::ostream& dbgout;
317 ARB_debug_output_TreeEssence(
const ARB_debug_output_TreeEssence&);
319 typedef std::ostream& CtrParam;
321 ARB_debug_output_TreeEssence(std::ostream& out);
322 ~ARB_debug_output_TreeEssence(
void);
327 #if OGLPLUS_DOCUMENTATION_ONLY
345 typedef ARB_debug_output_CallbackWithEssence<ARB_debug_output_TreeEssence>
350 class ARB_debug_output_ToXMLEssence
353 std::ostream& dbgout;
355 ARB_debug_output_ToXMLEssence(
const ARB_debug_output_ToXMLEssence&);
357 typedef std::ostream& CtrParam;
359 ARB_debug_output_ToXMLEssence(std::ostream& out);
360 ~ARB_debug_output_ToXMLEssence(
void);
365 #if OGLPLUS_DOCUMENTATION_ONLY
382 typedef ARB_debug_output_CallbackWithEssence<ARB_debug_output_ToXMLEssence>
386 #endif // ARB_debug_output
390 #if !OGLPLUS_LINK_LIBRARY || defined(OGLPLUS_IMPLEMENTING_LIBRARY)
391 #include <oglplus/ext/ARB_debug_output.ipp>
392 #endif // OGLPLUS_LINK_LIBRARY
394 #endif // include guard
DebugOutputARBType type
The type of the debug message.
Definition: ARB_debug_output.hpp:73
The DebugOutputARBType enumeration.
const Char * c_str(void) const
Returns the null-terminated c-string.
Definition: ref_tpl.hpp:200
ARB_debug_output_Unique(ARB_debug_output::Callback)
Construction takes another callback implementation.
LogSink(Callback callback)
Installs the callback and remembers the previous.
Definition: ARB_debug_output.hpp:136
static void InsertMessage(DebugOutputARBSource source, DebugOutputARBType type, GLuint id, DebugOutputARBSeverity severity, StrCRef message)
Inserts a new message into the debug output.
Definition: ARB_debug_output.hpp:224
Wrapper for the ARB_debug_output extension.
Definition: ARB_debug_output.hpp:43
Installs a custom callback processing the debug output.
Definition: ARB_debug_output.hpp:103
Funcions and classes for handling and wrapping OpenGL extensions.
DebugOutputARBSource source
The source of the debug message.
Definition: ARB_debug_output.hpp:70
DebugOutputARBSeverity severity
The severity of the debug message.
Definition: ARB_debug_output.hpp:79
The DebugOutputARBSeverity enumeration.
~LogSink(void)
Restores the previous callback and its context.
Definition: ARB_debug_output.hpp:175
String type definition and related functions.
DebugOutputARBSeverity
Debug output severity enumeration.
Definition: severity.hpp:27
DebugOutputARBType
Debug output type enumeration.
Definition: type.hpp:27
ARB_debug_output_ToXML(std::ostream &)
Constructor takes a reference to standard output stream.
::std::basic_string< ALchar > String
Filter for ARB_debug_output removing duplicate messages.
Definition: ARB_debug_output.hpp:297
The DebugOutputARBSource enumeration.
std::size_t size(void) const
Return the size (length) string.
Definition: ref_tpl.hpp:149
static void Control(DebugOutputARBSource source, DebugOutputARBType type, DebugOutputARBSeverity severity, bool enable)
Enables/disables messages with specific parameters.
Definition: ARB_debug_output.hpp:49
String const reference wrapper template.
Definition: ref_tpl.hpp:72
GLsizei length
The length of th debug message.
Definition: ARB_debug_output.hpp:82
Helper macro for optional checking of availability of GL function.
Filter for ARB_debug_output formatting the debug output into XML.
Definition: ARB_debug_output.hpp:372
DebugOutputARBSource
Debug output source enumeration.
Definition: source.hpp:27
Filter for ARB_debug_output printing a simple tree to a standard output.
Definition: ARB_debug_output.hpp:335
GLuint id
The id of the debug message.
Definition: ARB_debug_output.hpp:76
std::function< void(const CallbackData &)> Callback
Type of a callback functor processing debug output.
Definition: ARB_debug_output.hpp:95
Structure containing data passed to Callback functor.
Definition: ARB_debug_output.hpp:67
static void Synchronous(bool enable)
Enables or disables synchronous debug output.
Definition: ARB_debug_output.hpp:188
ARB_debug_output_Tree(std::ostream &)
Constructor takes a reference to standard output stream.
static void InsertMessage(DebugOutputARBSource source, DebugOutputARBType type, GLuint id, DebugOutputARBSeverity severity, const GLchar *buffer, GLint length=-1)
Inserts a new message into the debug output.
Definition: ARB_debug_output.hpp:203
const GLchar * message
The debug message.
Definition: ARB_debug_output.hpp:85