From bb2ee12b861ba56682059f3c11e30b90c9f08e80 Mon Sep 17 00:00:00 2001 From: Michel Breyer Date: Fri, 17 Nov 2017 14:59:24 +0100 Subject: [PATCH] Initialize TinyRenderer's depth buffer properly. --- examples/SharedMemory/TinyRendererVisualShapeConverter.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/SharedMemory/TinyRendererVisualShapeConverter.cpp b/examples/SharedMemory/TinyRendererVisualShapeConverter.cpp index b237e412c..31c0ff6d0 100644 --- a/examples/SharedMemory/TinyRendererVisualShapeConverter.cpp +++ b/examples/SharedMemory/TinyRendererVisualShapeConverter.cpp @@ -772,12 +772,13 @@ void TinyRendererVisualShapeConverter::resetCamera(float camDist, float yaw, flo void TinyRendererVisualShapeConverter::clearBuffers(TGAColor& clearColor) { + float farPlane = m_data->m_camera.getCameraFrustumFar(); for(int y=0;ym_swHeight;++y) { for(int x=0;xm_swWidth;++x) { m_data->m_rgbColorBuffer.set(x,y,clearColor); - m_data->m_depthBuffer[x+y*m_data->m_swWidth] = -1e30f; + m_data->m_depthBuffer[x+y*m_data->m_swWidth] = -farPlane; m_data->m_shadowBuffer[x+y*m_data->m_swWidth] = -1e30f; m_data->m_segmentationMaskBuffer[x+y*m_data->m_swWidth] = -1; } @@ -806,13 +807,13 @@ void TinyRendererVisualShapeConverter::render(const float viewMat[16], const flo clearColor.bgra[2] = 255; clearColor.bgra[3] = 255; - clearBuffers(clearColor); float near = projMat[14]/(projMat[10]-1); float far = projMat[14]/(projMat[10]+1); m_data->m_camera.setCameraFrustumNear( near); m_data->m_camera.setCameraFrustumFar(far); - + + clearBuffers(clearColor); ATTRIBUTE_ALIGNED16(btScalar modelMat[16]);