Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qopenglcontext.cpp
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
4#include <qpa/qplatformopenglcontext.h>
5#include <qpa/qplatformintegration.h>
6#include "qopenglcontext.h"
7#include "qopenglcontext_p.h"
8#include "qwindow.h"
9
10#include <QtCore/QThreadStorage>
11#include <QtCore/QThread>
12#include <QtCore/private/qlocking_p.h>
13
14#include <QtGui/private/qguiapplication_p.h>
15#include <QtGui/private/qopengl_p.h>
16#include <QtGui/private/qwindow_p.h>
17#include <QtGui/QScreen>
18#include <qpa/qplatformnativeinterface.h>
19
20#include <private/qopenglextensions_p.h>
21
22#include <QDebug>
23
25
27{
28public:
31 {
32 }
34 if (context)
36 }
38};
39
42
43#ifndef QT_NO_DEBUG
46#endif
47
58{
60}
61
66{
68}
69
150{
151 QGuiGLThreadContext *threadContext = qwindow_context_storage()->localData();
152 if (!threadContext) {
153 if (!QThread::currentThread()) {
154 qWarning("No QTLS available. currentContext won't work");
155 return nullptr;
156 }
157 threadContext = new QGuiGLThreadContext;
158 qwindow_context_storage()->setLocalData(threadContext);
159 }
160 QOpenGLContext *previous = threadContext->context;
161 threadContext->context = context;
162 return previous;
163}
164
166{
167 if (max_texture_size != -1)
168 return max_texture_size;
169
170 Q_Q(QOpenGLContext);
171 QOpenGLFunctions *funcs = q->functions();
172 funcs->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size);
173
174#if !QT_CONFIG(opengles2)
175 if (!q->isOpenGLES()) {
176 GLenum proxy = GL_PROXY_TEXTURE_2D;
177
178 GLint size;
179 GLint next = 64;
180 funcs->glTexImage2D(proxy, 0, GL_RGBA, next, next, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
181
182 QOpenGLExtraFunctions *extraFuncs = q->extraFunctions();
184
185 if (size == 0) {
186 return max_texture_size;
187 }
188 do {
189 size = next;
190 next = size * 2;
191
193 break;
194 funcs->glTexImage2D(proxy, 0, GL_RGBA, next, next, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
196 } while (next > size);
197
199 }
200#endif // QT_CONFIG(opengles2)
201
202 return max_texture_size;
203}
204
210{
211 QGuiGLThreadContext *threadContext = qwindow_context_storage()->localData();
212 if (threadContext)
213 return threadContext->context;
214 return nullptr;
215}
216
221{
222 return first->shareGroup() == second->shareGroup();
223}
224
231{
232 Q_D(const QOpenGLContext);
233 return d->platformGLContext;
234}
235
243{
244 Q_D(const QOpenGLContext);
245 if (d->shareContext)
246 return d->shareContext->handle();
247 return nullptr;
248}
249
259{
261}
262
274{
275 Q_D(QOpenGLContext);
276 d->requestedFormat = format;
277}
278
284{
285 Q_D(QOpenGLContext);
286 d->shareContext = shareContext;
287}
288
294{
295 Q_D(QOpenGLContext);
296 if (d->screen)
297 disconnect(d->screen, SIGNAL(destroyed(QObject*)), this, SLOT(_q_screenDestroyed(QObject*)));
298 d->screen = screen;
299 if (!d->screen)
301 if (d->screen)
302 connect(d->screen, SIGNAL(destroyed(QObject*)), this, SLOT(_q_screenDestroyed(QObject*)));
303}
304
306{
307 Q_Q(QOpenGLContext);
308 if (object == static_cast<QObject *>(screen)) {
309 screen = nullptr;
310 q->setScreen(nullptr);
311 }
312}
313
350{
351 Q_D(QOpenGLContext);
352 if (d->platformGLContext)
353 destroy();
354
356 if (!platformContext)
357 return false;
358
359 d->adopt(platformContext);
360
361 return isValid();
362}
363
365{
366}
367
369{
370 Q_Q(QOpenGLContext);
371
373 platformGLContext->setContext(q);
375
377 shareContext = nullptr;
379 shareGroup->d_func()->addContext(q);
380}
381
400void QOpenGLContext::destroy()
401{
402 Q_D(QOpenGLContext);
403
404 // Notify that the native context and the QPlatformOpenGLContext are going
405 // to go away.
406 if (d->platformGLContext)
408
409 // Invoke callbacks for helpers and invalidate.
410 if (d->textureFunctionsDestroyCallback) {
411 d->textureFunctionsDestroyCallback();
412 d->textureFunctionsDestroyCallback = nullptr;
413 }
414 d->textureFunctions = nullptr;
415
416 delete d->versionFunctions;
417 d->versionFunctions = nullptr;
418
419 if (d->vaoHelperDestroyCallback) {
420 Q_ASSERT(d->vaoHelper);
421 d->vaoHelperDestroyCallback(d->vaoHelper);
422 d->vaoHelperDestroyCallback = nullptr;
423 }
424 d->vaoHelper = nullptr;
425
426 // Tear down function wrappers.
427 delete d->versionFunctions;
428 d->versionFunctions = nullptr;
429
430 delete d->functions;
431 d->functions = nullptr;
432
433 // Clean up and destroy the native context machinery.
434 if (QOpenGLContext::currentContext() == this)
435 doneCurrent();
436
437 if (d->shareGroup)
438 d->shareGroup->d_func()->removeContext(this);
439
440 d->shareGroup = nullptr;
441
442 delete d->platformGLContext;
443 d->platformGLContext = nullptr;
444}
445
463{
464 destroy();
465
466#ifndef QT_NO_DEBUG
468#endif
469}
470
494{
495 Q_D(const QOpenGLContext);
496 return d->platformGLContext && d->platformGLContext->isValid();
497}
498
511{
512 Q_D(const QOpenGLContext);
513 if (!d->functions)
514 const_cast<QOpenGLFunctions *&>(d->functions) = new QOpenGLExtensions(QOpenGLContext::currentContext());
515 return d->functions;
516}
517
536{
537 return static_cast<QOpenGLExtraFunctions *>(functions());
538}
539
548{
549 Q_D(const QOpenGLContext);
550 if (d->extensionNames.isEmpty()) {
552 d->extensionNames = matcher.extensions();
553 }
554
555 return d->extensionNames;
556}
557
567{
568 return extensions().contains(extension);
569}
570
596{
597 if (!isValid())
598 return 0;
599
600 Q_D(const QOpenGLContext);
601 if (!d->surface || !d->surface->surfaceHandle())
602 return 0;
603
604 if (d->defaultFboRedirect)
605 return d->defaultFboRedirect;
606
607 return d->platformGLContext->defaultFramebufferObject(d->surface->surfaceHandle());
608}
609
634{
635 Q_D(QOpenGLContext);
636 if (!isValid())
637 return false;
638
640 && thread() != QThread::currentThread())) {
641 qFatal("Cannot make QOpenGLContext current in a different thread");
642 }
643
644 if (!surface) {
645 doneCurrent();
646 return true;
647 }
648
649 if (!surface->surfaceHandle())
650 return false;
651 if (!surface->supportsOpenGL()) {
652 qWarning() << "QOpenGLContext::makeCurrent() called with non-opengl surface" << surface;
653 return false;
654 }
655
656 if (!d->platformGLContext->makeCurrent(surface->surfaceHandle()))
657 return false;
658
660#ifndef QT_NO_DEBUG
662#endif
663
664 d->surface = surface;
665
666 static bool needsWorkaroundSet = false;
667 static bool needsWorkaround = false;
668
669 if (!needsWorkaroundSet) {
670 QByteArray env;
671#ifdef Q_OS_ANDROID
672 env = qgetenv(QByteArrayLiteral("QT_ANDROID_DISABLE_GLYPH_CACHE_WORKAROUND"));
673 needsWorkaround = env.isEmpty() || env == QByteArrayLiteral("0") || env == QByteArrayLiteral("false");
674#endif
675 env = qgetenv(QByteArrayLiteral("QT_ENABLE_GLYPH_CACHE_WORKAROUND"));
676 if (env == QByteArrayLiteral("1") || env == QByteArrayLiteral("true"))
677 needsWorkaround = true;
678
679 if (!needsWorkaround) {
680 const char *rendererString = reinterpret_cast<const char *>(functions()->glGetString(GL_RENDERER));
681 if (rendererString)
682 needsWorkaround =
683 qstrncmp(rendererString, "Mali-4xx", 6) == 0 // Mali-400, Mali-450
684 || qstrcmp(rendererString, "Mali-T880") == 0
685 || qstrncmp(rendererString, "Adreno (TM) 2xx", 13) == 0 // Adreno 200, 203, 205
686 || qstrncmp(rendererString, "Adreno 2xx", 8) == 0 // Same as above but without the '(TM)'
687 || qstrncmp(rendererString, "Adreno (TM) 3xx", 13) == 0 // Adreno 302, 305, 320, 330
688 || qstrncmp(rendererString, "Adreno 3xx", 8) == 0 // Same as above but without the '(TM)'
689 || qstrncmp(rendererString, "Adreno (TM) 4xx", 13) == 0 // Adreno 405, 418, 420, 430
690 || qstrncmp(rendererString, "Adreno 4xx", 8) == 0 // Same as above but without the '(TM)'
691 || qstrncmp(rendererString, "Adreno (TM) 5xx", 13) == 0 // Adreno 505, 506, 510, 530, 540
692 || qstrncmp(rendererString, "Adreno 5xx", 8) == 0 // Same as above but without the '(TM)'
693 || qstrncmp(rendererString, "Adreno (TM) 6xx", 13) == 0 // Adreno 610, 620, 630
694 || qstrncmp(rendererString, "Adreno 6xx", 8) == 0 // Same as above but without the '(TM)'
695 || qstrcmp(rendererString, "GC800 core") == 0
696 || qstrcmp(rendererString, "GC1000 core") == 0
697 || strstr(rendererString, "GC2000") != nullptr
698 || qstrcmp(rendererString, "Immersion.16") == 0
699 || qstrncmp(rendererString, "Apple Mx", 7) == 0;
700 }
701 needsWorkaroundSet = true;
702 }
703
704 if (needsWorkaround)
705 d->workaround_brokenFBOReadBack = true;
706
707 d->shareGroup->d_func()->deletePendingResources(this);
708
709 return true;
710}
711
720{
721 Q_D(QOpenGLContext);
722 if (!isValid())
723 return;
724
725 if (QOpenGLContext::currentContext() == this)
726 d->shareGroup->d_func()->deletePendingResources(this);
727
728 d->platformGLContext->doneCurrent();
730
731 d->surface = nullptr;
732}
733
740{
741 Q_D(const QOpenGLContext);
742 return d->surface;
743}
744
745
754{
755 Q_D(QOpenGLContext);
756 if (!isValid())
757 return;
758
759 if (!surface) {
760 qWarning("QOpenGLContext::swapBuffers() called with null argument");
761 return;
762 }
763
764 if (!surface->supportsOpenGL()) {
765 qWarning("QOpenGLContext::swapBuffers() called with non-opengl surface");
766 return;
767 }
768
769 QPlatformSurface *surfaceHandle = surface->surfaceHandle();
770 if (!surfaceHandle)
771 return;
772
773#if !defined(QT_NO_DEBUG)
775 qWarning("QOpenGLContext::swapBuffers() called without corresponding makeCurrent()");
776#endif
778 functions()->glFlush();
779 d->platformGLContext->swapBuffers(surfaceHandle);
780}
781
787QFunctionPointer QOpenGLContext::getProcAddress(const QByteArray &procName) const
788{
789 return getProcAddress(procName.constData());
790}
791
796QFunctionPointer QOpenGLContext::getProcAddress(const char *procName) const
797{
798 Q_D(const QOpenGLContext);
799 if (!d->platformGLContext)
800 return nullptr;
801 return d->platformGLContext->getProcAddress(procName);
802}
803
824{
825 Q_D(const QOpenGLContext);
826 if (!d->platformGLContext)
827 return d->requestedFormat;
828 return d->platformGLContext->format();
829}
830
835{
836 Q_D(const QOpenGLContext);
837 return d->shareGroup;
838}
839
847{
848 Q_D(const QOpenGLContext);
849 return d->shareContext;
850}
851
856{
857 Q_D(const QOpenGLContext);
858 return d->screen;
859}
860
888{
889#if defined(QT_OPENGL_DYNAMIC)
892#elif QT_CONFIG(opengles2)
893 return LibGLES;
894#else
895 return LibGL;
896#endif
897}
898
910{
912}
913
924{
927}
928
949{
952}
953
957QOpenGLTextureHelper* QOpenGLContext::textureFunctions() const
958{
959 Q_D(const QOpenGLContext);
960 return d->textureFunctions;
961}
962
966void QOpenGLContext::setTextureFunctions(QOpenGLTextureHelper* textureFuncs, std::function<void()> destroyCallback)
967{
968 Q_D(QOpenGLContext);
969 d->textureFunctions = textureFuncs;
970 d->textureFunctionsDestroyCallback = destroyCallback;
971}
972
986QOpenGLContextGroup::QOpenGLContextGroup()
988{
989}
990
995{
997 d->cleanup();
998}
999
1004{
1005 Q_D(const QOpenGLContextGroup);
1006 return d->m_shares;
1007}
1008
1015{
1017 return current ? current->shareGroup() : nullptr;
1018}
1019
1021 = default;
1022
1024{
1025 const auto locker = qt_scoped_lock(m_mutex);
1026 m_refs.ref();
1027 m_shares << ctx;
1028}
1029
1031{
1033
1034 bool deleteObject = false;
1035
1036 {
1037 const auto locker = qt_scoped_lock(m_mutex);
1039
1040 if (ctx == m_context && !m_shares.isEmpty())
1042
1043 if (!m_refs.deref()) {
1044 cleanup();
1045 deleteObject = true;
1046 }
1047 }
1048
1049 if (deleteObject) {
1050 if (q->thread() == QThread::currentThread())
1051 delete q; // Delete directly to prevent leak, refer to QTBUG-29056
1052 else
1053 q->deleteLater();
1054 }
1055}
1056
1058{
1060 {
1063 for (it = m_resources.constBegin(); it != end; ++it)
1064 it.key()->cleanup(q, it.value());
1066 }
1067
1070
1071 while (it != end) {
1072 (*it)->invalidateResource();
1073 (*it)->m_group = nullptr;
1074 ++it;
1075 }
1076
1078
1081}
1082
1084{
1085 const auto locker = qt_scoped_lock(m_mutex);
1086
1089
1092 while (it != end) {
1093 (*it)->freeResource(ctx);
1094 delete *it;
1095 ++it;
1096 }
1097}
1098
1124 : m_group(group)
1125{
1126 const auto locker = qt_scoped_lock(m_group->d_func()->m_mutex);
1127 m_group->d_func()->m_sharedResources << this;
1128}
1129
1131{
1132}
1133
1134// schedule the resource for deletion at an appropriate time
1136{
1137 if (!m_group) {
1138 delete this;
1139 return;
1140 }
1141
1142 const auto locker = qt_scoped_lock(m_group->d_func()->m_mutex);
1143 m_group->d_func()->m_sharedResources.removeOne(this);
1144 m_group->d_func()->m_pendingDeletion << this;
1145
1146 // can we delete right away?
1148 if (current && current->shareGroup() == m_group) {
1149 m_group->d_func()->deletePendingResources(current);
1150 }
1151}
1152
1166 = default;
1167
1169{
1170 if (m_id) {
1171 QOpenGLFunctions functions(context);
1172 m_func(&functions, m_id);
1173 m_id = 0;
1174 }
1175}
1176
1194 : active(0)
1195{
1196#ifdef QT_GL_CONTEXT_RESOURCE_DEBUG
1197 qDebug("Creating context group resource object %p.", this);
1198#endif
1199}
1200
1202{
1203#ifdef QT_GL_CONTEXT_RESOURCE_DEBUG
1204 qDebug("Deleting context group resource %p. Group size: %d.", this, m_groups.size());
1205#endif
1206 for (int i = 0; i < m_groups.size(); ++i) {
1207 if (!m_groups.at(i)->shares().isEmpty()) {
1208 QOpenGLContext *context = m_groups.at(i)->shares().constFirst();
1209 QOpenGLSharedResource *resource = value(context);
1210 if (resource)
1211 resource->free();
1212 }
1213 m_groups.at(i)->d_func()->m_resources.remove(this);
1214 active.deref();
1215 }
1216#ifndef QT_NO_DEBUG
1217 if (active.loadRelaxed() != 0) {
1218 qWarning("QtGui: Resources are still available at program shutdown.\n"
1219 " This is possibly caused by a leaked QOpenGLWidget, \n"
1220 " QOpenGLFramebufferObject or QOpenGLPixelBuffer.");
1221 }
1222#endif
1223}
1224
1226{
1227#ifdef QT_GL_CONTEXT_RESOURCE_DEBUG
1228 qDebug("Inserting context group resource %p for context %p, managed by %p.", value, context, this);
1229#endif
1230 QOpenGLContextGroup *group = context->shareGroup();
1231 Q_ASSERT(!group->d_func()->m_resources.contains(this));
1232 group->d_func()->m_resources.insert(this, value);
1233 m_groups.append(group);
1234 active.ref();
1235}
1236
1238{
1239 QOpenGLContextGroup *group = context->shareGroup();
1240 return group->d_func()->m_resources.value(this, nullptr);
1241}
1242
1244{
1246 for (QList<QOpenGLContextGroup *>::const_iterator it = m_groups.constBegin(); it != m_groups.constEnd(); ++it) {
1247 QOpenGLSharedResource *resource = (*it)->d_func()->m_resources.value(const_cast<QOpenGLMultiGroupSharedResource *>(this), nullptr);
1248 if (resource)
1249 result << resource;
1250 }
1251 return result;
1252}
1253
1255{
1256#ifdef QT_GL_CONTEXT_RESOURCE_DEBUG
1257 qDebug("Cleaning up context group resource %p, for group %p in thread %p.", this, group, QThread::currentThread());
1258#endif
1259 value->invalidateResource();
1260 value->free();
1261 active.deref();
1262
1263 Q_ASSERT(m_groups.contains(group));
1264 m_groups.removeOne(group);
1265}
1266
1268 = default;
1269
1270#ifndef QT_NO_DEBUG_STREAM
1272{
1273 QDebugStateSaver saver(debug);
1274 debug.nospace();
1275 debug.noquote();
1276 debug << "QOpenGLContext(";
1277 if (ctx) {
1278 debug << static_cast<const void *>(ctx);
1279 if (ctx->isValid()) {
1280 debug << ", format=" << ctx->format();
1281 if (const QSurface *sf = ctx->surface())
1282 debug << ", surface=" << sf;
1283 if (const QScreen *s = ctx->screen())
1284 debug << ", screen=\"" << s->name() << '"';
1285 } else {
1286 debug << ", invalid";
1287 }
1288 } else {
1289 debug << '0';
1290 }
1291 debug << ')';
1292 return debug;
1293}
1294
1296{
1297 QDebugStateSaver saver(debug);
1298 debug.nospace();
1299 debug << "QOpenGLContextGroup(";
1300 if (cg)
1301 debug << cg->shares();
1302 else
1303 debug << '0';
1304 debug << ')';
1305 return debug;
1306}
1307#endif // QT_NO_DEBUG_STREAM
1308
1309using namespace QNativeInterface;
1310
1311void *QOpenGLContext::resolveInterface(const char *name, int revision) const
1312{
1313 Q_UNUSED(name); Q_UNUSED(revision);
1314
1315 auto *platformContext = handle();
1316 Q_UNUSED(platformContext);
1317
1318#if defined(Q_OS_MACOS)
1320#endif
1321#if defined(Q_OS_WIN)
1323#endif
1324#if QT_CONFIG(xcb_glx_plugin)
1326#endif
1327#if QT_CONFIG(egl)
1328 QT_NATIVE_INTERFACE_RETURN_IF(QEGLContext, platformContext);
1329#endif
1330
1331 return nullptr;
1332}
1333
1335
1336#include "moc_qopenglcontext.cpp"
bool ref() noexcept
bool deref() noexcept
T loadRelaxed() const noexcept
\inmodule QtCore
Definition qbytearray.h:57
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
Definition qbytearray.h:122
bool isEmpty() const noexcept
Returns true if the byte array has size 0; otherwise returns false.
Definition qbytearray.h:106
\inmodule QtCore
\inmodule QtCore
static QPlatformIntegration * platformIntegration()
static QGuiApplicationPrivate * instance()
QScreen * primaryScreen
the primary (or default) screen of the application.
QOpenGLContext * context
\inmodule QtCore
Definition qhash.h:1135
\inmodule QtCore
Definition qhash.h:818
const_iterator constEnd() const noexcept
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the ...
Definition qhash.h:1209
const_iterator constBegin() const noexcept
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first item in the hash.
Definition qhash.h:1205
void clear() noexcept(std::is_nothrow_destructible< Node >::value)
Removes all items from the hash and frees up all memory used by it.
Definition qhash.h:949
Definition qlist.h:74
qsizetype size() const noexcept
Definition qlist.h:386
bool isEmpty() const noexcept
Definition qlist.h:390
bool removeOne(const AT &t)
Definition qlist.h:581
iterator end()
Definition qlist.h:609
const_reference at(qsizetype i) const noexcept
Definition qlist.h:429
const_iterator constBegin() const noexcept
Definition qlist.h:615
iterator begin()
Definition qlist.h:608
const T & constFirst() const noexcept
Definition qlist.h:630
void append(parameter_type t)
Definition qlist.h:441
const_iterator constEnd() const noexcept
Definition qlist.h:616
void clear()
Definition qlist.h:417
\inmodule QtCore
Definition qmutex.h:285
\inheaderfile QOpenGLContext
\inmodule QtCore
Definition qobject.h:90
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2823
QThread * thread() const
Returns the thread in which the object lives.
Definition qobject.cpp:1561
void destroyed(QObject *=nullptr)
This signal is emitted immediately before the object obj is destroyed, after any instances of QPointe...
QHash< QOpenGLMultiGroupSharedResource *, QOpenGLSharedResource * > m_resources
void removeContext(QOpenGLContext *ctx)
~QOpenGLContextGroupPrivate() override
void deletePendingResources(QOpenGLContext *ctx)
QList< QOpenGLSharedResource * > m_sharedResources
QList< QOpenGLContext * > m_shares
QList< QOpenGLSharedResource * > m_pendingDeletion
void addContext(QOpenGLContext *ctx)
The QOpenGLContextGroup class represents a group of contexts sharing OpenGL resources....
static QOpenGLContextGroup * currentContextGroup()
Returns the QOpenGLContextGroup corresponding to the current context.
QList< QOpenGLContext * > shares() const
Returns all the QOpenGLContext objects in this share group.
QOpenGLContextGroup * shareGroup
static void cleanMakeCurrentTracker(QOpenGLContext *context)
void _q_screenDestroyed(QObject *object)
QOpenGLContext * shareContext
QPlatformOpenGLContext * platformGLContext
static QOpenGLContext * setCurrentContext(QOpenGLContext *context)
static QMutex makeCurrentTrackerMutex
void adopt(QPlatformOpenGLContext *)
static bool toggleMakeCurrentTracker(QOpenGLContext *context, bool value)
static QHash< QOpenGLContext *, bool > makeCurrentTracker
\inmodule QtGui
QFunctionPointer getProcAddress(const QByteArray &procName) const
Resolves the function pointer to an OpenGL extension function, identified by procName.
bool create()
Attempts to create the OpenGL context with the current configuration.
void setScreen(QScreen *screen)
Sets the screen the OpenGL context should be valid for.
bool isValid() const
Returns if this context is valid, i.e.
bool makeCurrent(QSurface *surface)
Makes the context current in the current thread, against the given surface.
QSurfaceFormat format() const
Returns the format of the underlying platform context, if create() has been called.
QOpenGLContext(QObject *parent=nullptr)
Creates a new OpenGL context instance with parent object parent.
QOpenGLContext * shareContext() const
Returns the share context this context was created with.
QSet< QByteArray > extensions() const
Returns the set of OpenGL extensions supported by this context.
QPlatformOpenGLContext * handle() const
Returns the underlying platform context.
QOpenGLContextGroup * shareGroup() const
Returns the share group this context belongs to.
QOpenGLExtraFunctions * extraFunctions() const
Get the QOpenGLExtraFunctions instance for this context.
static OpenGLModuleType openGLModuleType()
Returns the underlying OpenGL implementation type.
void setShareContext(QOpenGLContext *shareContext)
Makes this context share textures, shaders, and other OpenGL resources with shareContext.
OpenGLModuleType
This enum defines the type of the underlying OpenGL implementation.
void aboutToBeDestroyed()
This signal is emitted before the underlying native OpenGL context is destroyed, such that users may ...
GLuint defaultFramebufferObject() const
Call this to get the default framebuffer object for the current surface.
void setFormat(const QSurfaceFormat &format)
Sets the format the OpenGL context should be compatible with.
bool hasExtension(const QByteArray &extension) const
Returns true if this OpenGL context supports the specified OpenGL extension, false otherwise.
static QOpenGLContext * currentContext()
Returns the last context which called makeCurrent in the current thread, or \nullptr,...
void doneCurrent()
Convenience function for calling makeCurrent with a 0 surface.
static bool areSharing(QOpenGLContext *first, QOpenGLContext *second)
Returns true if the first and second contexts are sharing OpenGL resources.
static QOpenGLContext * globalShareContext()
QScreen * screen() const
Returns the screen the context was created for.
QPlatformOpenGLContext * shareHandle() const
Returns the underlying platform context with which this context is sharing.
QOpenGLFunctions * functions() const
Get the QOpenGLFunctions instance for this context.
QSurface * surface() const
Returns the surface the context has been made current with.
static bool supportsThreadedOpenGL()
Returns true if the platform supports OpenGL rendering outside the main (gui) thread.
void swapBuffers(QSurface *surface)
Swap the back and front buffers of surface.
bool isOpenGLES() const
Returns true if the context is an OpenGL ES context.
~QOpenGLContext()
Destroys the QOpenGLContext object.
The QOpenGLExtraFunctions class provides cross-platform access to the OpenGL ES 3....
void glGetTexLevelParameteriv(GLenum target, GLint level, GLenum pname, GLint *params)
Convenience function that calls glGetTexLevelParameteriv(target, level, pname, params).
The QOpenGLFunctions class provides cross-platform access to the OpenGL ES 2.0 API.
const GLubyte * glGetString(GLenum name)
Convenience function that calls glGetString(name).
void glFlush()
Convenience function that calls glFlush().
The QOpenGLMultiGroupSharedResource keeps track of a shared resource that might be needed from multip...
void cleanup(QOpenGLContextGroup *group, QOpenGLSharedResource *value)
QList< QOpenGLSharedResource * > resources() const
QOpenGLSharedResource * value(QOpenGLContext *context)
void insert(QOpenGLContext *context, QOpenGLSharedResource *value)
~QOpenGLSharedResourceGuard() override
void freeResource(QOpenGLContext *context) override
The QOpenGLSharedResource class is used to keep track of resources that are shared between OpenGL con...
QOpenGLSharedResource(QOpenGLContextGroup *group)
virtual bool hasCapability(Capability cap) const
virtual QPlatformOpenGLContext * createPlatformOpenGLContext(QOpenGLContext *context) const
Factory function for QPlatformOpenGLContext.
virtual QOpenGLContext::OpenGLModuleType openGLModuleType()
Platform integration function for querying the OpenGL implementation type.
The QPlatformOpenGLContext class provides an abstraction for native GL contexts.
virtual void initialize()
Called after a new instance is constructed.
virtual bool isSharing() const
The QPlatformSurface class provides an abstraction for a surface.
The QScreen class is used to query screen properties. \inmodule QtGui.
Definition qscreen.h:32
Definition qset.h:18
bool contains(const T &value) const
Definition qset.h:71
The QSurfaceFormat class represents the format of a QSurface. \inmodule QtGui.
RenderableType renderableType() const
Gets the renderable type.
SwapBehavior swapBehavior() const
Returns the configured swap behaviour.
\inmodule QtGui
Definition qsurface.h:21
virtual QPlatformSurface * surfaceHandle() const =0
Returns a handle to the platform-specific implementation of the surface.
bool supportsOpenGL() const
Returns true if the surface is OpenGL compatible and can be used in conjunction with QOpenGLContext; ...
Definition qsurface.cpp:70
virtual QSurfaceFormat format() const =0
Returns the format of the surface.
\inmodule QtCore
static QThread * currentThread()
Definition qthread.cpp:966
EGLContext ctx
static VulkanServerBufferGlFunctions * funcs
void extension()
[6]
Definition dialogs.cpp:230
qDeleteAll(list.begin(), list.end())
QSet< QString >::iterator it
short next
Definition keywords.cpp:445
Combined button and popup list for selecting options.
@ AA_DontCheckOpenGLContextThreadAffinity
Definition qnamespace.h:460
static void * context
#define QByteArrayLiteral(str)
Definition qbytearray.h:52
int qstrncmp(const char *str1, const char *str2, size_t len)
Q_CORE_EXPORT int qstrcmp(const char *str1, const char *str2)
#define Q_UNLIKELY(x)
#define qApp
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage return DBusPendingCall * pending
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define Q_GLOBAL_STATIC(TYPE, NAME,...)
#define qGuiApp
#define qDebug
[1]
Definition qlogging.h:160
#define qWarning
Definition qlogging.h:162
#define qFatal
Definition qlogging.h:164
#define QT_NATIVE_INTERFACE_RETURN_IF(NativeInterface, baseType)
#define SLOT(a)
Definition qobjectdefs.h:51
#define SIGNAL(a)
Definition qobjectdefs.h:52
QOpenGLContext * qt_gl_global_share_context()
void qt_gl_set_global_share_context(QOpenGLContext *context)
static QOpenGLContext * global_share_context
QDebug operator<<(QDebug debug, const QOpenGLContext *ctx)
typedef GLint(GL_APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONINDEXEXTPROC)(GLuint program
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint GLuint end
GLboolean GLuint group
typedef GLenum(GL_APIENTRYP PFNGLGETGRAPHICSRESETSTATUSKHRPROC)(void)
GLuint name
GLint first
GLint GLsizei GLsizei GLenum format
const void * getProcAddress
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
GLuint64EXT * result
[6]
GLdouble s
[6]
Definition qopenglext.h:235
#define GL_TEXTURE_WIDTH
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
#define GLuint
#define GL_UNSIGNED_BYTE
#define GL_RGBA
QScreen * screen
[1]
Definition main.cpp:29
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
#define emit
#define Q_UNUSED(x)
QObject::connect nullptr
myObject disconnect()
[26]
static const auto matcher
[0]
QNetworkProxy proxy
[0]
bool contains(const AT &t) const noexcept
Definition qlist.h:44
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent