Like I mentioned in my other topic, I’d like to copy data from a depth (render)buffer in a FBO to the main depth buffer. Since there are no other ways for me to accomplish that goal, I’m currently trying to use PBO’s to make the whole glRead/DrawPixel-stuff a bit faster.
I initialize my FBO as usual, it’s all fine. I generate a new PBO, like this:
GLuint pbo; glGenBuffers(1, &pbo); glBindBuffer(GL_ARRAY_BUFFER, pbo); glBufferData(GL_ARRAY_BUFFER, width * height * sizeof(GL_FLOAT), 0l, GL_DYNAMIC_COPY); glBindBuffer(GL_ARRAY_BUFFER, 0);
Then, at runtime, I copy the depth buffer:
// Bind FBO here // ... glReadBuffer(GL_COLOR_ATTACHMENT0); glBindBuffer(GL_PIXEL_PACK_BUFFER, pbo); glReadPixels(0, 0, width, height, GL_DEPTH_COMPONENT, GL_FLOAT, 0); glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
Then, I draw the buffered data using:
// Switching to main framebuffer // ... glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo); glDrawPixels(width, height, GL_DEPTH_COMPONENT, GL_FLOAT, 0); glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
Could someone tell me if this is the correct way to copy data around (in vram)?
It seems to work once, but when I execute the testprogram more than once, everything goes bad. Odd crashes from random libraries, not able anymore to re-start the program (immediate crash in OpenGL library), cat gets killed, etc.
This whole “copy-fbo-depth-to-main-depth”-issue is starting to drive me mad. Am I writing bad code? Is the ATI driver bad? Are aliens to blame?