Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QOpenGLDebugLogger Class Reference

The QOpenGLDebugLogger enables logging of OpenGL debugging messages. More...

#include <qopengldebug.h>

+ Inheritance diagram for QOpenGLDebugLogger:
+ Collaboration diagram for QOpenGLDebugLogger:

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.
 
- Public Slots inherited from QObject
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.
 
- Signals inherited from QObject
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< QOpenGLDebugMessageloggedMessages () const
 Reads all the available messages in the OpenGL internal debug log and returns them.
 
- Public Member Functions inherited from QObject
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< QStringbindableObjectName ()
 
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).
 
QThreadthread () const
 Returns the thread in which the object lives.
 
bool moveToThread (QThread *thread QT6_DECL_NEW_OVERLOAD_TAIL)
 Changes the thread affinity for this object and its children and returns true on success.
 
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::nanoseconds time, Qt::TimerType timerType=Qt::CoarseTimer)
 
void killTimer (int id)
 Kills the timer with timer identifier, id.
 
void killTimer (Qt::TimerId id)
 
template<typename T >
findChild (QAnyStringView aName, 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 (QAnyStringView 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 >
findChild (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.
 
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 QObjectListchildren () 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< QByteArraydynamicPropertyNames () const
 
QBindingStoragebindingStorage ()
 
const QBindingStoragebindingStorage () const
 
QObjectparent () 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().
 
- Properties inherited from QObject
QString objectName
 the name of this object
 

Additional Inherited Members

- Static Public Member Functions inherited from QObject
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)
 
- Protected Member Functions inherited from QObject
QObjectsender () 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)
 
- Protected Attributes inherited from QObject
QScopedPointer< QObjectDatad_ptr
 

Detailed Description

The QOpenGLDebugLogger enables logging of OpenGL debugging messages.

\inmodule QtOpenGL

Since
5.1

Definition at line 119 of file qopengldebug.h.

Member Enumeration Documentation

◆ LoggingMode

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.

Constructor & Destructor Documentation

◆ QOpenGLDebugLogger()

QOpenGLDebugLogger::QOpenGLDebugLogger ( QObject * parent = nullptr)
explicit

Constructs a new logger object with the given parent.

Note
The object must be initialized before logging can happen.
See also
initialize()

Definition at line 1266 of file qopengldebug.cpp.

◆ ~QOpenGLDebugLogger()

QOpenGLDebugLogger::~QOpenGLDebugLogger ( )

Destroys the logger object.

Definition at line 1278 of file qopengldebug.cpp.

References stopLogging().

+ Here is the call graph for this function:

Member Function Documentation

◆ disableMessages() [1/2]

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.

See also
enableMessages(), pushGroup(), popGroup()

Definition at line 1660 of file qopengldebug.cpp.

References QOpenGLDebugMessage::AnySeverity, d, and QByteArrayLiteral.

◆ disableMessages() [2/2]

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.

See also
enableMessages(), pushGroup(), popGroup()

Definition at line 1643 of file qopengldebug.cpp.

References d, and QByteArrayLiteral.

◆ enableMessages() [1/2]

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.

See also
disableMessages(), pushGroup(), popGroup()

Definition at line 1622 of file qopengldebug.cpp.

References QOpenGLDebugMessage::AnySeverity, d, and QByteArrayLiteral.

◆ enableMessages() [2/2]

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.

See also
disableMessages(), pushGroup(), popGroup()

Definition at line 1605 of file qopengldebug.cpp.

References d, and QByteArrayLiteral.

◆ initialize()

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.

See also
QOpenGLContext

Definition at line 1298 of file qopengldebug.cpp.

References QObject::connect(), context, QOpenGLContext::currentContext(), d, QSurfaceFormat::DebugContext, disconnect(), GET_DEBUG_PROC_ADDRESS, GL_MAX_DEBUG_MESSAGE_LENGTH, Q_ASSERT, QByteArrayLiteral, qWarning, SIGNAL, and SLOT.

Referenced by src_gui_opengl_qopengldebug::SnippetWrapper::wrapper1().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isLogging()

bool QOpenGLDebugLogger::isLogging ( ) const

Returns true if this object is currently logging, false otherwise.

See also
startLogging()

Definition at line 1365 of file qopengldebug.cpp.

References d.

◆ loggedMessages()

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.

See also
startLogging()

Definition at line 1681 of file qopengldebug.cpp.

References d, QString::fromUtf8(), GLenum(), GLsizei(), GLuint, i, qt_messageSeverityFromGL(), qt_messageSourceFromGL(), qt_messageTypeFromGL(), qWarning, QByteArray::resize(), and QOpenGLDebugMessagePrivate::source.

Referenced by src_gui_opengl_qopengldebug::SnippetWrapper::wrapper1().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loggingMode()

QOpenGLDebugLogger::LoggingMode QOpenGLDebugLogger::loggingMode ( ) const

Returns the logging mode of the object.

See also
startLogging()

Definition at line 1430 of file qopengldebug.cpp.

References d.

◆ logMessage

void QOpenGLDebugLogger::logMessage ( const QOpenGLDebugMessage & debugMessage)
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.

Note
debugMessage must have QOpenGLDebugMessage::ApplicationSource or QOpenGLDebugMessage::ThirdPartySource as its source, and a valid type and severity, otherwise it will not be inserted into the log.
The object must be initialized before logging can happen.
See also
initialize()

Definition at line 1480 of file qopengldebug.cpp.

References QOpenGLDebugMessage::AnySeverity, QOpenGLDebugMessage::AnyType, QByteArray::append(), QOpenGLDebugMessage::ApplicationSource, d, GLenum(), QOpenGLDebugMessage::InvalidSeverity, QOpenGLDebugMessage::InvalidType, qt_messageSeverityToGL(), qt_messageSourceToGL(), qt_messageTypeToGL(), qWarning, and QOpenGLDebugMessage::ThirdPartySource.

Referenced by src_gui_opengl_qopengldebug::SnippetWrapper::wrapper1().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ maximumMessageLength()

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.

Note
Message texts are encoded in UTF-8 when they get passed to OpenGL, so their size in bytes does not usually match the amount of UTF-16 code units, as returned, for instance, by QString::length(). (It does if the message contains 7-bit ASCII only data, which is typical for debug messages.)

Definition at line 1768 of file qopengldebug.cpp.

References d, and qWarning.

◆ messageLogged

void QOpenGLDebugLogger::messageLogged ( const QOpenGLDebugMessage & debugMessage)
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.

Note
Logging must have been started, or this signal will not be emitted.
See also
startLogging()

Referenced by src_gui_opengl_qopengldebug::SnippetWrapper::wrapper1().

+ Here is the caller graph for this function:

◆ popGroup()

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.

Note
The object must be initialized before managing debug groups.
See also
pushGroup()

Definition at line 1586 of file qopengldebug.cpp.

References d, and qWarning.

◆ pushGroup()

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.

Note
The source must either be QOpenGLDebugMessage::ApplicationSource or QOpenGLDebugMessage::ThirdPartySource, otherwise the group will not be pushed.
The object must be initialized before managing debug groups.
See also
popGroup(), enableMessages(), disableMessages()

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.

+ Here is the call graph for this function:

◆ startLogging

void QOpenGLDebugLogger::startLogging ( QOpenGLDebugLogger::LoggingMode loggingMode = AsynchronousLogging)
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.

Note
It's not possible to change the logging mode without stopping and starting logging again. This might change in a future version of Qt.
The object must be initialized before logging can happen.
See also
stopLogging(), initialize()

Definition at line 1393 of file qopengldebug.cpp.

References QOpenGLContext::currentContext(), d, funcs, 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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ stopLogging

void QOpenGLDebugLogger::stopLogging ( )
slot

Stops logging messages from the OpenGL server.

See also
startLogging()

Definition at line 1441 of file qopengldebug.cpp.

References QOpenGLContext::currentContext(), d, funcs, GL_DEBUG_OUTPUT, GL_DEBUG_OUTPUT_SYNCHRONOUS, and qWarning.

Referenced by ~QOpenGLDebugLogger().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Property Documentation

◆ loggingMode

QOpenGLDebugLogger::loggingMode
read

the logging mode passed to startLogging().

Note that logging must have been started or the value of this property will be meaningless.

See also
startLogging(), isLogging()

Definition at line 122 of file qopengldebug.h.

Referenced by startLogging().


The documentation for this class was generated from the following files: