Question

Brad Larson provides some great code here and here for 'rendering your scene into a texture-backed framebuffer', but it's not clear whether this is the same framebuffer that I use for the rest of the drawing.

If you attach a renderbuffer to a framebuffer, can the framebuffer also render into a texture with the same call?

Was it helpful?

Solution

Sounds like you might be a bit confused with FBO usage. If you need it, this should get you started: Apple Developer - Drawing offscreen. This could help too.

Renderbuffer is something you can bind to an FBO (framebuffer object). FBO is something you create when you don't want your rendering to be displayed immediately, but want to read the rendering result back or perform additional rendering to it. The way FBOs work in OpenGL ES 2.0, you have only one color attachment point available (GL_COLOR_ATTACHMENT0 - your fragment shader output variable gl_FragColor is connected to this attachment point), and it can only have one texture or renderbuffer attached to it. So to answer that last question, you cannot have an FBO that would simultaneously write color to a renderbuffer and a texture.

As for the first part of your question, it depends whether you are already using an FBO or the default framebuffer. Chances are the behavior you're looking for is something like this:

  1. bind an FBO
  2. render something to a texture attached to the FBO
  3. bind the default framebuffer
  4. use the texture from step 2 to affect rendering in your second renderpass.

Hope this answers your question even a little bit.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top