From 2466dc155d5796705829b20ad249aa10295e4639 Mon Sep 17 00:00:00 2001 From: Mat Kelcey Date: Tue, 12 Jul 2016 13:46:48 -0700 Subject: [PATCH] fix for vertically flipped depth buffer in TinyRendererVisualShapeConverter::render --- .../TinyRendererVisualShapeConverter.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/examples/SharedMemory/TinyRendererVisualShapeConverter.cpp b/examples/SharedMemory/TinyRendererVisualShapeConverter.cpp index a4ceb2d45..92bca7498 100644 --- a/examples/SharedMemory/TinyRendererVisualShapeConverter.cpp +++ b/examples/SharedMemory/TinyRendererVisualShapeConverter.cpp @@ -624,6 +624,19 @@ void TinyRendererVisualShapeConverter::render(const float viewMat[16], const flo // printf("flipped!\n"); m_data->m_rgbColorBuffer.flip_vertically(); + //flip z-buffer + { + int half = m_data->m_swHeight>>1; + for (int j=0; jm_swWidth; + unsigned long l2 = (m_data->m_swHeight-1-j)*m_data->m_swWidth; + for (int i=0;im_swWidth;i++) + { + btSwap(m_data->m_depthBuffer[l1+i],m_data->m_depthBuffer[l2+i]); + } + } + } } void TinyRendererVisualShapeConverter::getWidthAndHeight(int& width, int& height)