Merge pull request #694 from matpalm/flipDepthImage

fix for vertically flipped depth buffer in TinyRenderer::render
This commit is contained in:
erwincoumans
2016-07-13 15:56:33 -07:00
committed by GitHub

View File

@@ -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; j<half; j++)
{
unsigned long l1 = j*m_data->m_swWidth;
unsigned long l2 = (m_data->m_swHeight-1-j)*m_data->m_swWidth;
for (int i=0;i<m_data->m_swWidth;i++)
{
btSwap(m_data->m_depthBuffer[l1+i],m_data->m_depthBuffer[l2+i]);
}
}
}
}
void TinyRendererVisualShapeConverter::getWidthAndHeight(int& width, int& height)