I am experimenting with off-screen rendering. I understand there is two solutions to this:
- rendering to texture (you attach a texture to one of the FBO's attachment point which can be a color, depth, etc.)
- use a render buffer.
I first experimented with using render-buffers. I have a FBO and 2 RBOs, one for color (attached to COLOR0) and one for depth (attached to DEPTH). When I want to visualise the content of what I rendered to the render buffer, I use the
glBlitFramebuffer function to copy the content from the FBO to the Window frame buffer (index 0).
glBindFramebuffer(GL_READ_FRAMEBUFFER, fboId); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); glBlitFramebuffer(0, 0, width, height, 0, 0, width, height, GL_COLOR_BUFFER_BIT, GL_LINEAR);
First I would like to know if this the best way? (of passing the image from the a render buffer back to the window buffer).
My second question. The method I described above works but I can only see the "color" buffer of the FBO, not the depth buffer (I would also like to visualise the depth buffer). So I was wondering how/if this was possible using this approach? I tried to use the index of the depth render buffer in place of the
glBindFramebuffer but it didn't change anything. Can I make it work without using render-to-texture approach?
My end goal is to render two images using an off-screen approach and blend them together. The result of the mix between the two rendered images is what I want to display to the screen. To keep things fast, I understand this can be done in hardware. What's the best way for doing this? Can it be done using the render-buffer approach or do I need to go the render-to-texture approach (aka render to two textures and then blend these textures using a fragment shader when I do my final pass in which I render a quad stretched over the surface of the screen?