diff options
author | James Turner <james.turner@kdab.com> | 2013-10-15 18:32:02 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-10-16 17:10:15 +0200 |
commit | 42c8c7e9dbf4c9e67b88bd16f0fe4e0d3c57857b (patch) | |
tree | 497ddc42cf92a093fcbb37d69e18f004e63ae59d | |
parent | b271ddebfcda26839a02705f17e287a4686f36fb (diff) |
Support APPLE VAO extension on Mac.
Since Mac lacks a compatibility profile, we often use the highest
supported compatible version, 2.1; this lacks vertex-array-object (VAO)
support in the API, but Apple provide a compatible extension. Extend
the helper object to detect this case and make VAO support work.
Change-Id: I75a74e048a0d188cec76bc5a4a9eafa4c9143740
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
-rw-r--r-- | src/gui/opengl/qopenglvertexarrayobject.cpp | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/src/gui/opengl/qopenglvertexarrayobject.cpp b/src/gui/opengl/qopenglvertexarrayobject.cpp index 16ed79ac10..1f039a8ca9 100644 --- a/src/gui/opengl/qopenglvertexarrayobject.cpp +++ b/src/gui/opengl/qopenglvertexarrayobject.cpp @@ -58,9 +58,15 @@ public: { Q_ASSERT(context); #if !defined(QT_OPENGL_ES_2) - GenVertexArrays = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLsizei , GLuint *)>(context->getProcAddress("glGenVertexArrays")); - DeleteVertexArrays = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLsizei , const GLuint *)>(context->getProcAddress("glDeleteVertexArrays")); - BindVertexArray = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLuint )>(context->getProcAddress("glBindVertexArray")); + 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("glGenVertexArrays")); + DeleteVertexArrays = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLsizei , const GLuint *)>(context->getProcAddress("glDeleteVertexArrays")); + BindVertexArray = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLuint )>(context->getProcAddress("glBindVertexArray")); + } #else GenVertexArrays = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLsizei , GLuint *)>(context->getProcAddress("glGenVertexArraysOES")); DeleteVertexArrays = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLsizei , const GLuint *)>(context->getProcAddress("glDeleteVertexArraysOES")); @@ -84,7 +90,7 @@ public: } private: - // Function signatures are equivalent between desktop core, ARB and ES 2 extensions + // Function signatures are equivalent between desktop core, ARB, APPLE 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); @@ -109,8 +115,8 @@ public: #if defined(QT_OPENGL_ES_2) delete vaoFuncs; #else - if (vaoFuncsType == ARB) - delete vaoFuncs.arb; + if ((vaoFuncsType == ARB) || (vaoFuncsType == APPLE)) + delete vaoFuncs.helper; #endif } @@ -130,13 +136,14 @@ public: union { QOpenGLFunctions_3_0 *core_3_0; QOpenGLFunctions_3_2_Core *core_3_2; - QVertexArrayObjectHelper *arb; + QVertexArrayObjectHelper *helper; } vaoFuncs; enum { NotSupported, Core_3_0, Core_3_2, - ARB + ARB, + APPLE } vaoFuncsType; #endif QOpenGLContext *context; @@ -181,9 +188,13 @@ bool QOpenGLVertexArrayObjectPrivate::create() vaoFuncs.core_3_0->initializeOpenGLFunctions(); vaoFuncs.core_3_0->glGenVertexArrays(1, &vao); } else if (ctx->hasExtension("GL_ARB_vertex_array_object")) { - vaoFuncs.arb = new QVertexArrayObjectHelper(ctx); + vaoFuncs.helper = new QVertexArrayObjectHelper(ctx); vaoFuncsType = ARB; - vaoFuncs.arb->glGenVertexArrays(1, &vao); + vaoFuncs.helper->glGenVertexArrays(1, &vao); + } else if (ctx->hasExtension(QByteArrayLiteral("GL_APPLE_vertex_array_object"))) { + vaoFuncs.helper = new QVertexArrayObjectHelper(ctx); + vaoFuncsType = APPLE; + vaoFuncs.helper->glGenVertexArrays(1, &vao); } #endif return (vao != 0); @@ -205,7 +216,8 @@ void QOpenGLVertexArrayObjectPrivate::destroy() vaoFuncs.core_3_0->glDeleteVertexArrays(1, &vao); break; case ARB: - vaoFuncs.arb->glDeleteVertexArrays(1, &vao); + case APPLE: + vaoFuncs.helper->glDeleteVertexArrays(1, &vao); break; case NotSupported: break; @@ -236,7 +248,8 @@ void QOpenGLVertexArrayObjectPrivate::bind() vaoFuncs.core_3_0->glBindVertexArray(vao); break; case ARB: - vaoFuncs.arb->glBindVertexArray(vao); + case APPLE: + vaoFuncs.helper->glBindVertexArray(vao); break; case NotSupported: break; @@ -258,7 +271,8 @@ void QOpenGLVertexArrayObjectPrivate::release() vaoFuncs.core_3_0->glBindVertexArray(0); break; case ARB: - vaoFuncs.arb->glBindVertexArray(0); + case APPLE: + vaoFuncs.helper->glBindVertexArray(0); break; case NotSupported: break; |