Framebuffer

Framebuffer

  • A Framebuffer is a collection of buffers that can be used as the destination for rendering.
  • OpenGL has two kinds of framebuffers: the Default Framebuffer, which is provided by the OpenGL Context; and user-created framebuffers called Framebuffer Objects (FBOs).
  • The framebuffer consists of a set of pixels arranged as a two-dimensional array.
  • Corresponding bits from each pixel in the framebuffer are grouped together into a bitplane; each bitplane contains a single bit from each pixel. These bitplanes are grouped into several logical buffers.These are the color, depth, and stencil buffers.
  • For the default framebuffer, the color buffers are the front left buffer, the front right buffer, the back left buffer, and the back right buffer.
  • Framebuffer objects are not visible, and do not have any of the color buffers present in the default framebuffer. Instead, the buffers of an framebuffer object are specified by attaching individual textures or renderbuffers to a set of attachment points.
  • In order to be used for rendering, a framebuffer object must be complete.
  • The default framebuffer is initially used as the draw and read framebuffer.

Default Framebuffer

  • The GL uses the window system-provided default framebuffer.
  • For the default framebuffer, the color buffers are the front left buffer, the front right buffer, the back left buffer, and the back right buffer.
  • Typically the contents of the front buffers are displayed on a color monitor while the contents of the back buffers are invisible.
  • The buffers for default framebuffers are part of the context and usually represent a window or display device.
  • The default framebuffer can also contain an accumulation buffer, which can be used to perform certain computations when rendering.

User-Created Framebuffer(FBOs)

  • Framebuffer objects are a collection of attachments.

  • The buffers for FBOs reference images from either Textures or Renderbuffers; they are never directly visible.

  • In particular, a framebuffer object encapsulates state necessary to describe a collection of color, depth, and stencil logical buffers.

Framebuffer-attachable images

  • For each logical buffer, a framebuffer-attachable image can be attached to the framebuffer to store the rendered output for that logical buffer.
  • Examples of framebuffer-attachable images include texture images and renderbuffer images.
  • By allowing the images of a renderbuffer to be attached to a framebuffer, the GL provides a mechanism to support off-screen rendering. Further, by allowing the images of a texture to be attached to a framebuffer, the GL provides a mechanism to support render to texture.
  • There are several types of framebuffer-attachable images
    - - The image of a renderbuffer object, which is always two-dimensionalFramebuffer_第1张图片
  • Additionally, an entire level of a three-dimensional, cube map, cube map array, or one- or two-dimensional array texture can be attached to an attachment point. Such attachments are treated as an array of two-dimensional images, arranged in layers, and the corresponding attachment point is considered to be layered.
Renderbuffer image
  • A renderbuffer is a data storage object containing a single image of a renderable internal format
  • A renderbuffer object can be attached as one of the logical buffers of a framebuffer object with the commmands
void glFramebufferRenderbuffer( enum target,
enum attachment, enum renderbuffertarget,
uint renderbuffer );
void glNamedFramebufferRenderbuffer( uint framebuffer,
enum attachment, enum renderbuffertarget,
uint renderbuffer );

attachment

Framebuffer_第2张图片

texture image
  • To render directly into a texture image, a specified level of a texture object can be attached as one of the logical buffers of a framebuffer object with the commands.
void glFramebufferTexture( enum target, enum attachment,
uint texture, int level );
void glNamedFramebufferTexture( uint framebuffer,
enum attachment, uint texture, int level );

你可能感兴趣的:(GPU,OpenGL)