From 824cf363f6ab999d2fc38ebdab1f7faae5559ad0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomi=20Korpip=C3=A4=C3=A4?= Date: Wed, 14 May 2014 11:19:28 +0300 Subject: Added option to use orthographic projection Task-number: QTRD-3078 Change-Id: I07ebc2b7edd542cd28e405dfc80282f18b7a7314 Reviewed-by: Mika Salmela Reviewed-by: Miikka Heikkinen --- src/datavisualization/engine/bars3drenderer.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'src/datavisualization/engine/bars3drenderer.cpp') diff --git a/src/datavisualization/engine/bars3drenderer.cpp b/src/datavisualization/engine/bars3drenderer.cpp index 661c3f3e..459f8c25 100644 --- a/src/datavisualization/engine/bars3drenderer.cpp +++ b/src/datavisualization/engine/bars3drenderer.cpp @@ -445,8 +445,16 @@ void Bars3DRenderer::drawSlicedScene() // Set up projection matrix QMatrix4x4 projectionMatrix; - projectionMatrix.perspective(35.0f, (GLfloat)m_secondarySubViewport.width() - / (GLfloat)m_secondarySubViewport.height(), 0.1f, 100.0f); + GLfloat viewPortRatio = (GLfloat)m_primarySubViewport.width() + / (GLfloat)m_primarySubViewport.height(); + if (m_useOrthoProjection) { + GLfloat orthoRatio = 2.0f / m_autoScaleAdjustment; + projectionMatrix.ortho(-viewPortRatio * orthoRatio, viewPortRatio * orthoRatio, + -orthoRatio, orthoRatio, + 0.0f, 100.0f); + } else { + projectionMatrix.perspective(35.0f, viewPortRatio, 0.1f, 100.0f); + } // Set view matrix QMatrix4x4 viewMatrix; @@ -923,7 +931,14 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle) QMatrix4x4 projectionMatrix; GLfloat viewPortRatio = (GLfloat)m_primarySubViewport.width() / (GLfloat)m_primarySubViewport.height(); - projectionMatrix.perspective(45.0f, viewPortRatio, 0.1f, 100.0f); + if (m_useOrthoProjection) { + GLfloat orthoRatio = 2.0f; + projectionMatrix.ortho(-viewPortRatio * orthoRatio, viewPortRatio * orthoRatio, + -orthoRatio, orthoRatio, + 0.0f, 100.0f); + } else { + projectionMatrix.perspective(45.0f, viewPortRatio, 0.1f, 100.0f); + } // Get the view matrix QMatrix4x4 viewMatrix = activeCamera->d_ptr->viewMatrix(); -- cgit v1.2.3