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
src_gui_opengl_qopengldebug.cpp
Go to the documentation of this file.
1// Copyright (C) 2018 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3#include <QOpenGLContext>
4#include <QSurfaceFormat>
5#include <QWidget>
6#include <QtOpenGL/QOpenGLDebugLogger>
7
9struct LogHandler : public QObject
10{
12public slots:
13 static bool handleLoggedMessage() { return true; };
14};
15struct SnippetWrapper : public QObject
16{
20};
21
22void wrapper0() {
23
25GLenum error = GL_NO_ERROR;
26do {
27 error = glGetError();
28 if (error != GL_NO_ERROR) {
29 // handle the error
30 }
31} while (error != GL_NO_ERROR);
33
34
37// asks for a OpenGL 3.2 debug context using the Core profile
39format.setMinorVersion(2);
42
44context->setFormat(format);
45context->create();
47
48} // wrapper0
49
50
54QOpenGLDebugLogger *logger = new QOpenGLDebugLogger(this);
55
56logger->initialize(); // initializes in the current context, i.e. ctx
58
59
61ctx->hasExtension(QByteArrayLiteral("GL_KHR_debug"));
63
64
66const QList<QOpenGLDebugMessage> messages = logger->loggedMessages();
67for (const QOpenGLDebugMessage &message : messages)
68 qDebug() << message;
70
71
74logger->startLogging();
76
77
81
82logger->logMessage(message);
84
85} // SnippetWrapper::wrapper1
86} // src_gui_opengl_qopengldebug
\inmodule QtCore
Definition qobject.h:103
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2960
\inmodule QtGui
static QOpenGLContext * currentContext()
Returns the last context which called makeCurrent in the current thread, or \nullptr,...
The QOpenGLDebugLogger enables logging of OpenGL debugging messages.
void messageLogged(const QOpenGLDebugMessage &debugMessage)
This signal is emitted when a debug message (wrapped by the debugMessage argument) is logged from the...
bool initialize()
Initializes the object in the current OpenGL context.
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.
QList< QOpenGLDebugMessage > loggedMessages() const
Reads all the available messages in the OpenGL internal debug log and returns them.
The QOpenGLDebugMessage class wraps an OpenGL debug message.
static QOpenGLDebugMessage createApplicationMessage(const QString &text, GLuint id=0, Severity severity=NotificationSeverity, Type type=OtherType)
Constructs and returns a debug message with text as its text, id as id, severity as severity,...
The QSurfaceFormat class represents the format of a QSurface. \inmodule QtGui.
void setMajorVersion(int majorVersion)
Sets the desired major OpenGL version.
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
EGLContext ctx
static void * context
#define QByteArrayLiteral(str)
Definition qbytearray.h:52
DBusConnection const char DBusError * error
#define qDebug
[1]
Definition qlogging.h:164
typedef GLenum(GL_APIENTRYP PFNGLGETGRAPHICSRESETSTATUSKHRPROC)(void)
GLuint GLsizei const GLchar * message
GLint GLsizei GLsizei GLenum format
#define QStringLiteral(str)
#define Q_OBJECT
#define slots