From 151bc8e12c7d8cc41ecbaf8af9130e2975458780 Mon Sep 17 00:00:00 2001 From: yunfeibai Date: Tue, 7 Feb 2017 17:19:48 -0800 Subject: [PATCH] Add depth image when using hardware renderer. --- examples/ExampleBrowser/OpenGLGuiHelper.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/ExampleBrowser/OpenGLGuiHelper.cpp b/examples/ExampleBrowser/OpenGLGuiHelper.cpp index c739d2e47..87bff6e59 100644 --- a/examples/ExampleBrowser/OpenGLGuiHelper.cpp +++ b/examples/ExampleBrowser/OpenGLGuiHelper.cpp @@ -437,10 +437,15 @@ void OpenGLGuiHelper::copyCameraImageData(const float viewMatrix[16], const floa int bytesPerPixel = 4; //RGBA int sourcePixelIndex = (xIndex+yIndex*sourceWidth)*bytesPerPixel; + int sourceDepthIndex = xIndex+yIndex*sourceWidth; + m_data->m_rgbaPixelBuffer1[(i+j*destinationWidth)*4+0] = sourceRgbaPixelBuffer[sourcePixelIndex+0]; m_data->m_rgbaPixelBuffer1[(i+j*destinationWidth)*4+1] = sourceRgbaPixelBuffer[sourcePixelIndex+1]; m_data->m_rgbaPixelBuffer1[(i+j*destinationWidth)*4+2] = sourceRgbaPixelBuffer[sourcePixelIndex+2]; m_data->m_rgbaPixelBuffer1[(i+j*destinationWidth)*4+3] = 255; + + m_data->m_depthBuffer1[i+j*destinationWidth] = sourceDepthBuffer[sourceDepthIndex]; + } } } @@ -456,7 +461,7 @@ void OpenGLGuiHelper::copyCameraImageData(const float viewMatrix[16], const floa { for (int i=0;im_depthBuffer1[i]; + depthBuffer[i] = m_data->m_depthBuffer1[i+startPixelIndex]; } } if (numPixelsCopied)