Browse Source

Added non-allocating char array overload to DebugMessage::insert().

pull/68/head
Vladimír Vondruš 12 years ago
parent
commit
4a6f53cdc8
  1. 18
      src/Magnum/DebugMessage.cpp
  2. 19
      src/Magnum/DebugMessage.h
  3. 2
      src/Magnum/Implementation/DebugState.h

18
src/Magnum/DebugMessage.cpp

@ -98,10 +98,6 @@ Int DebugMessage::maxMessageLength() {
return value;
}
void DebugMessage::insert(const Source source, const Type type, const UnsignedInt id, const Severity severity, const std::string& string) {
Context::current()->state().debug->messageInsertImplementation(source, type, id, severity, string);
}
void DebugMessage::setCallback(const Callback callback, const void* userParam) {
Context::current()->state().debug->messageCallbackImplementation(callback, userParam);
}
@ -110,9 +106,13 @@ void DebugMessage::setDefaultCallback() {
setCallback(defaultCallback, nullptr);
}
void DebugMessage::insertImplementationNoOp(Source, Type, UnsignedInt, Severity, const std::string&) {}
void DebugMessage::insertInternal(const Source source, const Type type, const UnsignedInt id, const Severity severity, const Containers::ArrayReference<const char> string) {
Context::current()->state().debug->messageInsertImplementation(source, type, id, severity, string);
}
void DebugMessage::insertImplementationNoOp(Source, Type, UnsignedInt, Severity, const Containers::ArrayReference<const char>) {}
void DebugMessage::insertImplementationKhr(const Source source, const Type type, const UnsignedInt id, const Severity severity, const std::string& string) {
void DebugMessage::insertImplementationKhr(const Source source, const Type type, const UnsignedInt id, const Severity severity, const Containers::ArrayReference<const char> string) {
/** @todo Re-enable when extension wrangler is available for ES */
#ifndef MAGNUM_TARGET_GLES
glDebugMessageInsert(GLenum(source), GLenum(type), id, GLenum(severity), string.size(), string.data());
@ -127,7 +127,7 @@ void DebugMessage::insertImplementationKhr(const Source source, const Type type,
#endif
}
void DebugMessage::insertImplementationExt(Source, Type, UnsignedInt, Severity, const std::string& string) {
void DebugMessage::insertImplementationExt(Source, Type, UnsignedInt, Severity, const Containers::ArrayReference<const char> string) {
/** @todo Re-enable when extension wrangler is available for ES */
#ifndef MAGNUM_TARGET_GLES
glInsertEventMarkerEXT(string.size(), string.data());
@ -138,8 +138,8 @@ void DebugMessage::insertImplementationExt(Source, Type, UnsignedInt, Severity,
}
#ifndef MAGNUM_TARGET_GLES
void DebugMessage::insertImplementationGremedy(Source, Type, UnsignedInt, Severity, const std::string& string) {
glStringMarkerGREMEDY(string.length(), string.data());
void DebugMessage::insertImplementationGremedy(Source, Type, UnsignedInt, Severity, const Containers::ArrayReference<const char> string) {
glStringMarkerGREMEDY(string.size(), string.data());
}
#endif

19
src/Magnum/DebugMessage.h

@ -30,6 +30,7 @@
*/
#include <string>
#include <Corrade/Containers/Array.h>
#include "Magnum/Magnum.h"
#include "Magnum/OpenGL.h"
@ -272,7 +273,14 @@ class MAGNUM_EXPORT DebugMessage {
* @fn_gl_extension2{InsertEventMarker,EXT,debug_marker} or
* @fn_gl_extension{StringMarker,GREMEDY,string_marker}
*/
static void insert(Source source, Type type, UnsignedInt id, Severity severity, const std::string& string);
static void insert(Source source, Type type, UnsignedInt id, Severity severity, const std::string& string) {
insertInternal(source, type, id, severity, {string.data(), string.size()});
}
/** @overload */
template<std::size_t size> static void insert(Source source, Type type, UnsignedInt id, Severity severity, const char(&string)[size]) {
insertInternal(source, type, id, severity, {string, size - 1});
}
/**
* @brief Set debug message callback
@ -306,11 +314,12 @@ class MAGNUM_EXPORT DebugMessage {
DebugMessage() = delete;
private:
static MAGNUM_LOCAL void insertImplementationNoOp(Source, Type, UnsignedInt, Severity, const std::string&);
static MAGNUM_LOCAL void insertImplementationKhr(Source source, Type type, UnsignedInt id, Severity severity, const std::string& string);
static MAGNUM_LOCAL void insertImplementationExt(Source, Type, UnsignedInt, Severity, const std::string& string);
static void insertInternal(Source source, Type type, UnsignedInt id, Severity severity, Containers::ArrayReference<const char> string);
static MAGNUM_LOCAL void insertImplementationNoOp(Source, Type, UnsignedInt, Severity, Containers::ArrayReference<const char>);
static MAGNUM_LOCAL void insertImplementationKhr(Source source, Type type, UnsignedInt id, Severity severity, Containers::ArrayReference<const char> string);
static MAGNUM_LOCAL void insertImplementationExt(Source, Type, UnsignedInt, Severity, Containers::ArrayReference<const char> string);
#ifndef MAGNUM_TARGET_GLES
static MAGNUM_LOCAL void insertImplementationGremedy(Source, Type, UnsignedInt, Severity, const std::string& string);
static MAGNUM_LOCAL void insertImplementationGremedy(Source, Type, UnsignedInt, Severity, Containers::ArrayReference<const char> string);
#endif
static MAGNUM_LOCAL void callbackImplementationNoOp(Callback, const void*);

2
src/Magnum/Implementation/DebugState.h

@ -38,7 +38,7 @@ struct DebugState {
std::string(*getLabelImplementation)(GLenum, GLuint);
void(*labelImplementation)(GLenum, GLuint, Containers::ArrayReference<const char>);
void(*messageInsertImplementation)(DebugMessage::Source, DebugMessage::Type, UnsignedInt, DebugMessage::Severity, const std::string&);
void(*messageInsertImplementation)(DebugMessage::Source, DebugMessage::Type, UnsignedInt, DebugMessage::Severity, Containers::ArrayReference<const char>);
void(*messageCallbackImplementation)(DebugMessage::Callback, const void*);
GLint maxLabelLength, maxLoggedMessages, maxMessageLength;

Loading…
Cancel
Save