pyglet.image.buffer
OpenGL Framebuffer abstractions.
This module provides classes for working with Framebuffers & Renderbuffers and their attachments. Attachements can be pyglet Texture objects, which allows easily accessing their data, saving to disk, etc. Renderbuffers can be used if you don’t need to access their data at a later time. For example:
# Create two objects to use as attachments for our Framebuffer.
color_buffer = pyglet.image.Texture.create(width, height, min_filter=GL_NEAREST, mag_filter=GL_NEAREST)
depth_buffer = pyglet.image.buffer.Renderbuffer(width, height, GL_DEPTH_COMPONENT)
# Create a framebuffer object, and attach the two buffers:
framebuffer = pyglet.image.Framebuffer()
framebuffer.attach_texture(color_buffer, attachment=GL_COLOR_ATTACHMENT0)
framebuffer.attach_renderbuffer(depth_buffer, attachment=GL_DEPTH_ATTACHMENT)
# Bind the Framebuffer, which sets it as the active render target:
framebuffer.bind()
See the OpenGL documentation for more information on valid attachment types and targets.
- class Framebuffer
OpenGL Framebuffer Object.
New in version 2.0.
- attach_renderbuffer(
- renderbuffer: Renderbuffer,
- target: int = 36160,
- attachment: int = 36064,
Attach a Renderbuffer to the Framebuffer.
- Parameters:
renderbuffer (
Renderbuffer
) – Specifies the Renderbuffer to attach to the framebuffer attachment point named by attachment.target (
int
) – Specifies the framebuffer target. target must be GL_DRAW_FRAMEBUFFER, GL_READ_FRAMEBUFFER, or GL_FRAMEBUFFER. GL_FRAMEBUFFER is equivalent to GL_DRAW_FRAMEBUFFER.attachment (
int
) – Specifies the attachment point of the framebuffer. attachment must be GL_COLOR_ATTACHMENTi, GL_DEPTH_ATTACHMENT, GL_STENCIL_ATTACHMENT or GL_DEPTH_STENCIL_ATTACHMENT.
- Return type:
- attach_texture( ) None
Attach a Texture to the Framebuffer.
- Parameters:
texture (
Texture
) – Specifies the texture object to attach to the framebuffer attachment point named by attachment.target (
int
) – Specifies the framebuffer target. target must be GL_DRAW_FRAMEBUFFER, GL_READ_FRAMEBUFFER, or GL_FRAMEBUFFER. GL_FRAMEBUFFER is equivalent to GL_DRAW_FRAMEBUFFER.attachment (
int
) – Specifies the attachment point of the framebuffer. attachment must be GL_COLOR_ATTACHMENTi, GL_DEPTH_ATTACHMENT, GL_STENCIL_ATTACHMENT or GL_DEPTH_STENCIL_ATTACHMENT.
- Return type:
- attach_texture_layer( ) None
Attach a Texture layer to the Framebuffer.
- Parameters:
texture (
Texture
) – Specifies the texture object to attach to the framebuffer attachment point named by attachment.layer (
int
) – Specifies the layer of texture to attach.level (
int
) – Specifies the mipmap level of texture to attach.target (
int
) – Specifies the framebuffer target. target must be GL_DRAW_FRAMEBUFFER, GL_READ_FRAMEBUFFER, or GL_FRAMEBUFFER. GL_FRAMEBUFFER is equivalent to GL_DRAW_FRAMEBUFFER.attachment (
int
) – Specifies the attachment point of the framebuffer. attachment must be GL_COLOR_ATTACHMENTi, GL_DEPTH_ATTACHMENT, GL_STENCIL_ATTACHMENT or GL_DEPTH_STENCIL_ATTACHMENT.
- Return type:
- static get_status() str
Get the current Framebuffer status, as a string.
If
Framebuffer.is_complete
isFalse
, this method can be used for more information. It will return a string with the OpenGL reported status.- Return type: