Graphics (gg)
The gg windowing, audio, and input layer: 21 intrinsics, headless by default.
pull "gg" opens the windowing, audio, and input layer (yes, gg, as in good game). It’s headless
by default: present and audio no-op, input polls empty, nothing pops up on screen. Build with the
desktop feature when you want a real window. The return shapes are identical either way, so all your
game logic stays testable headless, no display required. All 21 intrinsics run on both the interpreter
and the compiled paths.
Event kinds
Returned by gg.poll as (kind, code):
| Kind | Value |
|---|---|
NONE |
0 |
KEY_DOWN |
1 |
KEY_UP |
2 |
MOUSE_MOVE |
3 |
QUIT |
4 |
MOUSE_DOWN |
5 |
MOUSE_UP |
6 |
For mouse buttons, code is 0 for left and 1 for right. QUIT fires only on a real window close.
Esc is a normal KEY_DOWN / KEY_UP (code 27), so games can drive menus with it.
Keycodes
Letters A to Z and digits 0 to 9 are ASCII. Beyond those: SPACE = 32, ENTER = 10,
ESC = 27, BACKSPACE = 8, TAB = 9; arrows UP = 256, DOWN = 257, LEFT = 258, RIGHT = 259.
bet run)Cruns in the compiled backendBegin a frame; clear the canvas to color (0x00RRGGBB).
Fill a rectangle (0xAARRGGBB).
Present a tightly-packed w*h framebuffer 1:1.
Present a fixed-logical-size framebuffer, aspect-fit / letterboxed.
Live window size.
Upload a w*h RGBA8 texture; returns a 1-based texture id.
Blit a whole texture at (x, y).
Blit a source sub-rectangle.
Present the composited canvas and pump input.
Set the window title.
Queue count interleaved i16 samples (streaming ring).
Device output spec.
Interleaved samples still queued (synth backpressure).
Register a PCM sound; returns a 1-based id.
Start a voice; returns a 1-based voice id.
Stop a voice.
Live-update a voice's volume + stereo pan.
Next input event; kind == 0 (NONE) when the queue is empty.
Monotonic nanosecond counter (hi-res timing).
Mouse position in logical-canvas coords.
Signed raw mouse movement since the last call.