Next: , Previous: , Up: Graphics   [Contents][Index]


2.3.8 Framebuffers

A framebuffer is a chunk of memory that the GPU can render things onto. By default, the framebuffer that is used for rendering is the one belonging to the game window, but custom framebuffers can be used as well. A common use-case for custom framebuffers is applying post-processing effects: The entire scene is rendered to a framebuffer, and then the contents of that framebuffer are applied to a post-processing shader and rendered to the game window. The post-processing shader could do any number of things: scaling, antialiasing, motion blur, etc.

Procedure: make-framebuffer width height [#:min-filter linear] [#:mag-filter linear] [#:wrap-s repeat] [#:wrap-t repeat]

Create a new framebuffer that is width pixels wide and height pixels high.

min-filter and mag-filter determine the scaling algorithm applied to the framebuffer when rendering. By default, linear scaling is used in both cases. To perform no smoothing at all, use nearest for simple nearest neighbor scaling. This is typically the best choice for pixel art games.

Procedure: framebuffer? obj

Return #t if obj is a framebuffer.

Procedure: framebuffer-texture fb

Return the texture backing the framebuffer fb.

Procedure: framebuffer-viewport fb

Return the default viewport (see Viewports) used by the framebuffer fb.

Procedure: null-framebuffer

The default framebuffer.