diff --git a/graphics.cc b/graphics.cc index c4fc5a2..d90c834 100644 --- a/graphics.cc +++ b/graphics.cc @@ -118,8 +118,7 @@ void Graphics::render(double time) printf("Framebuffer incomplete, unknown error occured during shadow generation!\n"); } if (saveDepthBufferBool && i_face == 3) { - printf("Doing stuff...\n"); - saveDepthBufferToDisk(framebuffer_cube, "face2.png"); + saveDepthBufferToDisk(3, "face.png"); saveDepthBufferBool = false; } } @@ -248,12 +247,12 @@ float Graphics::getFarPlane() { return farPlane; } -void Graphics::saveDepthBufferToDisk(SharedFrameBufferObject fbo, std::string filename) { +void Graphics::saveDepthBufferToDisk(int face, std::string filename) { printf("Starting saving of depth buffer...\n"); float *depthbuffer = new float[1024*1024]; std::vector image (1024 * 1024 * 4); - glGetTexImage(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_DEPTH_COMPONENT, GL_FLOAT, depthbuffer); + glGetTexImage(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, 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; diff --git a/graphics.hh b/graphics.hh index c0ceabb..270ecbd 100644 --- a/graphics.hh +++ b/graphics.hh @@ -22,7 +22,7 @@ class Graphics { private: bool saveDepthBufferBool; void updateLights(); - void saveDepthBufferToDisk(ACGL::OpenGL::SharedFrameBufferObject fbo, std::string); + void saveDepthBufferToDisk(int face, std::string); double lastUpdate; glm::uvec2 windowSize; float nearPlane;