OpenGL: Allow querying OpenGL extensions via the QOpenGLContext

Change-Id: Ia88470554bbfd2a56738dadfcafafe42a990382d
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
This commit is contained in:
Sean Harmer 2012-08-07 09:37:30 +01:00 committed by Qt by Nokia
parent 5410299d94
commit d1bb10d9b8
3 changed files with 38 additions and 0 deletions

View File

@ -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>
@ -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<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.

View File

@ -129,6 +129,9 @@ public:
QOpenGLFunctions *functions() const;
QSet<QByteArray> extensions() const;
bool hasExtension(const QByteArray &extension) const;
Q_SIGNALS:
void aboutToBeDestroyed();

View File

@ -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;