Can an OpenGLES 2.0 framebuffer be bound to a texture and a renderbuffer at the same time?

那年仲夏 提交于 2020-01-13 11:22:49

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/18318800/can-an-opengles-2-0-framebuffer-be-bound-to-a-texture-and-a-renderbuffer-at-the

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!