Fixed saving of depthbuffer.
This commit is contained in:
parent
211530fe09
commit
a38f251a3e
@ -66,7 +66,7 @@
|
||||
</object>
|
||||
<light>
|
||||
<xOffset>0.0</xOffset>
|
||||
<yOffset>3</yOffset>
|
||||
<yOffset>2</yOffset>
|
||||
<zOffset>0.0</zOffset>
|
||||
<rColour>1.0</rColour>
|
||||
<gColour>1.0</gColour>
|
||||
|
@ -354,7 +354,7 @@ public:
|
||||
|
||||
btAssert(m_useQuantization);
|
||||
|
||||
btAssert(point.getX() <= m_bvhAabbMax.getX());
|
||||
//btAssert(point.getX() <= m_bvhAabbMax.getX());
|
||||
btAssert(point.getY() <= m_bvhAabbMax.getY());
|
||||
btAssert(point.getZ() <= m_bvhAabbMax.getZ());
|
||||
|
||||
|
20
graphics.cc
20
graphics.cc
@ -117,7 +117,7 @@ void Graphics::render(double time)
|
||||
if (!framebuffer_cube->isFrameBufferObjectComplete()) {
|
||||
printf("Framebuffer incomplete, unknown error occured during shadow generation!\n");
|
||||
}
|
||||
if (saveDepthBufferBool && i_face == 2) {
|
||||
if (saveDepthBufferBool && i_face == 3) {
|
||||
printf("Doing stuff...\n");
|
||||
saveDepthBufferToDisk(framebuffer_cube, "face2.png");
|
||||
saveDepthBufferBool = false;
|
||||
@ -250,17 +250,17 @@ float Graphics::getFarPlane() {
|
||||
|
||||
void Graphics::saveDepthBufferToDisk(SharedFrameBufferObject fbo, std::string filename) {
|
||||
printf("Starting saving of depth buffer...\n");
|
||||
float *depthbuffer = new float[windowSize.x * windowSize.y];
|
||||
std::vector<unsigned char> image (windowSize.x * windowSize.y * 4);
|
||||
float *depthbuffer = new float[1024*1024];
|
||||
std::vector<unsigned char> image (1024 * 1024 * 4);
|
||||
|
||||
glGetTexImage(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_DEPTH_COMPONENT, GL_FLOAT, depthbuffer);
|
||||
for (unsigned int i = 0; i<windowSize.x * windowSize.y; i++) {
|
||||
image[windowSize.x * windowSize.y * 4 + 0] = depthbuffer[i] * 255;
|
||||
image[windowSize.x * windowSize.y * 4 + 1] = depthbuffer[i] * 255;
|
||||
image[windowSize.x * windowSize.y * 4 + 2] = depthbuffer[i] * 255;
|
||||
image[windowSize.x * windowSize.y * 4 + 3] = 255;
|
||||
glGetTexImage(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_DEPTH_COMPONENT, GL_FLOAT, depthbuffer);
|
||||
for (unsigned int i = 0; i<1024*1024; i++) {
|
||||
image[i * 4 + 0] = depthbuffer[i] * 255;
|
||||
image[i * 4 + 1] = depthbuffer[i] * 255;
|
||||
image[i * 4 + 2] = depthbuffer[i] * 255;
|
||||
image[i * 4 + 3] = 255;
|
||||
}
|
||||
unsigned error = lodepng::encode(filename.c_str(), image, windowSize.x, windowSize.y);
|
||||
unsigned error = lodepng::encode(filename.c_str(), image, 1024, 1024);
|
||||
if (error) {
|
||||
std::cout << "Encoder error " << error << ": " << lodepng_error_text(error) << std::endl;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user