Opengl-Framebuffer

A color buffer for writing color values, a depth buffer to write and test depth information, and finally a stencil buffer that allows us to discard certain fragments based on some condition. The combination of these buffers is stored somewhere in GPU memory and is called a framebuffer.

In the tutorial, Framebuffer is actually a texture. We use this framebuffer-texture as a normal texture and render it on the defalt buffer

When attaching a texture to a framebuffer, all rendering commands will write to the texture as if it was a normal color/depth or stencil buffer which means the created NULL texture is a canvas, and opengl draw on this canvas。this drawed canvas can be a new texture.

So, to draw the scene to a single texture we'll have to take the following steps:

  1. Render the scene as usual with the new framebuffer bound as the active framebuffer.
  2. Bind to the default framebuffer.
  3. Draw a quad that spans the entire screen with the new framebuffer's color buffer as its texture.

Reference
https://learnopengl.com/Advanced-OpenGL/Framebuffers

posted @ 2023-03-07 16:30  一个AI的修养  阅读(35)  评论(0)    收藏  举报