summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Harmer <sean.harmer@kdab.com>2012-08-07 09:37:30 +0100
committerQt by Nokia <qt-info@nokia.com>2012-08-09 13:19:34 +0200
commitd1bb10d9b8f2d072dba8020e354326f91f5981f4 (patch)
tree5195b9f3ee81f52e2facca335b8423beb5c34fa2
parent5410299d945354cfe96729b6779fbfcbe2f4ae28 (diff)
OpenGL: Allow querying OpenGL extensions via the QOpenGLContext
Change-Id: Ia88470554bbfd2a56738dadfcafafe42a990382d Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
-rw-r--r--src/gui/kernel/qopenglcontext.cpp32
-rw-r--r--src/gui/kernel/qopenglcontext.h3
-rw-r--r--src/gui/kernel/qopenglcontext_p.h3
3 files changed, 38 insertions, 0 deletions
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 <QtCore/QThread>
#include <QtGui/private/qguiapplication_p.h>
+#include <QtGui/private/qopengl_p.h>
#include <QtGui/private/qwindow_p.h>
#include <QtGui/QScreen>
@@ -402,6 +403,37 @@ QOpenGLFunctions *QOpenGLContext::functions() const
}
/*!
+ Returns the set of OpenGL extensions supported by this context.
+
+ The context or a sharing context must be current.
+
+ \sa hasExtension()
+*/
+QSet<QByteArray> 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.
On some platforms the default framebuffer object depends on the 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<QByteArray> 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 <private/qobject_p.h>
#include <qmutex.h>
+#include <QtCore/QByteArray>
#include <QtCore/QHash>
+#include <QtCore/QSet>
QT_BEGIN_HEADER
@@ -212,6 +214,7 @@ public:
QScreen *screen;
QSurface *surface;
QOpenGLFunctions *functions;
+ mutable QSet<QByteArray> extensionNames;
GLuint current_fbo;
GLint max_texture_size;