diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp index d476278a7db..9d8ec114395 100644 --- a/src/gui/kernel/qopenglcontext.cpp +++ b/src/gui/kernel/qopenglcontext.cpp @@ -49,6 +49,7 @@ #include #include +#include #include #include @@ -401,6 +402,37 @@ QOpenGLFunctions *QOpenGLContext::functions() const return d->functions; } +/*! + Returns the set of OpenGL extensions supported by this context. + + The context or a sharing context must be current. + + \sa hasExtension() +*/ +QSet QOpenGLContext::extensions() const +{ + Q_D(const QOpenGLContext); + if (d->extensionNames.isEmpty()) { + QOpenGLExtensionMatcher matcher; + d->extensionNames = matcher.extensions(); + } + + return d->extensionNames; +} + +/*! + Returns true if this OpenGL context supports the specified OpenGL + \a extension, false otherwise. + + The context or a sharing context must be current. + + \sa extensions() +*/ +bool QOpenGLContext::hasExtension(const QByteArray &extension) const +{ + return extensions().contains(extension); +} + /*! Call this to get the default framebuffer object for the current surface. diff --git a/src/gui/kernel/qopenglcontext.h b/src/gui/kernel/qopenglcontext.h index b9a47a54b85..2dd92c99922 100644 --- a/src/gui/kernel/qopenglcontext.h +++ b/src/gui/kernel/qopenglcontext.h @@ -129,6 +129,9 @@ public: QOpenGLFunctions *functions() const; + QSet extensions() const; + bool hasExtension(const QByteArray &extension) const; + Q_SIGNALS: void aboutToBeDestroyed(); diff --git a/src/gui/kernel/qopenglcontext_p.h b/src/gui/kernel/qopenglcontext_p.h index 5f3dee1e516..ac72b76ea4f 100644 --- a/src/gui/kernel/qopenglcontext_p.h +++ b/src/gui/kernel/qopenglcontext_p.h @@ -49,7 +49,9 @@ #include #include +#include #include +#include QT_BEGIN_HEADER @@ -212,6 +214,7 @@ public: QScreen *screen; QSurface *surface; QOpenGLFunctions *functions; + mutable QSet extensionNames; GLuint current_fbo; GLint max_texture_size;