summaryrefslogtreecommitdiffstats
path: root/src/gui/opengl/qopenglpaintengine.cpp
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2011-09-07 08:40:28 +0200
committerGunnar Sletta <gunnar.sletta@nokia.com>2011-09-07 08:50:49 +0200
commitc8fcc2929820b5deafc1e84a3bcb719d87028bd6 (patch)
tree20ebc64cff3a3d4f3747299df89cbd75991d2c30 /src/gui/opengl/qopenglpaintengine.cpp
parent6119d12d7d7d63b00891e7fa21a5fab6751fb062 (diff)
Fixed crash in tst_QGL::multipleFBOInterleavedRendering().
Properly check for the ElementIndexUint extension. Change-Id: I8117aa052f2dd697a2dadeb7ce84a415b5fd24c8 Reviewed-on: http://codereview.qt.nokia.com/4311 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
Diffstat (limited to 'src/gui/opengl/qopenglpaintengine.cpp')
-rw-r--r--src/gui/opengl/qopenglpaintengine.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/gui/opengl/qopenglpaintengine.cpp b/src/gui/opengl/qopenglpaintengine.cpp
index 6b9878edf3..dfb8549375 100644
--- a/src/gui/opengl/qopenglpaintengine.cpp
+++ b/src/gui/opengl/qopenglpaintengine.cpp
@@ -666,6 +666,7 @@ struct QOpenGL2PEVectorPathCache
int indexCount;
GLenum primitiveType;
qreal iscale;
+ QVertexIndexVector::Type indexType;
};
void QOpenGL2PaintEngineExPrivate::cleanupVectorPath(QPaintEngineEx *engine, void *data)
@@ -823,13 +824,14 @@ void QOpenGL2PaintEngineExPrivate::fill(const QVectorPath& path)
cache->indexCount = polys.indices.size();
cache->primitiveType = GL_TRIANGLES;
cache->iscale = inverseScale;
+ cache->indexType = polys.indices.type();
#ifdef QT_OPENGL_CACHE_AS_VBOS
glGenBuffers(1, &cache->vbo);
glGenBuffers(1, &cache->ibo);
glBindBuffer(GL_ARRAY_BUFFER, cache->vbo);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, cache->ibo);
- if (funcs.hasOpenGLExtension(QOpenGLExtensions::ElementIndexUint))
+ if (polys.indices.type() == QVertexIndexVector::UnsignedInt)
funcs.glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(quint32) * polys.indices.size(), polys.indices.data(), GL_STATIC_DRAW);
else
funcs.glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(quint16) * polys.indices.size(), polys.indices.data(), GL_STATIC_DRAW);
@@ -840,7 +842,7 @@ void QOpenGL2PaintEngineExPrivate::fill(const QVectorPath& path)
funcs.glBufferData(GL_ARRAY_BUFFER, sizeof(float) * vertices.size(), vertices.data(), GL_STATIC_DRAW);
#else
cache->vertices = (float *) qMalloc(sizeof(float) * polys.vertices.size());
- if (funcs.hasOpenGLExtension(QOpenGLExtensions::ElementIndexUint)) {
+ if (polys.indices.type() == QVertexIndexVector::UnsignedInt) {
cache->indices = (quint32 *) qMalloc(sizeof(quint32) * polys.indices.size());
memcpy(cache->indices, polys.indices.data(), sizeof(quint32) * polys.indices.size());
} else {
@@ -857,7 +859,7 @@ void QOpenGL2PaintEngineExPrivate::fill(const QVectorPath& path)
glBindBuffer(GL_ARRAY_BUFFER, cache->vbo);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, cache->ibo);
setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, 0);
- if (funcs.hasOpenGLExtension(QOpenGLExtensions::ElementIndexUint))
+ if (cache->indexType == QVertexIndexVector::UnsignedInt)
glDrawElements(cache->primitiveType, cache->indexCount, GL_UNSIGNED_INT, 0);
else
glDrawElements(cache->primitiveType, cache->indexCount, GL_UNSIGNED_SHORT, 0);
@@ -865,7 +867,7 @@ void QOpenGL2PaintEngineExPrivate::fill(const QVectorPath& path)
glBindBuffer(GL_ARRAY_BUFFER, 0);
#else
setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, cache->vertices);
- if (funcs.hasOpenGLExtension(QOpenGLExtensions::ElementIndexUint))
+ if (cache->indexType == QVertexIndexVector::UnsignedInt)
glDrawElements(cache->primitiveType, cache->indexCount, GL_UNSIGNED_INT, (qint32 *)cache->indices);
else
glDrawElements(cache->primitiveType, cache->indexCount, GL_UNSIGNED_SHORT, (qint16 *)cache->indices);