summaryrefslogtreecommitdiffstats
path: root/src/datavisualization/utils
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@digia.com>2014-06-16 09:26:26 +0300
committerMiikka Heikkinen <miikka.heikkinen@digia.com>2014-06-24 08:07:21 +0300
commit03baf7bc0b3bf07625e1111fe50c5262047ee302 (patch)
treed794091f991f04ddb3e1223657e5a96067826275 /src/datavisualization/utils
parentb86c799f7758f64e781ebf97a2e660675db8168c (diff)
Added some extra checking for selection texture creation
Change-Id: Iedeaa2581c32b6d46168568fef736b234ac17e95 Reviewed-by: Tomi Korpipää <tomi.korpipaa@digia.com>
Diffstat (limited to 'src/datavisualization/utils')
-rw-r--r--src/datavisualization/utils/texturehelper.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/datavisualization/utils/texturehelper.cpp b/src/datavisualization/utils/texturehelper.cpp
index 2a2a89dd..97f9c672 100644
--- a/src/datavisualization/utils/texturehelper.cpp
+++ b/src/datavisualization/utils/texturehelper.cpp
@@ -116,11 +116,22 @@ GLuint TextureHelper::createSelectionTexture(const QSize &size, GLuint &frameBuf
if (!depthBuffer)
glGenRenderbuffers(1, &depthBuffer);
glBindRenderbuffer(GL_RENDERBUFFER, depthBuffer);
+ GLenum status = glGetError();
+ // glGetError docs advise to call glGetError in loop to clear all error flags
+ while (status)
+ status = glGetError();
#if !defined(QT_OPENGL_ES_2)
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, size.width(), size.height());
#else
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, size.width(), size.height());
#endif
+ status = glGetError();
+ if (status) {
+ qCritical() << "Selection texture render buffer creation failed:" << status;
+ glDeleteTextures(1, &textureid);
+ glBindRenderbuffer(GL_RENDERBUFFER, 0);
+ return 0;
+ }
glBindRenderbuffer(GL_RENDERBUFFER, 0);
// Create frame buffer
@@ -134,10 +145,11 @@ GLuint TextureHelper::createSelectionTexture(const QSize &size, GLuint &frameBuf
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthBuffer);
// Verify that the frame buffer is complete
- GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
+ status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
if (status != GL_FRAMEBUFFER_COMPLETE) {
- qCritical() << "Frame buffer creation failed" << status;
- return 0;
+ qCritical() << "Selection texture frame buffer creation failed:" << status;
+ glDeleteTextures(1, &textureid);
+ textureid = 0;
}
// Restore the default framebuffer
@@ -212,8 +224,9 @@ GLuint TextureHelper::createDepthTextureFrameBuffer(const QSize &size, GLuint &f
// Verify that the frame buffer is complete
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
if (status != GL_FRAMEBUFFER_COMPLETE) {
- qCritical() << "Frame buffer creation failed" << status;
- return 0;
+ qCritical() << "Depth texture frame buffer creation failed" << status;
+ glDeleteTextures(1, &depthtextureid);
+ depthtextureid = 0;
}
// Restore the default framebuffer