Framebuffers

A framebuffer is a collection of buffers that can be used as the destination for rendering. OpenGL has two kinds of framebuffers: the default framebuffer, which is provided by the OpenGL Context; and user-created framebuffers called framebuffer objects (FBOs). The buffers for default framebuffers are part of the context and usually represent a window or display device. The buffers for FBOs reference images from either textures or render buffers; they are never directly visible.

Read more on framebuffers on OpenGL Wiki

Example usage

...
texture = np.zeros((512,512,4),np.float32).view(gloo.TextureFloat2D)
framebuffer = gloo.FrameBuffer(color=[texture])
...

@window.event
def on_draw(dt):
    window.clear()
    framebuffer.activate()
    quad.draw(gl.GL_TRIANGLE_STRIP)
    framebuffer.deactivate()

Content

RenderBuffer

class glumpy.gloo.RenderBuffer(width=0, height=0, format=None)

Bases: glumpy.gloo.globject.GLObject

Base class for render buffer object.

Parameters:
  • format (GLEnum) – Buffer format
  • width (int) – Buffer width (pixels)
  • height (int) – Buffer height (pixel)
height

Buffer height (read-only).

resize(width, height)

Resize the buffer (deferred operation).

Parameters:
  • width (int) – New buffer width (pixels)
  • height (int) – New buffer height (pixels)
width

Buffer width (read-only).

ColorBuffer

class glumpy.gloo.ColorBuffer(width, height, format=GL_RGBA)

Bases: glumpy.gloo.framebuffer.RenderBuffer

Color buffer object.

Parameters:
  • width (int) – Buffer width (pixels)
  • height (int) – Buffer height (pixel)
  • format (GLEnum) – Buffer format (default is gl.GL_RGBA)

DepthBuffer

class glumpy.gloo.DepthBuffer(width, height, format=GL_DEPTH_COMPONENT)

Bases: glumpy.gloo.framebuffer.RenderBuffer

Depth buffer object.

Parameters:
  • width (int) – Buffer width (pixels)
  • height (int) – Buffer height (pixel)
  • format (GLEnum) – Buffer format (default is gl.GL_DEPTH_COMPONENT)

StencilBuffer

class glumpy.gloo.StencilBuffer(width, height, format=GL_STENCIL_INDEX8)

Bases: glumpy.gloo.framebuffer.RenderBuffer

Stencil buffer object

Parameters:
  • width (int) – Buffer width (pixels)
  • height (int) – Buffer height (pixel)
  • format (GLEnum) – Buffer format (default is gl.GL_STENCIL_INDEX8)

FrameBuffer

class glumpy.gloo.FrameBuffer(color=None, depth=None, stencil=None)

Bases: glumpy.gloo.globject.GLObject

Framebuffer object.

Parameters:
color

Color buffer attachment(s) (read/write)

depth

Depth buffer attachment (read/write)

height

Buffer height (read only, pixels)

resize(width, height)

Resize the buffer (deferred operation).

This method will also resize any attached buffers.

Parameters:
  • width (int) – New buffer width (pixels)
  • height (int) – New buffer height (pixels)
stencil

Stencil buffer attachment (read/write)

width

Buffer width (read only, pixels)