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


2.3.11 Viewports

A viewport represents a subset of the screen (or framebuffer). When rendering a frame, the resulting image will only appear within that viewport. These aren’t often needed, and Chickadee’s default viewport occupies the entire screen, but there are certain situations where they are useful. For example, a split-screen multiplayer game may render to two different viewports, each occupying a different half of the screen. For information about how to set the current viewport, see with-viewport in Rendering Engine.

The (chickadee render viewport) module provides the following API:

Procedure: make-viewport x y width height [#:clear-color] [#:clear-flags]

Create a viewport that covers an area of the window starting from coordinates (x, y) and spanning width x height pixels. Fill the viewport with clear-color when clearing the screen. Clear the buffers denoted by the list of symbols in clear-flags.

Possible values for clear-flags are color-buffer, depth-buffer, accum-buffer, and stencil-buffer.

Procedure: viewport? obj

Return #t if obj is a viewport.

Procedure: viewport-x viewport

Return the left edge of viewport.

Procedure: viewport-y viewport

Return the bottom edge of viewport.

Procedure: viewport-width viewport

Return the width of viewport.

Procedure: viewport-height viewport

Return the height of viewport.

Procedure: viewport-clear-color viewport

Return the clear color for viewport.

Procedure: viewport-clear-flags viewport

Return the list of clear flags for viewport.