![]() |
Qt 6.x
The Qt SDK
|
The QOpenGLDebugLogger enables logging of OpenGL debugging messages. More...
#include <qopengldebug.h>
Public Types | |
enum | LoggingMode { AsynchronousLogging , SynchronousLogging } |
The LoggingMode enum defines the logging mode of the logger object. More... | |
Public Slots | |
void | logMessage (const QOpenGLDebugMessage &debugMessage) |
Inserts the message debugMessage into the OpenGL debug log. | |
void | startLogging (LoggingMode loggingMode=AsynchronousLogging) |
Starts logging messages coming from the OpenGL server. | |
void | stopLogging () |
Stops logging messages from the OpenGL server. | |
![]() | |
void | deleteLater () |
\threadsafe | |
Signals | |
void | messageLogged (const QOpenGLDebugMessage &debugMessage) |
This signal is emitted when a debug message (wrapped by the debugMessage argument) is logged from the OpenGL server. | |
![]() | |
void | destroyed (QObject *=nullptr) |
This signal is emitted immediately before the object obj is destroyed, after any instances of QPointer have been notified, and cannot be blocked. | |
void | objectNameChanged (const QString &objectName, QPrivateSignal) |
This signal is emitted after the object's name has been changed. | |
Public Member Functions | |
QOpenGLDebugLogger (QObject *parent=nullptr) | |
Constructs a new logger object with the given parent. | |
~QOpenGLDebugLogger () | |
Destroys the logger object. | |
bool | initialize () |
Initializes the object in the current OpenGL context. | |
bool | isLogging () const |
Returns true if this object is currently logging, false otherwise. | |
LoggingMode | loggingMode () const |
Returns the logging mode of the object. | |
qint64 | maximumMessageLength () const |
Returns the maximum supported length, in bytes, for the text of the messages passed to logMessage(). | |
void | pushGroup (const QString &name, GLuint id=0, QOpenGLDebugMessage::Source source=QOpenGLDebugMessage::ApplicationSource) |
Pushes a debug group with name name, id id, and source source onto the debug groups stack. | |
void | popGroup () |
Pops the topmost debug group from the debug groups stack. | |
void | enableMessages (QOpenGLDebugMessage::Sources sources=QOpenGLDebugMessage::AnySource, QOpenGLDebugMessage::Types types=QOpenGLDebugMessage::AnyType, QOpenGLDebugMessage::Severities severities=QOpenGLDebugMessage::AnySeverity) |
Enables the logging of messages from the given sources, of the given types and with the given severities and any message id. | |
void | enableMessages (const QList< GLuint > &ids, QOpenGLDebugMessage::Sources sources=QOpenGLDebugMessage::AnySource, QOpenGLDebugMessage::Types types=QOpenGLDebugMessage::AnyType) |
Enables the logging of messages with the given ids, from the given sources and of the given types and any severity. | |
void | disableMessages (QOpenGLDebugMessage::Sources sources=QOpenGLDebugMessage::AnySource, QOpenGLDebugMessage::Types types=QOpenGLDebugMessage::AnyType, QOpenGLDebugMessage::Severities severities=QOpenGLDebugMessage::AnySeverity) |
Disables the logging of messages with the given sources, of the given types and with the given severities and any message id. | |
void | disableMessages (const QList< GLuint > &ids, QOpenGLDebugMessage::Sources sources=QOpenGLDebugMessage::AnySource, QOpenGLDebugMessage::Types types=QOpenGLDebugMessage::AnyType) |
Disables the logging of messages with the given ids, from the given sources and of the given types and any severity. | |
QList< QOpenGLDebugMessage > | loggedMessages () const |
Reads all the available messages in the OpenGL internal debug log and returns them. | |
![]() | |
Q_INVOKABLE | QObject (QObject *parent=nullptr) |
Constructs an object with parent object parent. | |
virtual | ~QObject () |
Destroys the object, deleting all its child objects. | |
virtual bool | event (QEvent *event) |
This virtual function receives events to an object and should return true if the event e was recognized and processed. | |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
Filters events if this object has been installed as an event filter for the watched object. | |
QString | objectName () const |
Q_WEAK_OVERLOAD void | setObjectName (const QString &name) |
Sets the object's name to name. | |
void | setObjectName (QAnyStringView name) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
QBindable< QString > | bindableObjectName () |
bool | isWidgetType () const |
Returns true if the object is a widget; otherwise returns false . | |
bool | isWindowType () const |
Returns true if the object is a window; otherwise returns false . | |
bool | isQuickItemType () const |
Returns true if the object is a QQuickItem; otherwise returns false . | |
bool | signalsBlocked () const noexcept |
Returns true if signals are blocked; otherwise returns false . | |
bool | blockSignals (bool b) noexcept |
If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). | |
QThread * | thread () const |
Returns the thread in which the object lives. | |
void | moveToThread (QThread *thread) |
Changes the thread affinity for this object and its children. | |
int | startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer) |
This is an overloaded function that will start a timer of type timerType and a timeout of interval milliseconds. | |
int | startTimer (std::chrono::milliseconds time, Qt::TimerType timerType=Qt::CoarseTimer) |
void | killTimer (int id) |
Kills the timer with timer identifier, id. | |
template<typename T > | |
T | findChild (const QString &aName=QString(), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
Returns the child of this object that can be cast into type T and that is called name, or \nullptr if there is no such object. | |
template<typename T > | |
QList< T > | findChildren (const QString &aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. | |
template<typename T > | |
QList< T > | findChildren (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
const QObjectList & | children () const |
Returns a list of child objects. | |
void | setParent (QObject *parent) |
Makes the object a child of parent. | |
void | installEventFilter (QObject *filterObj) |
Installs an event filter filterObj on this object. | |
void | removeEventFilter (QObject *obj) |
Removes an event filter object obj from this object. | |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const |
bool | disconnect (const char *signal=nullptr, const QObject *receiver=nullptr, const char *member=nullptr) const |
bool | disconnect (const QObject *receiver, const char *member=nullptr) const |
void | dumpObjectTree () const |
Dumps a tree of children to the debug output. | |
void | dumpObjectInfo () const |
Dumps information about signal connections, etc. | |
bool | setProperty (const char *name, const QVariant &value) |
Sets the value of the object's name property to value. | |
bool | setProperty (const char *name, QVariant &&value) |
QVariant | property (const char *name) const |
Returns the value of the object's name property. | |
QList< QByteArray > | dynamicPropertyNames () const |
QBindingStorage * | bindingStorage () |
const QBindingStorage * | bindingStorage () const |
QObject * | parent () const |
Returns a pointer to the parent object. | |
bool | inherits (const char *classname) const |
Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false . | |
Properties | |
LoggingMode | loggingMode |
the logging mode passed to startLogging(). | |
![]() | |
QString | objectName |
the name of this object | |
Additional Inherited Members | |
![]() | |
static QMetaObject::Connection | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection) |
\threadsafe | |
static QMetaObject::Connection | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection) |
template<typename Func1 , typename Func2 > | |
static QMetaObject::Connection | connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::ContextTypeForFunctor< Func2 >::ContextType *context, Func2 &&slot, Qt::ConnectionType type=Qt::AutoConnection) |
template<typename Func1 , typename Func2 > | |
static QMetaObject::Connection | connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 &&slot) |
static bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member) |
\threadsafe | |
static bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member) |
static bool | disconnect (const QMetaObject::Connection &) |
Disconnect a connection. | |
template<typename Func1 , typename Func2 > | |
static bool | disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot) |
template<typename Func1 > | |
static bool | disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *receiver, void **zero) |
![]() | |
QObject * | sender () const |
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns \nullptr. | |
int | senderSignalIndex () const |
int | receivers (const char *signal) const |
Returns the number of receivers connected to the signal. | |
bool | isSignalConnected (const QMetaMethod &signal) const |
virtual void | timerEvent (QTimerEvent *event) |
This event handler can be reimplemented in a subclass to receive timer events for the object. | |
virtual void | childEvent (QChildEvent *event) |
This event handler can be reimplemented in a subclass to receive child events. | |
virtual void | customEvent (QEvent *event) |
This event handler can be reimplemented in a subclass to receive custom events. | |
virtual void | connectNotify (const QMetaMethod &signal) |
virtual void | disconnectNotify (const QMetaMethod &signal) |
QObject (QObjectPrivate &dd, QObject *parent=nullptr) | |
![]() | |
QScopedPointer< QObjectData > | d_ptr |
![]() | |
template< class T > T | qobject_cast (const QObject *object) |
Returns the given object cast to type T if the object is of type T (or of a subclass); otherwise returns \nullptr. | |
template< typename T > T | qFindChildqFindChildren (const QObject *obj, const QString &name)() |
template< typename T > QList< T > | qFindChildrenqFindChildren (const QObject *obj, const QString &name)() |
QObjectList | |
\macro Q_CLASSINFO(Name, Value) | |
The QOpenGLDebugLogger enables logging of OpenGL debugging messages.
\inmodule QtOpenGL
Definition at line 119 of file qopengldebug.h.
The LoggingMode enum defines the logging mode of the logger object.
\value AsynchronousLogging Messages from the OpenGL server are logged asynchronously. This means that messages can be logged some time after the corresponding OpenGL actions that caused them, and even be received in an out-of-order fashion, depending on the OpenGL implementation. This mode has a very low performance penalty, as OpenGL implementations are heavily threaded and asynchronous by nature.
\value SynchronousLogging Messages from the OpenGL server are logged synchronously and sequentially. This has a severe performance hit, as OpenGL implementations are very asynchronous by nature; but it's very useful to debug OpenGL problems, as OpenGL guarantees that the messages generated by a OpenGL command will be logged before the corresponding command execution has returned. Therefore, you can install a breakpoint on the messageLogged() signal and see in the backtrace which OpenGL command caused it; the only caveat is that if you are using OpenGL from multiple threads you may need to force direct connection when connecting to the messageLogged() signal.
Enumerator | |
---|---|
AsynchronousLogging | |
SynchronousLogging |
Definition at line 125 of file qopengldebug.h.
Constructs a new logger object with the given parent.
Definition at line 1266 of file qopengldebug.cpp.
QOpenGLDebugLogger::~QOpenGLDebugLogger | ( | ) |
Destroys the logger object.
Definition at line 1278 of file qopengldebug.cpp.
References stopLogging().
void QOpenGLDebugLogger::disableMessages | ( | const QList< GLuint > & | ids, |
QOpenGLDebugMessage::Sources | sources = QOpenGLDebugMessage::AnySource , |
||
QOpenGLDebugMessage::Types | types = QOpenGLDebugMessage::AnyType |
||
) |
Disables the logging of messages with the given ids, from the given sources and of the given types and any severity.
The logging will be disabled in the current control group.
Definition at line 1660 of file qopengldebug.cpp.
References QOpenGLDebugMessage::AnySeverity, d, and QByteArrayLiteral.
void QOpenGLDebugLogger::disableMessages | ( | QOpenGLDebugMessage::Sources | sources = QOpenGLDebugMessage::AnySource , |
QOpenGLDebugMessage::Types | types = QOpenGLDebugMessage::AnyType , |
||
QOpenGLDebugMessage::Severities | severities = QOpenGLDebugMessage::AnySeverity |
||
) |
Disables the logging of messages with the given sources, of the given types and with the given severities and any message id.
The logging will be disabled in the current control group.
Definition at line 1643 of file qopengldebug.cpp.
References d, and QByteArrayLiteral.
void QOpenGLDebugLogger::enableMessages | ( | const QList< GLuint > & | ids, |
QOpenGLDebugMessage::Sources | sources = QOpenGLDebugMessage::AnySource , |
||
QOpenGLDebugMessage::Types | types = QOpenGLDebugMessage::AnyType |
||
) |
Enables the logging of messages with the given ids, from the given sources and of the given types and any severity.
The logging will be enabled in the current control group.
Definition at line 1622 of file qopengldebug.cpp.
References QOpenGLDebugMessage::AnySeverity, d, and QByteArrayLiteral.
void QOpenGLDebugLogger::enableMessages | ( | QOpenGLDebugMessage::Sources | sources = QOpenGLDebugMessage::AnySource , |
QOpenGLDebugMessage::Types | types = QOpenGLDebugMessage::AnyType , |
||
QOpenGLDebugMessage::Severities | severities = QOpenGLDebugMessage::AnySeverity |
||
) |
Enables the logging of messages from the given sources, of the given types and with the given severities and any message id.
The logging will be enabled in the current control group.
Definition at line 1605 of file qopengldebug.cpp.
References d, and QByteArrayLiteral.
bool QOpenGLDebugLogger::initialize | ( | ) |
Initializes the object in the current OpenGL context.
The context must support the {GL_KHR_debug} extension for the initialization to succeed. The object must be initialized before any logging can happen.
It is safe to call this function multiple times from the same context.
This function can also be used to change the context of a previously initialized object; note that in this case the object must not be logging when you call this function.
Returns true
if the logger is successfully initialized; false otherwise.
Definition at line 1298 of file qopengldebug.cpp.
References QObject::connect(), context, QOpenGLContext::currentContext(), d, QSurfaceFormat::DebugContext, disconnect(), QOpenGLContext::functions(), GET_DEBUG_PROC_ADDRESS, GL_MAX_DEBUG_MESSAGE_LENGTH, QOpenGLFunctions::glGetIntegerv(), Q_ASSERT, QByteArrayLiteral, qWarning, SIGNAL, and SLOT.
Referenced by src_gui_opengl_qopengldebug::SnippetWrapper::wrapper1().
bool QOpenGLDebugLogger::isLogging | ( | ) | const |
Returns true
if this object is currently logging, false otherwise.
Definition at line 1365 of file qopengldebug.cpp.
References d.
QList< QOpenGLDebugMessage > QOpenGLDebugLogger::loggedMessages | ( | ) | const |
Reads all the available messages in the OpenGL internal debug log and returns them.
Moreover, this function will clear the internal debug log, so that subsequent invocations will not return messages that were already returned.
Definition at line 1681 of file qopengldebug.cpp.
References QByteArray::constData(), d, QByteArray::data(), QString::fromUtf8(), GLenum(), GLsizei(), GLuint, i, QOpenGLDebugMessagePrivate::id, QOpenGLDebugMessagePrivate::message, qt_messageSeverityFromGL(), qt_messageSourceFromGL(), qt_messageTypeFromGL(), qWarning, QByteArray::resize(), QOpenGLDebugMessagePrivate::severity, QByteArray::size(), QOpenGLDebugMessagePrivate::source, and QOpenGLDebugMessagePrivate::type.
Referenced by src_gui_opengl_qopengldebug::SnippetWrapper::wrapper1().
QOpenGLDebugLogger::LoggingMode QOpenGLDebugLogger::loggingMode | ( | ) | const |
Returns the logging mode of the object.
Definition at line 1430 of file qopengldebug.cpp.
References d.
|
slot |
Inserts the message debugMessage into the OpenGL debug log.
This provides a way for applications or libraries to insert custom messages that can ease the debugging of OpenGL applications.
Definition at line 1480 of file qopengldebug.cpp.
References QOpenGLDebugMessage::AnySeverity, QOpenGLDebugMessage::AnyType, QByteArray::append(), QOpenGLDebugMessage::ApplicationSource, QByteArray::constData(), d, GLenum(), QOpenGLDebugMessage::id(), QOpenGLDebugMessage::InvalidSeverity, QOpenGLDebugMessage::InvalidType, QOpenGLDebugMessage::message(), qt_messageSeverityToGL(), qt_messageSourceToGL(), qt_messageTypeToGL(), qWarning, QByteArray::resize(), QOpenGLDebugMessage::severity(), QByteArray::size(), QOpenGLDebugMessage::source(), QOpenGLDebugMessage::ThirdPartySource, QString::toUtf8(), and QOpenGLDebugMessage::type().
Referenced by src_gui_opengl_qopengldebug::SnippetWrapper::wrapper1().
qint64 QOpenGLDebugLogger::maximumMessageLength | ( | ) | const |
Returns the maximum supported length, in bytes, for the text of the messages passed to logMessage().
This is also the maximum length of a debug group name, as pushing or popping groups will automatically log a message with the debug group name as the message text.
If a message text is too long, it will be automatically truncated by QOpenGLDebugLogger.
Definition at line 1768 of file qopengldebug.cpp.
|
signal |
This signal is emitted when a debug message (wrapped by the debugMessage argument) is logged from the OpenGL server.
Depending on the OpenGL implementation, this signal can be emitted from other threads than the one(s) the receiver(s) lives in, and even different from the thread the QOpenGLContext in which this object has been initialized lives in. Moreover, the signal could be emitted from multiple threads at the same time. This is normally not a problem, as Qt will utilize a queued connection for cross-thread signal emissions, but if you force the connection type to Direct then you must be aware of the potential races in the slots connected to this signal.
If logging have been started in SynchronousLogging mode, OpenGL guarantees that this signal will be emitted from the same thread the QOpenGLContext has been bound to, and no concurrent invocations will ever happen.
Referenced by src_gui_opengl_qopengldebug::SnippetWrapper::wrapper1().
void QOpenGLDebugLogger::popGroup | ( | ) |
Pops the topmost debug group from the debug groups stack.
If the group is successfully popped, OpenGL will automatically log a message with message, id and source matching those of the popped group, type QOpenGLDebugMessage::GroupPopType and severity QOpenGLDebugMessage::NotificationSeverity.
Popping a debug group will restore the message filtering settings of the group that becomes the top of the debug groups stack.
Definition at line 1586 of file qopengldebug.cpp.
void QOpenGLDebugLogger::pushGroup | ( | const QString & | name, |
GLuint | id = 0 , |
||
QOpenGLDebugMessage::Source | source = QOpenGLDebugMessage::ApplicationSource |
||
) |
Pushes a debug group with name name, id id, and source source onto the debug groups stack.
If the group is successfully pushed, OpenGL will automatically log a message with message name, id id, source source, type QOpenGLDebugMessage::GroupPushType and severity QOpenGLDebugMessage::NotificationSeverity.
The newly pushed group will inherit the same filtering settings of the group that was on the top of the stack; that is, the filtering will not be changed by pushing a new group.
Definition at line 1543 of file qopengldebug.cpp.
References QByteArray::append(), QOpenGLDebugMessage::ApplicationSource, QByteArray::constData(), d, qt_messageSourceToGL(), qWarning, QByteArray::resize(), QByteArray::size(), and QOpenGLDebugMessage::ThirdPartySource.
|
slot |
Starts logging messages coming from the OpenGL server.
When a new message is received, the signal messageLogged() is emitted, carrying the logged message as argument.
loggingMode specifies whether the logging must be asynchronous (the default) or synchronous.
QOpenGLDebugLogger will record the values of {GL_DEBUG_OUTPUT} and
{GL_DEBUG_OUTPUT_SYNCHRONOUS} when logging is started, and set them back when logging is stopped. Moreover, any user-defined OpenGL debug callback installed when this function is invoked will be restored when logging is stopped; QOpenGLDebugLogger will ensure that the pre-existing callback will still be invoked when logging.
Definition at line 1393 of file qopengldebug.cpp.
References QOpenGLContext::currentContext(), d, funcs, QOpenGLContext::functions(), GL_DEBUG_CALLBACK_FUNCTION, GL_DEBUG_CALLBACK_USER_PARAM, GL_DEBUG_OUTPUT, GL_DEBUG_OUTPUT_SYNCHRONOUS, loggingMode, qt_opengl_debug_callback(), qWarning, and SynchronousLogging.
Referenced by src_gui_opengl_qopengldebug::SnippetWrapper::wrapper1().
|
slot |
Stops logging messages from the OpenGL server.
Definition at line 1441 of file qopengldebug.cpp.
References QOpenGLContext::currentContext(), d, funcs, QOpenGLContext::functions(), GL_DEBUG_OUTPUT, GL_DEBUG_OUTPUT_SYNCHRONOUS, and qWarning.
Referenced by ~QOpenGLDebugLogger().
|
read |
the logging mode passed to startLogging().
Note that logging must have been started or the value of this property will be meaningless.
Definition at line 102 of file qopengldebug.h.
Referenced by startLogging().