Framebuffers

Context.framebuffer(color_attachments, depth_attachment=None) → Framebuffer

Create a Framebuffer.

Parameters:
  • color_attachments (list) – A list of Texture or Renderbuffer objects.
  • depth_attachment (Renderbuffer or Texture) – A Texture or Renderbuffer object.
Returns:

framebuffer

Return type:

Framebuffer

class Framebuffer

Create a Framebuffer using Context.framebuffer().

clear(red=0.0, green=0.0, blue=0.0, alpha=0.0, viewport=None)

Clear the framebuffer.

Values must be in (0, 255) range. If the viewport is not None then scrissor test will be used to clear the given viewport.

If the viewport is a 2-tuple it will clear the (0, 0, width, height) where (width, height) is the 2-tuple.

If the viewport is a 4-tuple it will clear the given viewport.

Parameters:
  • red (float) – color component.
  • green (float) – color component.
  • blue (float) – color component.
  • alpha (float) – alpha component.
Keyword Arguments:
 

viewport (tuple) – The viewport.

use()

Bind the framebuffer. Set the target for the VertexArray.render or VertexArray.transform methods.

read(viewport=None, components=3, attachment=0, alignment=1, floats=False) → bytes

Read the framebuffer content.

read_into(buffer, viewport=None, components=3, attachment=0, alignment=1, floats=False)

Read the framebuffer content.

width

int – The width of the Framebuffer.

height

int – The height of the Framebuffer.

samples

int – The samples of the Framebuffer.