From d1bb10d9b8f2d072dba8020e354326f91f5981f4 Mon Sep 17 00:00:00 2001 From: Sean Harmer Date: Tue, 7 Aug 2012 09:37:30 +0100 Subject: OpenGL: Allow querying OpenGL extensions via the QOpenGLContext MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ia88470554bbfd2a56738dadfcafafe42a990382d Reviewed-by: Samuel Rødal --- src/gui/kernel/qopenglcontext.cpp | 32 ++++++++++++++++++++++++++++++++ src/gui/kernel/qopenglcontext.h | 3 +++ src/gui/kernel/qopenglcontext_p.h | 3 +++ 3 files changed, 38 insertions(+) (limited to 'src/gui/kernel') diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp index d476278a7d..9d8ec11439 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 b9a47a54b8..2dd92c9992 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 5f3dee1e51..ac72b76ea4 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; -- cgit v1.2.3