FBO

Framebuffer Object for off-screen rendering

Create

static FBO.create(size, components=4, depth=False, dtype='f1', layers=1) → FBO

Create a single or multi layer FBO

Parameters:
  • size – (tuple) with and height
  • components – (tuple) number of components. 1, 2, 3, 4
  • depth – (bool) Create a depth attachment
  • dtype – (string) data type per r, g, b, a …
  • layers – (int) number of color attachments
Returns:

A new FBO

static FBO.create_from_textures(color_buffers:List[Texture2D], depth_buffer:DepthTexture=None) → FBO

Create FBO from existing textures

Parameters:
  • color_buffers – List of textures
  • depth_buffer – Depth texture
Returns:

FBO instance

Methods

FBO.use(stack=True)

Bind FBO adding it to the stack.

Parameters:stack – (bool) If the bind should push the current FBO on the stack.
FBO.release(stack=True)

Bind FBO popping it from the stack

Parameters:stack – (bool) If the bind should be popped form the FBO stack.
FBO.clear(red=0.0, green=0.0, blue=0.0, alpha=0.0, depth=1.0)

Clears all FBO layers including depth

FBO.draw_color_layer(layer=0, pos=(0.0, 0.0), scale=(1.0, 1.0))

Draw a color layer in the FBO.

Parameters:
  • layer – Layer ID
  • pos – (tuple) offset x, y
  • scale – (tuple) scale x, y
FBO.draw_depth(near, far, pos=(0.0, 0.0), scale=(1.0, 1.0))

Draw a depth buffer in the FBO.

Parameters:
  • near – projection near.
  • far – projection far.
  • pos – (tuple) offset x, y
  • scale – (tuple) scale x, y
FBO.read(viewport=None, components=3, attachment=0, alignment=1, dtype='f1') → bytes

Read the content of the framebuffer.

Parameters:
  • viewport – (tuple) The viewport
  • components – The number of components to read.
  • attachment – The color attachment
  • alignment – The byte alignment of the pixels
  • dtype – (str) dtype

Attributes

FBO.size

Attempts to determine the pixel size of the FBO. Currently returns the size of the first color attachment. If the FBO has no color attachments, the depth attachment will be used. Raises FBOError if the size cannot be determined.

Returns:(w, h) tuple representing the size in pixels
FBO.mglo

Internal ModernGL fbo