Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qopenglcontext.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QOPENGLCONTEXT_H
6#define QOPENGLCONTEXT_H
7
8#include <QtGui/qtguiglobal.h>
9
10#ifndef QT_NO_OPENGL
11
12#include <QtCore/qnamespace.h>
13#include <QtCore/qobject.h>
14#include <QtCore/qscopedpointer.h>
15#include <QtCore/qset.h>
16#include <QtCore/qnativeinterface.h>
17
18#include <QtGui/QSurfaceFormat>
19
20#ifdef __GLEW_H__
21#if defined(Q_CC_GNU)
22#warning qopenglfunctions.h is not compatible with GLEW, GLEW defines will be undefined
23#warning To use GLEW with Qt, do not include <qopengl.h> or <QOpenGLFunctions> after glew.h
24#endif
25#endif
26
27#include <QtGui/qopengl.h>
28
29#include <QtCore/qvariant.h>
30
31QT_BEGIN_NAMESPACE
32
33class QDebug;
35class QOpenGLContextGroupPrivate;
36class QOpenGLFunctions;
37class QOpenGLExtraFunctions;
38class QPlatformOpenGLContext;
39
40class QScreen;
41class QSurface;
42
43class Q_GUI_EXPORT QOpenGLContextGroup : public QObject
44{
45 Q_OBJECT
46 Q_DECLARE_PRIVATE(QOpenGLContextGroup)
47public:
48 ~QOpenGLContextGroup();
49
50 QList<QOpenGLContext *> shares() const;
51
52 static QOpenGLContextGroup *currentContextGroup();
53
54private:
55 QOpenGLContextGroup();
56
57 friend class QOpenGLContext;
58 friend class QOpenGLContextPrivate;
59 friend class QOpenGLContextGroupResourceBase;
60 friend class QOpenGLSharedResource;
61 friend class QOpenGLMultiGroupSharedResource;
62};
63
64
66
67class Q_GUI_EXPORT QOpenGLContext : public QObject
68{
69 Q_OBJECT
70 Q_DECLARE_PRIVATE(QOpenGLContext)
71public:
72 explicit QOpenGLContext(QObject *parent = nullptr);
73 ~QOpenGLContext();
74
75 void setFormat(const QSurfaceFormat &format);
76 void setShareContext(QOpenGLContext *shareContext);
77 void setScreen(QScreen *screen);
78
79 bool create();
80 bool isValid() const;
81
82 QSurfaceFormat format() const;
83 QOpenGLContext *shareContext() const;
84 QOpenGLContextGroup *shareGroup() const;
85 QScreen *screen() const;
86
87 GLuint defaultFramebufferObject() const;
88
89 bool makeCurrent(QSurface *surface);
90 void doneCurrent();
91
92 void swapBuffers(QSurface *surface);
93 QFunctionPointer getProcAddress(const QByteArray &procName) const;
94 QFunctionPointer getProcAddress(const char *procName) const;
95
96 QSurface *surface() const;
97
98 static QOpenGLContext *currentContext();
99 static bool areSharing(QOpenGLContext *first, QOpenGLContext *second);
100
101 QPlatformOpenGLContext *handle() const;
102 QPlatformOpenGLContext *shareHandle() const;
103
104 QOpenGLFunctions *functions() const;
105 QOpenGLExtraFunctions *extraFunctions() const;
106
107 QSet<QByteArray> extensions() const;
108 bool hasExtension(const QByteArray &extension) const;
109
110 enum OpenGLModuleType {
111 LibGL,
112 LibGLES
113 };
114
115 static OpenGLModuleType openGLModuleType();
116
117 bool isOpenGLES() const;
118
119 static bool supportsThreadedOpenGL();
120 static QOpenGLContext *globalShareContext();
121
122 QT_DECLARE_NATIVE_INTERFACE_ACCESSOR(QOpenGLContext)
123
124Q_SIGNALS:
125 void aboutToBeDestroyed();
126
127private:
128 friend class QOpenGLContextResourceBase;
129 friend class QOpenGLPaintDevice;
130 friend class QOpenGLGlyphTexture;
131 friend class QOpenGLTextureGlyphCache;
132 friend class QOpenGLEngineShaderManager;
133 friend class QOpenGLFramebufferObject;
134 friend class QOpenGLFramebufferObjectPrivate;
135 friend class QOpenGL2PaintEngineEx;
136 friend class QOpenGL2PaintEngineExPrivate;
137 friend class QSGDistanceFieldGlyphCache;
138 friend class QWidgetPrivate;
139 friend class QAbstractOpenGLFunctionsPrivate;
140 friend class QOpenGLTexturePrivate;
141
142 QOpenGLTextureHelper* textureFunctions() const;
143 void setTextureFunctions(QOpenGLTextureHelper* textureFuncs, std::function<void()> destroyCallback);
144
145 void destroy();
146
147 Q_PRIVATE_SLOT(d_func(), void _q_screenDestroyed(QObject *object))
148};
149
150#ifndef QT_NO_DEBUG_STREAM
151Q_GUI_EXPORT QDebug operator<<(QDebug debug, const QOpenGLContext *ctx);
152Q_GUI_EXPORT QDebug operator<<(QDebug debug, const QOpenGLContextGroup *cg);
153#endif // !QT_NO_DEBUG_STREAM
154
155QT_END_NAMESPACE
156
157#include <QtGui/qopenglcontext_platform.h>
158
159#endif // QT_NO_OPENGL
160
161#endif // QOPENGLCONTEXT_H
QOpenGLContext * context
The QOpenGLContextGroup class represents a group of contexts sharing OpenGL resources....
\inmodule QtGui
Combined button and popup list for selecting options.
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QDir::Filters filters)
Definition qdir.cpp:2582
Q_GLOBAL_STATIC(QReadWriteLock, g_updateMutex)
QOpenGLContext * qt_gl_global_share_context()
void qt_gl_set_global_share_context(QOpenGLContext *context)
static QOpenGLContext * global_share_context