fix for vertically flipped depth buffer in TinyRendererVisualShapeConverter::render

This commit is contained in:
Mat Kelcey 2016-07-12 13:46:48 -07:00
parent e918e5a44e
commit 2466dc155d

View File

@ -624,6 +624,19 @@ void TinyRendererVisualShapeConverter::render(const float viewMat[16], const flo
// printf("flipped!\n"); // printf("flipped!\n");
m_data->m_rgbColorBuffer.flip_vertically(); 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) void TinyRendererVisualShapeConverter::getWidthAndHeight(int& width, int& height)