summaryrefslogtreecommitdiffstats
path: root/src/datavisualization/engine/abstract3drenderer.cpp
diff options
context:
space:
mode:
authorTomi Korpipää <tomi.korpipaa@digia.com>2014-06-18 06:44:42 +0300
committerTomi Korpipää <tomi.korpipaa@digia.com>2014-06-24 08:05:45 +0300
commit52d5ff5dc54c40925f3ec2eecc8573cb5e69d830 (patch)
treecd20f84df234a68ed2086765d65d99a4b98b77f0 /src/datavisualization/engine/abstract3drenderer.cpp
parent9b50f3f7d49f57712517d1d05de69ec7495c13f9 (diff)
Bars: Moved bar, background and grid line drawing to separate methods
+ Added floor reflection support in ifdefs Change-Id: I1060aee1bc8f7a0360ad01675c36c0f1a2120f1c Reviewed-by: Miikka Heikkinen <miikka.heikkinen@digia.com>
Diffstat (limited to 'src/datavisualization/engine/abstract3drenderer.cpp')
-rw-r--r--src/datavisualization/engine/abstract3drenderer.cpp42
1 files changed, 38 insertions, 4 deletions
diff --git a/src/datavisualization/engine/abstract3drenderer.cpp b/src/datavisualization/engine/abstract3drenderer.cpp
index 04ede782..132a0514 100644
--- a/src/datavisualization/engine/abstract3drenderer.cpp
+++ b/src/datavisualization/engine/abstract3drenderer.cpp
@@ -137,7 +137,7 @@ void Abstract3DRenderer::render(const GLuint defaultFboHandle)
glEnable(GL_SCISSOR_TEST);
QVector4D clearColor = Utils::vectorFromColor(m_cachedTheme->windowColor());
glClearColor(clearColor.x(), clearColor.y(), clearColor.z(), 1.0f);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
glDisable(GL_SCISSOR_TEST);
}
@@ -983,6 +983,16 @@ void Abstract3DRenderer::updateCustomItemPositions()
}
}
+#ifdef USE_REFLECTIONS
+void Abstract3DRenderer::drawCustomItems(RenderingState state,
+ ShaderHelper *shader,
+ const QMatrix4x4 &viewMatrix,
+ const QMatrix4x4 &projectionViewMatrix,
+ const QMatrix4x4 &depthProjectionViewMatrix,
+ GLuint depthTexture,
+ GLfloat shadowQuality,
+ GLfloat reflection)
+#else
void Abstract3DRenderer::drawCustomItems(RenderingState state,
ShaderHelper *shader,
const QMatrix4x4 &viewMatrix,
@@ -990,6 +1000,7 @@ void Abstract3DRenderer::drawCustomItems(RenderingState state,
const QMatrix4x4 &depthProjectionViewMatrix,
GLuint depthTexture,
GLfloat shadowQuality)
+#endif
{
if (m_customRenderCache.isEmpty())
return;
@@ -1001,8 +1012,6 @@ void Abstract3DRenderer::drawCustomItems(RenderingState state,
shader->setUniformValue(shader->lightColor(),
Utils::vectorFromColor(m_cachedTheme->lightColor()));
shader->setUniformValue(shader->view(), viewMatrix);
-
- glEnable(GL_TEXTURE_2D);
}
// Draw custom items
@@ -1035,10 +1044,36 @@ void Abstract3DRenderer::drawCustomItems(RenderingState state,
* QQuaternion::fromAxisAndAngle(1.0f, 0.0f, 0.0f, -camRotationY);
}
+#ifdef USE_REFLECTIONS
+ if (reflection < 0.0f) {
+ if (item->itemPointer()->d_ptr->m_isLabelItem)
+ continue;
+ else
+ glCullFace(GL_FRONT);
+ } else {
+ glCullFace(GL_BACK);
+ }
+ QVector3D trans = item->translation();
+ trans.setY(reflection * trans.y());
+ modelMatrix.translate(trans);
+ if (reflection < 0.0f) {
+ QQuaternion mirror = QQuaternion(rotation.scalar(),
+ -rotation.x(), rotation.y(), -rotation.z());
+ modelMatrix.rotate(mirror);
+ itModelMatrix.rotate(mirror);
+ } else {
+ modelMatrix.rotate(rotation);
+ itModelMatrix.rotate(rotation);
+ }
+ QVector3D scale = item->scaling();
+ scale.setY(reflection * scale.y());
+ modelMatrix.scale(scale);
+#else
modelMatrix.translate(item->translation());
modelMatrix.rotate(rotation);
modelMatrix.scale(item->scaling());
itModelMatrix.rotate(rotation);
+#endif
if (!item->isFacingCamera())
itModelMatrix.scale(item->scaling());
MVPMatrix = projectionViewMatrix * modelMatrix;
@@ -1091,7 +1126,6 @@ void Abstract3DRenderer::drawCustomItems(RenderingState state,
}
if (RenderingNormal == state) {
- glDisable(GL_TEXTURE_2D);
glDisable(GL_BLEND);
glEnable(GL_CULL_FACE);
}