Framebuffer¶
-
class
moderngl.
Framebuffer
¶ A
Framebuffer
is a collection of buffers that can be used as the destination for rendering. The buffers for Framebuffer objects reference images from either Textures or Renderbuffers.Create a
Framebuffer
usingContext.framebuffer()
.
Create¶
-
Context.
simple_framebuffer
(size, components=4, samples=0, dtype='f1') → Framebuffer A
Framebuffer
is a collection of buffers that can be used as the destination for rendering. The buffers for Framebuffer objects reference images from either Textures or Renderbuffers.Parameters: - size (tuple) – The width and height of the renderbuffer.
- components (int) – The number of components 1, 2, 3 or 4.
Keyword Arguments: - samples (int) – The number of samples. Value 0 means no multisample format.
- dtype (str) – Data type.
Returns: Framebuffer
object
-
Context.
framebuffer
(color_attachments=(), depth_attachment=None) → Framebuffer A
Framebuffer
is a collection of buffers that can be used as the destination for rendering. The buffers for Framebuffer objects reference images from either Textures or Renderbuffers.Parameters: - color_attachments (list) – A list of
Texture
orRenderbuffer
objects. - depth_attachment (Renderbuffer or Texture) – The depth attachment.
Returns: Framebuffer
object- color_attachments (list) – A list of
Methods¶
-
Framebuffer.
clear
(red=0.0, green=0.0, blue=0.0, alpha=0.0, depth=1.0, viewport=None)¶ Clear the framebuffer.
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.
- depth (float) – depth value.
Keyword Arguments: viewport (tuple) – The viewport.
-
Framebuffer.
read
(viewport=None, components=3, attachment=0, alignment=1, dtype='f1') → bytes¶ Read the content of the framebuffer.
Parameters: - viewport (tuple) – The viewport.
- components (int) – The number of components to read.
Keyword Arguments: - attachment (int) – The color attachment.
- alignment (int) – The byte alignment of the pixels.
- dtype (str) – Data type.
Returns: bytes
-
Framebuffer.
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.
Keyword Arguments: - attachment (int) – The color attachment.
- alignment (int) – The byte alignment of the pixels.
- dtype (str) – Data type.
- write_offset (int) – The write offset.
-
Framebuffer.
use
()¶ Bind the framebuffer. Set the target for the
VertexArray.render()
.
Attributes¶
-
Framebuffer.
viewport
¶ tuple – The viewport of the framebuffer.
-
Framebuffer.
color_mask
¶ tuple – The color mask of the framebuffer.
-
Framebuffer.
depth_mask
¶ tuple – The depth mask of the framebuffer.
-
Framebuffer.
width
¶ int – The width of the framebuffer.
-
Framebuffer.
height
¶ int – The height of the framebuffer.
-
Framebuffer.
size
¶ tuple – The size of the framebuffer.
-
Framebuffer.
samples
¶ int – The samples of the framebuffer.
-
Framebuffer.
bits
¶ dict – The bits of the framebuffer.
-
Framebuffer.
color_attachments
¶ tuple – The color attachments of the framebuffer.
-
Framebuffer.
depth_attachment
¶ Texture or Renderbuffer – The depth attachment of the framebuffer.
-
Framebuffer.
glo
¶ int – The internal OpenGL object. This values is provided for debug purposes only.