From f9de7efe60f0e6fdec25bb1b59ee59f8ce757490 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Fri, 22 Aug 2014 18:41:29 +0200 Subject: [PATCH] QOpenGLTextureBlitter: Do not call vao functions if it failed to create MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Follow the good practice of checking for isCreated() before calling VAO functions like bind(). Use also the vao binder where applicable. Change-Id: Ib827f3bce838396bf2e08f9480fa63801d4d3a50 Reviewed-by: Jørgen Lind --- src/gui/opengl/qopengltextureblitter.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/gui/opengl/qopengltextureblitter.cpp b/src/gui/opengl/qopengltextureblitter.cpp index ef548188c8..ebe0429290 100644 --- a/src/gui/opengl/qopengltextureblitter.cpp +++ b/src/gui/opengl/qopengltextureblitter.cpp @@ -248,9 +248,6 @@ bool QOpenGLTextureBlitter::create() Q_D(QOpenGLTextureBlitter); - d->vao->create(); - d->vao->bind(); - if (d->program) return true; @@ -273,6 +270,9 @@ bool QOpenGLTextureBlitter::create() d->program->bind(); + // Create and bind the VAO, if supported. + QOpenGLVertexArrayObject::Binder vaoBinder(d->vao.data()); + d->vertexBuffer.create(); d->vertexBuffer.bind(); d->vertexBuffer.allocate(vertex_buffer_data, sizeof(vertex_buffer_data)); @@ -292,8 +292,6 @@ bool QOpenGLTextureBlitter::create() d->program->setUniformValue(d->swizzleUniformPos,false); - d->vao->release(); - return true; } @@ -316,7 +314,8 @@ void QOpenGLTextureBlitter::bind() { Q_D(QOpenGLTextureBlitter); - d->vao->bind(); + if (d->vao->isCreated()) + d->vao->bind(); d->program->bind(); @@ -335,7 +334,8 @@ void QOpenGLTextureBlitter::release() { Q_D(QOpenGLTextureBlitter); d->program->release(); - d->vao->release(); + if (d->vao->isCreated()) + d->vao->release(); } void QOpenGLTextureBlitter::setSwizzleRB(bool swizzle)