aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2014-07-28 21:13:13 +0200
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2014-07-31 13:57:31 +0200
commit658f279171742cc09781407c8214bce635f93b67 (patch)
tree71cc0b863782df86c83394232597212581ef2979 /src
parentf7d6e2a2a0d69cc475750cff7680f5b19346838c (diff)
QQuickWindow: fix resetOpenGLState handling of vertex arrays
In the core profile it's forbidden to set vertex attributes (via glVertexAttribPointer and similar) when there's no VAO bound. Similarly, if there's a VAO bound when calling resetOpenGLState, then we need to unbind it or those operations will affect its status. Change-Id: Id7db028ddde9f9429f5a210b8b3d1468888dbce4 Reviewed-by: Sean Harmer <sean.harmer@kdab.com> Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/quick/items/qquickwindow.cpp28
-rw-r--r--src/quick/items/qquickwindow_p.h4
2 files changed, 26 insertions, 6 deletions
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp
index f57d04dfad..0233e93443 100644
--- a/src/quick/items/qquickwindow.cpp
+++ b/src/quick/items/qquickwindow.cpp
@@ -74,6 +74,8 @@
#include <private/qqmlprofilerservice_p.h>
#include <private/qqmlmemoryprofiler_p.h>
+#include <private/qopenglvertexarrayobject_p.h>
+
QT_BEGIN_NAMESPACE
Q_LOGGING_CATEGORY(DBG_TOUCH, "qt.quick.touch");
@@ -415,6 +417,7 @@ QQuickWindowPrivate::QQuickWindowPrivate()
, lastFocusReason(Qt::OtherFocusReason)
, renderTarget(0)
, renderTargetId(0)
+ , vaoHelper(0)
, incubationController(0)
{
#ifndef QT_NO_DRAGANDDROP
@@ -2832,6 +2835,9 @@ void QQuickWindow::cleanupSceneGraph()
{
Q_D(QQuickWindow);
+ delete d->vaoHelper;
+ d->vaoHelper = 0;
+
if (!d->renderer)
return;
@@ -3517,16 +3523,26 @@ void QQuickWindow::resetOpenGLState()
if (!openglContext())
return;
- QOpenGLFunctions *gl = openglContext()->functions();
+ Q_D(QQuickWindow);
+
+ QOpenGLContext *ctx = openglContext();
+ QOpenGLFunctions *gl = ctx->functions();
gl->glBindBuffer(GL_ARRAY_BUFFER, 0);
gl->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
- int maxAttribs;
- gl->glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxAttribs);
- for (int i=0; i<maxAttribs; ++i) {
- gl->glVertexAttribPointer(i, 4, GL_FLOAT, GL_FALSE, 0, 0);
- gl->glDisableVertexAttribArray(i);
+ if (!d->vaoHelper)
+ d->vaoHelper = new QOpenGLVertexArrayObjectHelper(ctx);
+ if (d->vaoHelper->isValid())
+ d->vaoHelper->glBindVertexArray(0);
+
+ if (ctx->isOpenGLES() || (gl->openGLFeatures() & QOpenGLFunctions::FixedFunctionPipeline)) {
+ int maxAttribs;
+ gl->glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxAttribs);
+ for (int i=0; i<maxAttribs; ++i) {
+ gl->glVertexAttribPointer(i, 4, GL_FLOAT, GL_FALSE, 0, 0);
+ gl->glDisableVertexAttribArray(i);
+ }
}
gl->glActiveTexture(GL_TEXTURE0);
diff --git a/src/quick/items/qquickwindow_p.h b/src/quick/items/qquickwindow_p.h
index 66202aec5c..8f0696914e 100644
--- a/src/quick/items/qquickwindow_p.h
+++ b/src/quick/items/qquickwindow_p.h
@@ -94,6 +94,8 @@ class QTouchEvent;
class QQuickWindowRenderLoop;
class QQuickWindowIncubationController;
+class QOpenGLVertexArrayObjectHelper;
+
class Q_QUICK_PRIVATE_EXPORT QQuickWindowPrivate : public QWindowPrivate
{
public:
@@ -233,6 +235,8 @@ public:
uint renderTargetId;
QSize renderTargetSize;
+ QOpenGLVertexArrayObjectHelper *vaoHelper;
+
// Keeps track of which touch point (int) was last accepted by which item
QHash<int, QQuickItem *> itemForTouchPointId;