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?
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:
- bind an FBO
- render something to a texture attached to the FBO
- bind the default framebuffer
- use the texture from step 2 to affect rendering in your second renderpass.
Hope this answers your question even a little bit.
来源:https://stackoverflow.com/questions/18318800/can-an-opengles-2-0-framebuffer-be-bound-to-a-texture-and-a-renderbuffer-at-the