diff options
author | Tomi Korpipää <tomi.korpipaa@digia.com> | 2013-06-19 08:37:09 +0300 |
---|---|---|
committer | Tomi Korpipää <tomi.korpipaa@digia.com> | 2013-06-19 08:47:46 +0300 |
commit | 4cf975ad3e8f2bb6785029ffdae1b41841707692 (patch) | |
tree | b4e40ab1203c3316b74e6653b5138a91d7f07720 | |
parent | 3f5ef027cbe49006ff34024226748ee6a5085c34 (diff) |
QML2 shadows fixed again
Hack solution, may cause trouble later on. Should try to find a better
way to fix this.
Change-Id: I440252419a451fd26932c6d851f95259a5c60e24
Change-Id: I440252419a451fd26932c6d851f95259a5c60e24
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@digia.com>
Reviewed-by: Pasi Keränen <pasi.keranen@digia.com>
-rw-r--r-- | examples/qmlbarchart/qml/qmlbarchart/main.qml | 33 | ||||
-rw-r--r-- | src/datavis3d/engine/bars3dcontroller.cpp | 22 | ||||
-rw-r--r-- | src/datavis3d/engine/drawer.cpp | 8 | ||||
-rw-r--r-- | src/datavis3dqml2/declarativebars.cpp | 7 |
4 files changed, 47 insertions, 23 deletions
diff --git a/examples/qmlbarchart/qml/qmlbarchart/main.qml b/examples/qmlbarchart/qml/qmlbarchart/main.qml index ff6721f2..9c19aeb7 100644 --- a/examples/qmlbarchart/qml/qmlbarchart/main.qml +++ b/examples/qmlbarchart/qml/qmlbarchart/main.qml @@ -32,8 +32,8 @@ Item { Item { id: dataView - width: 480 - height: 480 + width: parent.width - shadowToggle.width + height: parent.height anchors.right: parent.right; DataItem { id: testitem1 @@ -65,10 +65,27 @@ Item { label: "Test6" value: 1 } + DataItem { + id: testitem7 + label: "Test7" + value: 3 + } + DataItem { + id: testitem8 + label: "Test8" + value: -2 + } DataRow { id: testrow1 } + DataRow { + id: testrow2 + } + + DataSet { + id: testset1 + } // ListModel { // id: testdata1 @@ -100,11 +117,15 @@ Item { testrow1.addItem(testitem2); testrow1.addItem(testitem3); testrow1.addItem(testitem4); - testrow1.addItem(testitem5); - testrow1.addItem(testitem6); + testrow2.addItem(testitem5); + testrow2.addItem(testitem6); + testrow2.addItem(testitem7); + testrow2.addItem(testitem8); + testset1.addRow(testrow1); + testset1.addRow(testrow2) - testchart.setupSampleSpace(6, 1); - testchart.addDataRow(testrow1); + testchart.setupSampleSpace(4, 2); + testchart.addDataSet(testset1); } Rectangle { diff --git a/src/datavis3d/engine/bars3dcontroller.cpp b/src/datavis3d/engine/bars3dcontroller.cpp index 0ca79350..07bec2ea 100644 --- a/src/datavis3d/engine/bars3dcontroller.cpp +++ b/src/datavis3d/engine/bars3dcontroller.cpp @@ -206,8 +206,6 @@ void Bars3dController::initializeOpenGL() } initBackgroundShaders(QStringLiteral(":/shaders/vertexShadow"), QStringLiteral(":/shaders/fragmentShadowNoTex")); - // Init the depth buffer (for shadows) - updateDepthBuffer(); } else { if (!m_theme->m_uniformColor) { initShaders(QStringLiteral(":/shaders/vertex"), @@ -882,12 +880,12 @@ void Bars3dController::drawScene(const GLuint defaultFboHandle) #endif } - // Bind bar shader - m_barShader->bind(); - // Enable texturing glEnable(GL_TEXTURE_2D); + // Bind bar shader + m_barShader->bind(); + // Draw bars if (!m_zoomActivated && m_zoomSelection) m_zoomSelection->d_ptr->clear(); @@ -1118,12 +1116,12 @@ void Bars3dController::drawScene(const GLuint defaultFboHandle) } } - // Disable textures - glDisable(GL_TEXTURE_2D); - // Release background shader m_backgroundShader->release(); + // Disable textures + glDisable(GL_TEXTURE_2D); + // Reset culling if (m_negativeValues) { glEnable(GL_CULL_FACE); @@ -1993,8 +1991,6 @@ void Bars3dController::setShadowQuality(ShadowQuality quality) } initBackgroundShaders(QStringLiteral(":/shaders/vertexShadow"), QStringLiteral(":/shaders/fragmentShadowNoTex")); - // Re-init depth buffer - updateDepthBuffer(); } else { // Re-init shaders if (!m_theme->m_uniformColor) { @@ -2006,9 +2002,9 @@ void Bars3dController::setShadowQuality(ShadowQuality quality) } initBackgroundShaders(QStringLiteral(":/shaders/vertex"), QStringLiteral(":/shaders/fragment")); - // Re-init depth buffer - updateDepthBuffer(); } + // Re-init depth buffer + updateDepthBuffer(); #else if (!m_theme->m_uniformColor) { initShaders(QStringLiteral(":/shaders/vertexES2"), @@ -2321,8 +2317,6 @@ void Bars3dController::updateDepthBuffer() m_depthFrameBuffer, m_shadowQuality); } - - qDebug() << "updateDepthBuffer() EXIT m_depthFrameBuffer = " << m_depthFrameBuffer << ", m_depthTexture = " << m_depthTexture; } #endif diff --git a/src/datavis3d/engine/drawer.cpp b/src/datavis3d/engine/drawer.cpp index ab815f4a..5d062f68 100644 --- a/src/datavis3d/engine/drawer.cpp +++ b/src/datavis3d/engine/drawer.cpp @@ -112,7 +112,13 @@ void Drawer::drawObject(ShaderHelper *shader, ObjectHelper *object, GLuint textu shader->setUniformValue(shader->texture(), 0); } - if (depthTextureId) { + if (depthTextureId && !textureId) { + // TODO: This is a HACK for QML2 integration. Find a way to make it work without this. + // Activate depth texture + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, depthTextureId); + shader->setUniformValue(shader->shadow(), 0); + } else if (depthTextureId) { // Activate depth texture glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, depthTextureId); diff --git a/src/datavis3dqml2/declarativebars.cpp b/src/datavis3dqml2/declarativebars.cpp index 9950f4fe..19fd8ee7 100644 --- a/src/datavis3dqml2/declarativebars.cpp +++ b/src/datavis3dqml2/declarativebars.cpp @@ -395,7 +395,7 @@ void DeclarativeBarsRenderer::render() // Create FBO if (!m_fbo) { QOpenGLFramebufferObjectFormat format; - format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil); + format.setAttachment(QOpenGLFramebufferObject::Depth); m_fbo = new QOpenGLFramebufferObject(size, format); m_texture = m_window->createTextureFromId(m_fbo->texture(), size); @@ -412,12 +412,15 @@ void DeclarativeBarsRenderer::render() QSGGeometry::updateTexturedRectGeometry(geometry, rect(), m_texture->convertToNormalizedSourceRect(sourceRect)); markDirty(DirtyMaterial); + //qDebug() << "create node" << m_fbo->handle() << m_texture->textureId() << m_fbo->size(); } // Call the shared rendering function m_fbo->bind(); + m_barsRenderer->render(m_fbo->handle()); - m_fbo->bindDefault(); + + m_fbo->release(); // New view is in the FBO, request repaint of scene graph m_window->update(); |