C API: Overlays¶
A picture the host draws on the CPU, blended over the frame by the renderer: Overlays.
sona_renderer_overlay¶
sona_result sona_renderer_overlay(sona_renderer *r, const sona_overlay *o);
| Parameter and type | Meaning |
|---|---|
rsona_renderer * |
The renderer (required) |
oconst sona_overlay * |
A sona_overlay (required) |
Returns SONA_OK. Errors SONA_E_ARGUMENT, SONA_E_LIMIT, SONA_E_MEMORY, SONA_E_CONTEXT (what each means).
Example (also in Overlays: a picture over the frame):
sona_overlay o;
memset(&o, 0, sizeof o);
o.size = sizeof o;
o.width = hud_w;
o.height = hud_h;
/* straight RGBA8, row 0 at the top; read during the call only */
o.rgba = hud_pixels;
/* the same as the last call's: nothing is uploaded */
o.revision = hud_revision;
/* what changed; w 0: all of it */
o.dirty[0] = x; o.dirty[1] = y; o.dirty[2] = w; o.dirty[3] = h;
/* o.rect: where it lands in the target, pixels from the top left; w 0:
the whole target */
sona_renderer_overlay(renderer, &o);
/* the avatars, the credit, then the overlay */
sona_draw(renderer, &view, &target, &opts);
/* the next draws have none (the texture is kept) */
sona_renderer_overlay(renderer, NULL);
Sets r's overlay for every sona_draw that follows, until the next call. o NULL takes it away (its texture is kept for the next one of the same size). After sona_renderer_reset or a lost device, set it again. SONA_E_ARGUMENT for a bad size or stride, a dirty rectangle outside the picture, or no rgba; SONA_E_LIMIT past the largest texture.
sona_renderer_underlay¶
sona_result sona_renderer_underlay(sona_renderer *r, const sona_overlay *o);
| Parameter and type | Meaning |
|---|---|
rsona_renderer * |
The renderer (required) |
oconst sona_overlay * |
A sona_overlay (required) |
Returns SONA_OK. Errors SONA_E_ARGUMENT, SONA_E_UNSUPPORTED, SONA_E_LIMIT, SONA_E_MEMORY, SONA_E_CONTEXT (what each means).
Example:
sona_overlay x_overlay;
memset(&x_overlay, 0, sizeof x_overlay);
x_overlay.size = sizeof x_overlay;
sona_result result = sona_renderer_underlay(r, &x_overlay);
if (result != SONA_OK) printf("sona_renderer_underlay: %s\n",
sona_result_name(result));
A picture behind the avatars, as a page's backdrop behind a clear canvas: drawn first in the main pass at o->rect (w or h 0: the whole target), for every sona_draw and sona_snapshot until the next call; NULL takes it away. The frame's bloom runs over it as over the avatars. The editor draws 360sona.com's stage gradient this way. GL and Vulkan have it; on the other backends it returns SONA_E_UNSUPPORTED and the frame's clear shows.
This page as Markdown · All the docs as one file (llms-full.txt)