How to draw into FBO and transfer to the default frame buffer?

I’m exercising the scenario of FBO to default frame buffer transferring , the outline is as follow

  1. gen a FBO
  2. bind it to GL_FRAMEBUFFER
  4. draw something
  5. bind default frame buffer to GL_DRAW_FRAMEBUFFER (while keep FBO bound to GL_READ_FRAMEBUFFER)
  6. call glBlitFramebuffer

got nothing rendered on the screen. What I’ve missed? Many thanks!

You don’t “render to an FBO”; you render to the images you have attached to the FBO. An FBO without attached images… doesn’t contain anything.

The default width/height settings allow you to force an empty FBO to have a hypothetical size. This allows the rasterizer to work, but… there are still no attached images. So rendering doesn’t “render” anything. This feature exists to essentially allow you to use side-effects of rasterization like executing fragment shaders without having to attach an image that you don’t intend to write to. This is hypothetically useful, as shaders can write to SSBOs or images via image load/store.

But an empty FBO is empty; if it contains no images, rendering operations to it will result in nothing being written to the images that aren’t attached to it.

If you want to do what you’re trying to do, you need to create a texture (or renderbuffer, but best to just use a texture nowadays) of the appropriate size and format, and attach that to the FBO. And if you need depth testing or stencil work, you’ll have to create additional textures with the appropriate formats.

1 Like

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.