summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@digia.com>2014-07-02 16:33:15 +0200
committerLaszlo Agocs <laszlo.agocs@digia.com>2014-07-02 19:53:20 +0200
commit0541516907da117c391b6c8d9820209673fcd9cd (patch)
treec7a5d7dcc561b4a8270fc569e2196fd03223c7bf /src
parentc71469530406f5d0214ceb1f10c0db051a9eee84 (diff)
Use the standard functions in GLES3 builds in VAOs
There is no guarantee that the OES extension is present and the standard functions are not required to be dynamically resolvable on ES. By performing the ARB-style lookup for the suffixless function names we can also support ES3 compatible contexts on desktop GL. This also fixes the problem of picking up the APPLE extension functions instead of ARB when both are available. vaoFuncsType was set to ARB correctly but the helper has to take the preference of ARB into account too. Task-number: QTBUG-38168 Change-Id: If7402320e8f96891017674f3c43bc57c4b5d29f3 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src')
-rw-r--r--src/gui/opengl/qopenglvertexarrayobject.cpp42
1 files changed, 28 insertions, 14 deletions
diff --git a/src/gui/opengl/qopenglvertexarrayobject.cpp b/src/gui/opengl/qopenglvertexarrayobject.cpp
index 5ebfc9a9c8..d9b9385751 100644
--- a/src/gui/opengl/qopenglvertexarrayobject.cpp
+++ b/src/gui/opengl/qopenglvertexarrayobject.cpp
@@ -60,20 +60,34 @@ public:
QVertexArrayObjectHelper(QOpenGLContext *context)
{
Q_ASSERT(context);
+ bool tryARB = true;
+
if (context->isOpenGLES()) {
- GenVertexArrays = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLsizei , GLuint *)>(context->getProcAddress(QByteArrayLiteral("glGenVertexArraysOES")));
- DeleteVertexArrays = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLsizei , const GLuint *)>(context->getProcAddress(QByteArrayLiteral("glDeleteVertexArraysOES")));
- BindVertexArray = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLuint )>(context->getProcAddress(QByteArrayLiteral("glBindVertexArrayOES")));
- } else {
- if (context->hasExtension(QByteArrayLiteral("GL_APPLE_vertex_array_object"))) {
- GenVertexArrays = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLsizei , GLuint *)>(context->getProcAddress(QByteArrayLiteral("glGenVertexArraysAPPLE")));
- DeleteVertexArrays = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLsizei , const GLuint *)>(context->getProcAddress(QByteArrayLiteral("glDeleteVertexArraysAPPLE")));
- BindVertexArray = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLuint )>(context->getProcAddress(QByteArrayLiteral("glBindVertexArrayAPPLE")));
- } else {
- GenVertexArrays = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLsizei , GLuint *)>(context->getProcAddress(QByteArrayLiteral("glGenVertexArrays")));
- DeleteVertexArrays = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLsizei , const GLuint *)>(context->getProcAddress(QByteArrayLiteral("glDeleteVertexArrays")));
- BindVertexArray = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLuint )>(context->getProcAddress(QByteArrayLiteral("glBindVertexArray")));
+#ifdef QT_OPENGL_ES_3
+ GenVertexArrays = ::glGenVertexArrays;
+ DeleteVertexArrays = ::glDeleteVertexArrays;
+ BindVertexArray = ::glBindVertexArray;
+ tryARB = false;
+#else
+ if (context->hasExtension(QByteArrayLiteral("GL_OES_vertex_array_object"))) {
+ GenVertexArrays = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLsizei , GLuint *)>(context->getProcAddress(QByteArrayLiteral("glGenVertexArraysOES")));
+ DeleteVertexArrays = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLsizei , const GLuint *)>(context->getProcAddress(QByteArrayLiteral("glDeleteVertexArraysOES")));
+ BindVertexArray = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLuint )>(context->getProcAddress(QByteArrayLiteral("glBindVertexArrayOES")));
+ tryARB = false;
}
+#endif
+ } else if (!context->hasExtension(QByteArrayLiteral("GL_ARB_vertex_array_object"))
+ && context->hasExtension(QByteArrayLiteral("GL_APPLE_vertex_array_object"))) {
+ GenVertexArrays = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLsizei , GLuint *)>(context->getProcAddress(QByteArrayLiteral("glGenVertexArraysAPPLE")));
+ DeleteVertexArrays = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLsizei , const GLuint *)>(context->getProcAddress(QByteArrayLiteral("glDeleteVertexArraysAPPLE")));
+ BindVertexArray = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLuint )>(context->getProcAddress(QByteArrayLiteral("glBindVertexArrayAPPLE")));
+ tryARB = false;
+ }
+
+ if (tryARB) {
+ GenVertexArrays = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLsizei , GLuint *)>(context->getProcAddress(QByteArrayLiteral("glGenVertexArrays")));
+ DeleteVertexArrays = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLsizei , const GLuint *)>(context->getProcAddress(QByteArrayLiteral("glDeleteVertexArrays")));
+ BindVertexArray = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLuint )>(context->getProcAddress(QByteArrayLiteral("glBindVertexArray")));
}
}
@@ -93,7 +107,7 @@ public:
}
private:
- // Function signatures are equivalent between desktop core, ARB, APPLE and ES 2 extensions
+ // Function signatures are equivalent between desktop core, ARB, APPLE, ES3 and ES 2 extensions
void (QOPENGLF_APIENTRYP GenVertexArrays)(GLsizei n, GLuint *arrays);
void (QOPENGLF_APIENTRYP DeleteVertexArrays)(GLsizei n, const GLuint *arrays);
void (QOPENGLF_APIENTRYP BindVertexArray)(GLuint array);
@@ -160,7 +174,7 @@ bool QOpenGLVertexArrayObjectPrivate::create()
QObject::connect(context, SIGNAL(aboutToBeDestroyed()), q, SLOT(_q_contextAboutToBeDestroyed()));
if (ctx->isOpenGLES()) {
- if (ctx->hasExtension(QByteArrayLiteral("GL_OES_vertex_array_object"))) {
+ if (ctx->format().majorVersion() >= 3 || ctx->hasExtension(QByteArrayLiteral("GL_OES_vertex_array_object"))) {
vaoFuncs.helper = new QVertexArrayObjectHelper(ctx);
vaoFuncsType = OES;
vaoFuncs.helper->glGenVertexArrays(1, &vao);