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
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
39
40Q_GLOBAL_STATIC(QThreadStorage<QGuiGLThreadContext *>, qwindow_context_storage);
42
43#ifndef QT_NO_DEBUG
44QHash<QOpenGLContext *, bool> QOpenGLContextPrivate::makeCurrentTracker;
46#endif
47
61
69
166{
167 QGuiGLThreadContext *threadContext = qwindow_context_storage()->localData();
168 if (!threadContext) {
169 if (!QThread::currentThread()) {
170 qWarning("No QTLS available. currentContext won't work");
171 return nullptr;
172 }
173 if (!context)
174 return nullptr;
175
176 threadContext = new QGuiGLThreadContext;
177 qwindow_context_storage()->setLocalData(threadContext);
178 }
179 QOpenGLContext *previous = threadContext->context;
180 threadContext->context = context;
181 return previous;
182}
183
185{
186 if (max_texture_size != -1)
187 return max_texture_size;
188
189 Q_Q(QOpenGLContext);
190 QOpenGLFunctions *funcs = q->functions();
191 funcs->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size);
192
193#if !QT_CONFIG(opengles2)
194 if (!q->isOpenGLES()) {
195 GLenum proxy = GL_PROXY_TEXTURE_2D;
196
197 GLint size;
198 GLint next = 64;
199 funcs->glTexImage2D(proxy, 0, GL_RGBA, next, next, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
200
201 QOpenGLExtraFunctions *extraFuncs = q->extraFunctions();
203
204 if (size == 0) {
205 return max_texture_size;
206 }
207 do {
208 size = next;
209 next = size * 2;
210
212 break;
213 funcs->glTexImage2D(proxy, 0, GL_RGBA, next, next, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
214 extraFuncs->glGetTexLevelParameteriv(proxy, 0, GL_TEXTURE_WIDTH, &next);
215 } while (next > size);
216
218 }
219#endif // QT_CONFIG(opengles2)
220
221 return max_texture_size;
222}
223
229{
230 QGuiGLThreadContext *threadContext = qwindow_context_storage()->localData();
231 if (threadContext)
232 return threadContext->context;
233 return nullptr;
234}
235
240{
241 return first->shareGroup() == second->shareGroup();
242}
243
250{
251 Q_D(const QOpenGLContext);
252 return d->platformGLContext;
253}
254
262{
263 Q_D(const QOpenGLContext);
264 if (d->shareContext)
265 return d->shareContext->handle();
266 return nullptr;
267}
268
281
293{
294 Q_D(QOpenGLContext);
295 d->requestedFormat = format;
296}
297
303{
304 Q_D(QOpenGLContext);
305 d->shareContext = shareContext;
306}
307
313{
314 Q_D(QOpenGLContext);
315 if (d->screen)
316 disconnect(d->screen, SIGNAL(destroyed(QObject*)), this, SLOT(_q_screenDestroyed(QObject*)));
317 d->screen = screen;
318 if (!d->screen)
320 if (d->screen)
321 connect(d->screen, SIGNAL(destroyed(QObject*)), this, SLOT(_q_screenDestroyed(QObject*)));
322}
323
325{
326 Q_Q(QOpenGLContext);
327 if (object == static_cast<QObject *>(screen)) {
328 screen = nullptr;
329 q->setScreen(nullptr);
330 }
331}
332
369{
370 Q_D(QOpenGLContext);
371 if (d->platformGLContext)
372 destroy();
373
374 auto *platformContext = QGuiApplicationPrivate::platformIntegration()->createPlatformOpenGLContext(this);
375 if (!platformContext)
376 return false;
377
378 d->adopt(platformContext);
379
380 return isValid();
381}
382
386
400
419void QOpenGLContext::destroy()
420{
421 Q_D(QOpenGLContext);
422
423 // Notify that the native context and the QPlatformOpenGLContext are going
424 // to go away.
425 if (d->platformGLContext)
427
428 // Invoke callbacks for helpers and invalidate.
429 if (d->textureFunctionsDestroyCallback) {
430 d->textureFunctionsDestroyCallback();
431 d->textureFunctionsDestroyCallback = nullptr;
432 }
433 d->textureFunctions = nullptr;
434
435 delete d->versionFunctions;
436 d->versionFunctions = nullptr;
437
438 if (d->vaoHelperDestroyCallback) {
439 Q_ASSERT(d->vaoHelper);
440 d->vaoHelperDestroyCallback(d->vaoHelper);
441 d->vaoHelperDestroyCallback = nullptr;
442 }
443 d->vaoHelper = nullptr;
444
445 // Tear down function wrappers.
446 delete d->versionFunctions;
447 d->versionFunctions = nullptr;
448
449 delete d->functions;
450 d->functions = nullptr;
451
452 // Clean up and destroy the native context machinery.
453 if (QOpenGLContext::currentContext() == this)
454 doneCurrent();
455
456 if (d->shareGroup)
457 d->shareGroup->d_func()->removeContext(this);
458
459 d->shareGroup = nullptr;
460
461 delete d->platformGLContext;
462 d->platformGLContext = nullptr;
463}
464
487{
488 destroy();
489
490#ifndef QT_NO_DEBUG
492#endif
493}
494
518{
519 Q_D(const QOpenGLContext);
520 return d->platformGLContext && d->platformGLContext->isValid();
521}
522
535{
536 Q_D(const QOpenGLContext);
537 if (!d->functions)
538 const_cast<QOpenGLFunctions *&>(d->functions) = new QOpenGLExtensions(QOpenGLContext::currentContext());
539 return d->functions;
540}
541
563
571QSet<QByteArray> QOpenGLContext::extensions() const
572{
573 Q_D(const QOpenGLContext);
574 if (d->extensionNames.isEmpty()) {
576 d->extensionNames = matcher.extensions();
577 }
578
579 return d->extensionNames;
580}
581
594
620{
621 if (!isValid())
622 return 0;
623
624 Q_D(const QOpenGLContext);
625 if (!d->surface || !d->surface->surfaceHandle())
626 return 0;
627
628 if (d->defaultFboRedirect)
629 return d->defaultFboRedirect;
630
631 return d->platformGLContext->defaultFramebufferObject(d->surface->surfaceHandle());
632}
633
658{
659 Q_D(QOpenGLContext);
660 if (!isValid())
661 return false;
662
664 && thread() != QThread::currentThread())) {
665 qFatal("Cannot make QOpenGLContext current in a different thread");
666 }
667
668 if (!surface) {
669 doneCurrent();
670 return true;
671 }
672
673 if (!surface->surfaceHandle())
674 return false;
675 if (!surface->supportsOpenGL()) {
676 qWarning() << "QOpenGLContext::makeCurrent() called with non-opengl surface" << surface;
677 return false;
678 }
679
680 if (!d->platformGLContext->makeCurrent(surface->surfaceHandle()))
681 return false;
682
684#ifndef QT_NO_DEBUG
686#endif
687
688 d->surface = surface;
689
690 static bool needsWorkaroundSet = false;
691 static bool needsWorkaround = false;
692
693 if (!needsWorkaroundSet) {
694 QByteArray env;
695#ifdef Q_OS_ANDROID
696 env = qgetenv(QByteArrayLiteral("QT_ANDROID_DISABLE_GLYPH_CACHE_WORKAROUND"));
697 needsWorkaround = env.isEmpty() || env == QByteArrayLiteral("0") || env == QByteArrayLiteral("false");
698#endif
699 env = qgetenv(QByteArrayLiteral("QT_ENABLE_GLYPH_CACHE_WORKAROUND"));
700 if (env == QByteArrayLiteral("1") || env == QByteArrayLiteral("true"))
701 needsWorkaround = true;
702
703 if (!needsWorkaround) {
704 const char *rendererString = reinterpret_cast<const char *>(functions()->glGetString(GL_RENDERER));
705 if (rendererString)
706 needsWorkaround =
707 qstrncmp(rendererString, "Mali-4xx", 6) == 0 // Mali-400, Mali-450
708 || qstrcmp(rendererString, "Mali-T880") == 0
709 || qstrncmp(rendererString, "Adreno (TM) 2xx", 13) == 0 // Adreno 200, 203, 205
710 || qstrncmp(rendererString, "Adreno 2xx", 8) == 0 // Same as above but without the '(TM)'
711 || qstrncmp(rendererString, "Adreno (TM) 3xx", 13) == 0 // Adreno 302, 305, 320, 330
712 || qstrncmp(rendererString, "Adreno 3xx", 8) == 0 // Same as above but without the '(TM)'
713 || qstrncmp(rendererString, "Adreno (TM) 4xx", 13) == 0 // Adreno 405, 418, 420, 430
714 || qstrncmp(rendererString, "Adreno 4xx", 8) == 0 // Same as above but without the '(TM)'
715 || qstrncmp(rendererString, "Adreno (TM) 5xx", 13) == 0 // Adreno 505, 506, 510, 530, 540
716 || qstrncmp(rendererString, "Adreno 5xx", 8) == 0 // Same as above but without the '(TM)'
717 || qstrncmp(rendererString, "Adreno (TM) 6xx", 13) == 0 // Adreno 610, 620, 630
718 || qstrncmp(rendererString, "Adreno 6xx", 8) == 0 // Same as above but without the '(TM)'
719 || qstrcmp(rendererString, "GC800 core") == 0
720 || qstrcmp(rendererString, "GC1000 core") == 0
721 || strstr(rendererString, "GC2000") != nullptr
722 || qstrcmp(rendererString, "Immersion.16") == 0
723 || qstrncmp(rendererString, "Apple Mx", 7) == 0;
724 }
725 needsWorkaroundSet = true;
726 }
727
728 if (needsWorkaround)
729 d->workaround_brokenFBOReadBack = true;
730
731 d->shareGroup->d_func()->deletePendingResources(this);
732
733 return true;
734}
735
744{
745 Q_D(QOpenGLContext);
746 if (!isValid())
747 return;
748
749 if (QOpenGLContext::currentContext() == this)
750 d->shareGroup->d_func()->deletePendingResources(this);
751
752 d->platformGLContext->doneCurrent();
754
755 d->surface = nullptr;
756}
757
764{
765 Q_D(const QOpenGLContext);
766 return d->surface;
767}
768
769
778{
779 Q_D(QOpenGLContext);
780 if (!isValid())
781 return;
782
783 if (!surface) {
784 qWarning("QOpenGLContext::swapBuffers() called with null argument");
785 return;
786 }
787
788 if (!surface->supportsOpenGL()) {
789 qWarning("QOpenGLContext::swapBuffers() called with non-opengl surface");
790 return;
791 }
792
793 QPlatformSurface *surfaceHandle = surface->surfaceHandle();
794 if (!surfaceHandle)
795 return;
796
797#if !defined(QT_NO_DEBUG)
799 qWarning("QOpenGLContext::swapBuffers() called without corresponding makeCurrent()");
800#endif
801 if (surface->format().swapBehavior() == QSurfaceFormat::SingleBuffer)
802 functions()->glFlush();
803 d->platformGLContext->swapBuffers(surfaceHandle);
804}
805
811QFunctionPointer QOpenGLContext::getProcAddress(const QByteArray &procName) const
812{
813 return getProcAddress(procName.constData());
814}
815
820QFunctionPointer QOpenGLContext::getProcAddress(const char *procName) const
821{
822 Q_D(const QOpenGLContext);
823 if (!d->platformGLContext)
824 return nullptr;
825 return d->platformGLContext->getProcAddress(procName);
826}
827
848{
849 Q_D(const QOpenGLContext);
850 if (!d->platformGLContext)
851 return d->requestedFormat;
852 return d->platformGLContext->format();
853}
854
859{
860 Q_D(const QOpenGLContext);
861 return d->shareGroup;
862}
863
871{
872 Q_D(const QOpenGLContext);
873 return d->shareContext;
874}
875
880{
881 Q_D(const QOpenGLContext);
882 return d->screen;
883}
884
912{
913#if defined(QT_OPENGL_DYNAMIC)
915 return QGuiApplicationPrivate::instance()->platformIntegration()->openGLModuleType();
916#elif QT_CONFIG(opengles2)
917 return LibGLES;
918#else
919 return LibGL;
920#endif
921}
922
937
952
977
981QOpenGLTextureHelper* QOpenGLContext::textureFunctions() const
982{
983 Q_D(const QOpenGLContext);
984 return d->textureFunctions;
985}
986
990void QOpenGLContext::setTextureFunctions(QOpenGLTextureHelper* textureFuncs, std::function<void()> destroyCallback)
991{
992 Q_D(QOpenGLContext);
993 d->textureFunctions = textureFuncs;
994 d->textureFunctionsDestroyCallback = destroyCallback;
995}
996
1010QOpenGLContextGroup::QOpenGLContextGroup()
1012{
1013}
1014
1019{
1021 d->cleanup();
1022}
1023
1027QList<QOpenGLContext *> QOpenGLContextGroup::shares() const
1028{
1029 Q_D(const QOpenGLContextGroup);
1030 return d->m_shares;
1031}
1032
1039{
1041 return current ? current->shareGroup() : nullptr;
1042}
1043
1045 = default;
1046
1048{
1049 const auto locker = qt_scoped_lock(m_mutex);
1050 m_refs.ref();
1051 m_shares << ctx;
1052}
1053
1055{
1057
1058 bool deleteObject = false;
1059
1060 {
1061 const auto locker = qt_scoped_lock(m_mutex);
1063
1064 if (ctx == m_context && !m_shares.isEmpty())
1066
1067 if (!m_refs.deref()) {
1068 cleanup();
1069 deleteObject = true;
1070 }
1071 }
1072
1073 if (deleteObject) {
1074 if (q->thread() == QThread::currentThread())
1075 delete q; // Delete directly to prevent leak, refer to QTBUG-29056
1076 else
1077 q->deleteLater();
1078 }
1079}
1080
1082{
1084 {
1087 for (it = m_resources.constBegin(); it != end; ++it)
1088 it.key()->cleanup(q, it.value());
1090 }
1091
1094
1095 while (it != end) {
1096 (*it)->invalidateResource();
1097 (*it)->m_group = nullptr;
1098 ++it;
1099 }
1100
1102
1105}
1106
1108{
1109 const auto locker = qt_scoped_lock(m_mutex);
1110
1111 const QList<QOpenGLSharedResource *> pending = m_pendingDeletion;
1113
1116 while (it != end) {
1117 (*it)->freeResource(ctx);
1118 delete *it;
1119 ++it;
1120 }
1121}
1122
1148 : m_group(group)
1149{
1150 const auto locker = qt_scoped_lock(m_group->d_func()->m_mutex);
1151 m_group->d_func()->m_sharedResources << this;
1152}
1153
1157
1158// schedule the resource for deletion at an appropriate time
1160{
1161 if (!m_group) {
1162 delete this;
1163 return;
1164 }
1165
1166 const auto locker = qt_scoped_lock(m_group->d_func()->m_mutex);
1167 m_group->d_func()->m_sharedResources.removeOne(this);
1168 m_group->d_func()->m_pendingDeletion << this;
1169
1170 // can we delete right away?
1172 if (current && current->shareGroup() == m_group) {
1173 m_group->d_func()->deletePendingResources(current);
1174 }
1175}
1176
1190 = default;
1191
1193{
1194 if (m_id) {
1195 QOpenGLFunctions functions(context);
1196 m_func(&functions, m_id);
1197 m_id = 0;
1198 }
1199}
1200
1218 : active(0)
1219{
1220#ifdef QT_GL_CONTEXT_RESOURCE_DEBUG
1221 qDebug("Creating context group resource object %p.", this);
1222#endif
1223}
1224
1226{
1227#ifdef QT_GL_CONTEXT_RESOURCE_DEBUG
1228 qDebug("Deleting context group resource %p. Group size: %d.", this, m_groups.size());
1229#endif
1230 for (int i = 0; i < m_groups.size(); ++i) {
1231 if (!m_groups.at(i)->shares().isEmpty()) {
1232 QOpenGLContext *context = m_groups.at(i)->shares().constFirst();
1233 QOpenGLSharedResource *resource = value(context);
1234 if (resource)
1235 resource->free();
1236 }
1237 m_groups.at(i)->d_func()->m_resources.remove(this);
1238 active.deref();
1239 }
1240#ifndef QT_NO_DEBUG
1241 if (active.loadRelaxed() != 0) {
1242 qWarning("QtGui: Resources are still available at program shutdown.\n"
1243 " This is possibly caused by a leaked QOpenGLWidget, \n"
1244 " QOpenGLFramebufferObject or QOpenGLPixelBuffer.");
1245 }
1246#endif
1247}
1248
1250{
1251#ifdef QT_GL_CONTEXT_RESOURCE_DEBUG
1252 qDebug("Inserting context group resource %p for context %p, managed by %p.", value, context, this);
1253#endif
1254 QOpenGLContextGroup *group = context->shareGroup();
1255 Q_ASSERT(!group->d_func()->m_resources.contains(this));
1256 group->d_func()->m_resources.insert(this, value);
1257 m_groups.append(group);
1258 active.ref();
1259}
1260
1262{
1263 QOpenGLContextGroup *group = context->shareGroup();
1264 return group->d_func()->m_resources.value(this, nullptr);
1265}
1266
1267QList<QOpenGLSharedResource *> QOpenGLMultiGroupSharedResource::resources() const
1268{
1269 QList<QOpenGLSharedResource *> result;
1270 for (QList<QOpenGLContextGroup *>::const_iterator it = m_groups.constBegin(); it != m_groups.constEnd(); ++it) {
1271 QOpenGLSharedResource *resource = (*it)->d_func()->m_resources.value(const_cast<QOpenGLMultiGroupSharedResource *>(this), nullptr);
1272 if (resource)
1273 result << resource;
1274 }
1275 return result;
1276}
1277
1279{
1280#ifdef QT_GL_CONTEXT_RESOURCE_DEBUG
1281 qDebug("Cleaning up context group resource %p, for group %p in thread %p.", this, group, QThread::currentThread());
1282#endif
1283 value->invalidateResource();
1284 value->free();
1285 active.deref();
1286
1287 Q_ASSERT(m_groups.contains(group));
1288 m_groups.removeOne(group);
1289}
1290
1292 = default;
1293
1294#ifndef QT_NO_DEBUG_STREAM
1296{
1297 QDebugStateSaver saver(debug);
1298 debug.nospace();
1299 debug.noquote();
1300 debug << "QOpenGLContext(";
1301 if (ctx) {
1302 debug << static_cast<const void *>(ctx);
1303 if (ctx->isValid()) {
1304 debug << ", format=" << ctx->format();
1305 if (const QSurface *sf = ctx->surface())
1306 debug << ", surface=" << sf;
1307 if (const QScreen *s = ctx->screen())
1308 debug << ", screen=\"" << s->name() << '"';
1309 } else {
1310 debug << ", invalid";
1311 }
1312 } else {
1313 debug << '0';
1314 }
1315 debug << ')';
1316 return debug;
1317}
1318
1320{
1321 QDebugStateSaver saver(debug);
1322 debug.nospace();
1323 debug << "QOpenGLContextGroup(";
1324 if (cg)
1325 debug << cg->shares();
1326 else
1327 debug << '0';
1328 debug << ')';
1329 return debug;
1330}
1331#endif // QT_NO_DEBUG_STREAM
1332
1333using namespace QNativeInterface;
1334
1335void *QOpenGLContext::resolveInterface(const char *name, int revision) const
1336{
1337 Q_UNUSED(name); Q_UNUSED(revision);
1338
1339 auto *platformContext = handle();
1340 Q_UNUSED(platformContext);
1341
1342#if defined(Q_OS_MACOS)
1344#endif
1345#if defined(Q_OS_WIN)
1347#endif
1348#if QT_CONFIG(xcb_glx_plugin)
1350#endif
1351#if QT_CONFIG(egl)
1352 QT_NATIVE_INTERFACE_RETURN_IF(QEGLContext, platformContext);
1353#endif
1354
1355 return nullptr;
1356}
1357
1359
1360#include "moc_qopenglcontext.cpp"
bool ref() noexcept
bool deref() noexcept
T loadRelaxed() const noexcept
\inmodule QtCore
Definition qbytearray.h:57
bool isEmpty() const noexcept
Returns true if the byte array has size 0; otherwise returns false.
Definition qbytearray.h:107
\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:1145
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:1219
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:1215
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:951
qsizetype size() const noexcept
Definition qlist.h:397
bool isEmpty() const noexcept
Definition qlist.h:401
bool removeOne(const AT &t)
Definition qlist.h:598
iterator end()
Definition qlist.h:626
const_reference at(qsizetype i) const noexcept
Definition qlist.h:446
const_iterator constBegin() const noexcept
Definition qlist.h:632
iterator begin()
Definition qlist.h:625
const T & constFirst() const noexcept
Definition qlist.h:647
void append(parameter_type t)
Definition qlist.h:458
const_iterator constEnd() const noexcept
Definition qlist.h:633
void clear()
Definition qlist.h:434
\inmodule QtCore
Definition qmutex.h:281
\inheaderfile QOpenGLContext
\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
QThread * thread() const
Returns the thread in which the object lives.
Definition qobject.cpp:1598
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)
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
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.
\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.
static QThread * currentThread()
Definition qthread.cpp:1039
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:461
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:164
#define qWarning
Definition qlogging.h:166
#define qFatal
Definition qlogging.h:168
#define QT_NATIVE_INTERFACE_RETURN_IF(NativeInterface, baseType)
#define SLOT(a)
Definition qobjectdefs.h:52
#define SIGNAL(a)
Definition qobjectdefs.h:53
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
GLdouble s
[6]
Definition qopenglext.h:235
const void * getProcAddress
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
GLuint64EXT * result
[6]
#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:45