FBO¶
-
demosys.opengl.
FBO
¶ A framebuffer object is a collection of buffers that can be used as the destination for rendering. The buffers for framebuffer objects reference images from either textures.
A typical FBO has one or multiple color layers and a depth. Shaders can write to these buffers when activated.
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
Methods¶
-
FBO.
use
(stack=True)¶ Bind FBO adding it to the stack. Optionally a context manager can be used:
optonally a context manager can be used:
with fbo: # draw stuff
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
-
FBO.
read_into
(buffer, viewport=None, components=3, attachment=0, alignment=1, dtype='f1', write_offset=0)¶ Read the content of the framebuffer into a buffer.
Parameters: - buffer – (bytearray) The buffer that will receive the pixels.
- viewport – (tuple) The viewport.
- components – (int) The number of components to read.
- attachment – (int) The color attachment.
- alignment – (int) The byte alignment of the pixels.
- dtype – (str) Data type.
- write_offset – (int) The write offset.
Attributes¶
-
FBO.
size
¶ (w, h) tuple representing the size in pixels
-
FBO.
samples
¶ int: The samples of the framebuffer.
-
FBO.
viewport
¶ tuple: The viewport of the framebuffer.
-
FBO.
color_mask
¶ tuple[bool, bool, bool, bool]: The color mask of the framebuffer.
-
FBO.
depth_mask
¶ bool: The depth mask of the framebuffer.
-
FBO.
mglo
¶ Internal ModernGL fbo