cube¶
spinning wireframe 3D cube (the stage-7 graphics demo)
NAME
cube - spinning wireframe 3D cube (the stage-7 graphics demo)
SYNOPSIS
cube [frames] [s]
DESCRIPTION
Draws a perspective wireframe cube -- front face red, back face
green, connecting edges blue (stage 9 colour-per-record) -- and
spins it about two axes, one frame at a time, then exits. With no argument it runs 64
frames (one full turn); a numeric argument runs that many. Needs the
display; prints ?No display without one.
The cube is the first client of the C 3D library (/lib/lib_g3d.c, used
as `//#use gfx` + `//#use g3d` from C): a retained pool of 3D edges
(g3line), a window on the view plane (g3window), a viewport on the
screen (g3view), perspective projection (g3persp), and a render call
(g3render) that clips, projects, maps and hands each surviving edge to
the display's hardware LINE. The rotation itself is the demo's own
integer sine table, not the library's.
With the GL engine fitted (stage 10c) the cube is a STORED COMMAND
LIST that spins itself: the list nudges the card's modeling matrix
(MDROTY 6, MDROTX 3 per pass), erases, draws the 12 edges, flips
and waits a frame tick -- and CLOOP runs it N times with the CPU
completely idle. On the way in it CLEARS both framebuffer pages
(power-on contents are undefined) and on the way out it rejoins
them (PGSYNC), so drawing afterwards behaves. `cube N s` forces the
stage-7 all-software path (~72 ms a frame, rebuilt from constants
every frame so frame N is identical on every run) -- without a GL
engine that path is the automatic fallback.
EXAMPLES
cube one full turn and exit
cube 500 keep spinning for 500 frames
SEE ALSO
g3d, gfx, basic (GRAPHICS section)
The text of man cube on P8X (os/man/cube in the repository). All commands