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