summaryrefslogtreecommitdiffstats
path: root/src/opengl/qgl.cpp
diff options
context:
space:
mode:
authorTom Cooksey <thomas.cooksey@nokia.com>2009-12-30 08:21:34 (GMT)
committerTom Cooksey <thomas.cooksey@nokia.com>2009-12-30 12:21:35 (GMT)
commit1f1b37e613a930cc1ab871f5d11bf9742920c7f9 (patch)
tree432356825b85eba0c8a6b93cc4925dc2401b9021 /src/opengl/qgl.cpp
parent4bc5082073ef64f5e1cf120eb5190ca0f5dad268 (diff)
downloadQt-1f1b37e613a930cc1ab871f5d11bf9742920c7f9.zip
Qt-1f1b37e613a930cc1ab871f5d11bf9742920c7f9.tar.gz
Qt-1f1b37e613a930cc1ab871f5d11bf9742920c7f9.tar.bz2
Track which vertex attrib arrays are enabled in QGLContextPrivate
The GL2 engine (and probably Qt/3D) needs to track which vertex attribute arrays are currently enabled and which are disabled. As this is per-context state, the logical place to track this is in the context and not in the paint engine. This patch also makes the GL2 engine's shader manager enable/disable the appropriate attribute arrays for a given shader program when it is used. Reviewed-By: Kim
Diffstat (limited to 'src/opengl/qgl.cpp')
-rw-r--r--src/opengl/qgl.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index 466e851..5bb62f7 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -1484,6 +1484,8 @@ void QGLContextPrivate::init(QPaintDevice *dev, const QGLFormat &format)
current_fbo = 0;
default_fbo = 0;
active_engine = 0;
+ for (int i = 0; i < QT_GL_VERTEX_ARRAY_TRACKED_COUNT; ++i)
+ vertexAttributeArraysEnabledState[i] = false;
}
QGLContext* QGLContext::currentCtx = 0;
@@ -1874,6 +1876,35 @@ void QGLContextPrivate::cleanup()
{
}
+#define ctx q_ptr
+void QGLContextPrivate::setVertexAttribArrayEnabled(int arrayIndex, bool enabled)
+{
+ Q_ASSERT(arrayIndex < QT_GL_VERTEX_ARRAY_TRACKED_COUNT);
+ Q_ASSERT(glEnableVertexAttribArray);
+
+ if (vertexAttributeArraysEnabledState[arrayIndex] && !enabled)
+ glDisableVertexAttribArray(arrayIndex);
+
+ if (!vertexAttributeArraysEnabledState[arrayIndex] && enabled)
+ glEnableVertexAttribArray(arrayIndex);
+
+ vertexAttributeArraysEnabledState[arrayIndex] = enabled;
+}
+
+void QGLContextPrivate::syncGlState()
+{
+ Q_ASSERT(glEnableVertexAttribArray);
+ for (int i = 0; i < QT_GL_VERTEX_ARRAY_TRACKED_COUNT; ++i) {
+ if (vertexAttributeArraysEnabledState[i])
+ glEnableVertexAttribArray(i);
+ else
+ glDisableVertexAttribArray(i);
+ }
+
+}
+#undef ctx
+
+
/*!
\overload