summaryrefslogtreecommitdiffstats
path: root/src/datavisualization/utils
diff options
context:
space:
mode:
authorMika Salmela <mika.salmela@digia.com>2013-11-15 15:21:36 +0200
committerMika Salmela <mika.salmela@digia.com>2013-11-18 08:58:06 +0200
commit3ef798f18244e468fd558f36e161aeaf15a44564 (patch)
tree8aca491ab874b4f6ecc5bdb7d44748b01e08d213 /src/datavisualization/utils
parent27241b083df419f3a2de928c1d3f5dd8f6459030 (diff)
Initialization for depth texture
Precaution for using depth texture before nothing has been drawn. Task-number: QTRD-2570 Change-Id: I47ece387542acbd1ffed8d650a70ecc471efb30e Reviewed-by: Miikka Heikkinen <miikka.heikkinen@digia.com>
Diffstat (limited to 'src/datavisualization/utils')
-rw-r--r--src/datavisualization/utils/texturehelper.cpp19
-rw-r--r--src/datavisualization/utils/texturehelper_p.h1
2 files changed, 19 insertions, 1 deletions
diff --git a/src/datavisualization/utils/texturehelper.cpp b/src/datavisualization/utils/texturehelper.cpp
index cb18fcc2..41c5b452 100644
--- a/src/datavisualization/utils/texturehelper.cpp
+++ b/src/datavisualization/utils/texturehelper.cpp
@@ -182,7 +182,7 @@ GLuint TextureHelper::createDepthTexture(const QSize &size, GLuint textureSize)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE_ARB);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, size.width() * textureSize,
- size.height() * textureSize, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, NULL);
+ size.height() * textureSize, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL);
glBindTexture(GL_TEXTURE_2D, 0);
return depthtextureid;
@@ -219,6 +219,23 @@ GLuint TextureHelper::createDepthTextureFrameBuffer(const QSize &size, GLuint &f
}
#endif
+#if !defined(QT_OPENGL_ES_2)
+void TextureHelper::fillDepthTexture(GLuint texture,const QSize &size, GLuint textureSize, GLfloat value)
+{
+ int nItems = size.width() * textureSize * size.height() * textureSize;
+ GLfloat *bits = new GLfloat[nItems];
+ for (int i = 0; i < nItems; i++)
+ bits[i] = value;
+
+ glBindTexture(GL_TEXTURE_2D, texture);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, size.width() * textureSize,
+ size.height() * textureSize, 0, GL_DEPTH_COMPONENT, GL_FLOAT, bits);
+ glBindTexture(GL_TEXTURE_2D, 0);
+
+ delete[] bits;
+}
+#endif
+
void TextureHelper::deleteTexture(const GLuint *texture)
{
glDeleteTextures(1, texture);
diff --git a/src/datavisualization/utils/texturehelper_p.h b/src/datavisualization/utils/texturehelper_p.h
index 84570a13..11022495 100644
--- a/src/datavisualization/utils/texturehelper_p.h
+++ b/src/datavisualization/utils/texturehelper_p.h
@@ -53,6 +53,7 @@ class TextureHelper : protected QOpenGLFunctions
GLuint createDepthTexture(const QSize &size, GLuint textureSize);
// Returns depth texture and inserts generated framebuffer to parameter
GLuint createDepthTextureFrameBuffer(const QSize &size, GLuint &frameBuffer, GLuint textureSize);
+ void fillDepthTexture(GLuint texture, const QSize &size, GLuint textureSize, GLfloat value);
#endif
void deleteTexture(const GLuint *texture);