Skip to content

C API: Loading placeholders

A neutral figure in the avatar's place while it loads, and avatars added before their manifest is known: Loading placeholders.

sona_placeholder_defaults

void sona_placeholder_defaults(sona_placeholder_options *o);
Parameter and type Meaning
o
sona_placeholder_options *
The sona_placeholder_options to fill with the defaults (required)

Returns Nothing.

Example:

sona_placeholder_options x_placeholder_options;
memset(&x_placeholder_options, 0, sizeof x_placeholder_options);
x_placeholder_options.size = sizeof x_placeholder_options;
sona_placeholder_defaults(&x_placeholder_options);

size set; delay_seconds 0 (never a hole), appear_seconds 0.2, reveal_seconds 0.4, failed_seconds 2, tint 0.16, 0.19, 0.25 (a cool grey), failed_tint 0.25, 0.15, 0.15 (a muted red), glow 0.5.

sona_placeholder_set

sona_result sona_placeholder_set(sona_ctx *ctx,
                                 const sona_placeholder_options *o);
Parameter and type Meaning
ctx
sona_ctx *
The context (required)
o
const sona_placeholder_options *
The options, a sona_placeholder_options (NULL: the defaults)

Returns SONA_OK. Errors SONA_E_ARGUMENT, SONA_E_MEMORY (what each means).

Example (also in Loading placeholders):

sona_open(&cfg, &ctx);
sona_placeholder_set(ctx, NULL);         /* on, with the defaults */
/* optional: far figures become sprites too */
sona_lod_set(ctx, NULL);

/* ... add avatars as usual; they show figures until READY ... */

while (game_running()) {               /* your game's loop */
  sona_update(ctx, dt, &view, NULL);     /* phases, timers, posing */
  sona_draw(renderer, &view, &target, NULL);
}

NULL: the defaults. SONA_E_ARGUMENT for a size that is not the struct's, a negative or non-finite time (each has a limit of 60 s), a colour outside 0..1 or reserved words that are not zero. Takes effect at the next sona_update.

sona_placeholder_get

sona_result sona_placeholder_get(const sona_ctx *ctx,
                                 sona_placeholder_options *out);
Parameter and type Meaning
ctx
const sona_ctx *
The context (required)
out
sona_placeholder_options *
Receives the sona_placeholder_options (required)

Returns SONA_OK. Errors SONA_E_ARGUMENT, SONA_E_NOT_FOUND (what each means).

Example:

sona_placeholder_options x_placeholder_options;
memset(&x_placeholder_options, 0, sizeof x_placeholder_options);
x_placeholder_options.size = sizeof x_placeholder_options;
sona_result result = sona_placeholder_get(ctx, &x_placeholder_options);
if (result != SONA_OK) printf("sona_placeholder_get: %s\n",
    sona_result_name(result));

SONA_E_NOT_FOUND while placeholders are off (out still gets the options last set, or the defaults).

sona_placeholder_off

sona_result sona_placeholder_off(sona_ctx *ctx);
Parameter and type Meaning
ctx
sona_ctx *
The context (required)

Returns SONA_OK. Errors SONA_E_ARGUMENT (what each means).

Example:

sona_result result = sona_placeholder_off(ctx);
if (result != SONA_OK) printf("sona_placeholder_off: %s\n",
    sona_result_name(result));

Figures shown now fade out over appear_seconds.

sona_avatar_placeholder

sona_result sona_avatar_placeholder(sona_avatar *a, int32_t mode);
Parameter and type Meaning
a
sona_avatar *
The avatar (required)
mode
int32_t
A SONA_PLACEHOLDER_* mode for this avatar

Returns SONA_OK. Errors SONA_E_ARGUMENT, SONA_E_DESTROYED, SONA_E_MEMORY (what each means).

Example:

sona_result result = sona_avatar_placeholder(avatar, 0);
if (result != SONA_OK) printf("sona_avatar_placeholder: %s\n",
    sona_result_name(result));

Per avatar: -1 follows the ctx (the default), 0 never, 1 always (with the ctx's options, or the defaults).

sona_avatar_placeholder_info

sona_result sona_avatar_placeholder_info(const sona_avatar *a,
                                         sona_placeholder_info *out);
Parameter and type Meaning
a
const sona_avatar *
The avatar (required)
out
sona_placeholder_info *
Receives the sona_placeholder_info (required)

Returns SONA_OK. Errors SONA_E_ARGUMENT, SONA_E_DESTROYED (what each means).

Example:

sona_placeholder_info x_placeholder_info;
memset(&x_placeholder_info, 0, sizeof x_placeholder_info);
x_placeholder_info.size = sizeof x_placeholder_info;
sona_result result = sona_avatar_placeholder_info(avatar,
                                                  &x_placeholder_info);
if (result != SONA_OK) printf("sona_avatar_placeholder_info: %s\n",
    sona_result_name(result));

The avatar's figure at the last sona_update: its phase, opacity, height, which figure (male, female or neutral), whether it plays the avatar's clip, the seconds since the avatar was added and whether it is drawn as a sprite.

sona_placeholder_stats_get

void sona_placeholder_stats_get(const sona_ctx *ctx,
                                sona_placeholder_stats *out);
Parameter and type Meaning
ctx
const sona_ctx *
The context (required)
out
sona_placeholder_stats *
Receives the sona_placeholder_stats (required)

Returns Nothing.

Example:

sona_placeholder_stats x_placeholder_stats;
memset(&x_placeholder_stats, 0, sizeof x_placeholder_stats);
x_placeholder_stats.size = sizeof x_placeholder_stats;
sona_placeholder_stats_get(ctx, &x_placeholder_stats);

Figures in view at the last sona_update (by phase, and how many as sprites), how many were posed and the time that took, and the figure draws of the last sona_draw or sona_snapshot.

sona_avatar_add_waiting

sona_result sona_avatar_add_waiting(sona_ctx *ctx,
                                    const sona_add_options *opts,
                                    sona_avatar **out);
Parameter and type Meaning
ctx
sona_ctx *
The context (required)
opts
const sona_add_options *
The options, a sona_add_options (required)
out
sona_avatar **
Receives the new avatar (required)

Returns SONA_OK. Errors SONA_E_ARGUMENT, SONA_E_MEMORY, SONA_E_MANIFEST (what each means).

Example (also in Loading placeholders):

sona_avatar *seat;
/* QUEUED, the neutral figure */
sona_avatar_add_waiting(ctx, &opts, &seat);
/* ... later, when the network brings the manifest ... */
/* now it loads like any avatar */
sona_avatar_set_manifest_base64(seat, b64);

An avatar whose manifest is not known, as for a player joining before their profile arrives. It stays QUEUED and shows the neutral figure (with placeholders on) until sona_avatar_set_manifest gives it its manifest, once; then it loads as if it had been added with it. Placement, play, layers and the rest work on it as on any avatar. sona_avatar_set_manifest: SONA_E_ARGUMENT for an avatar not added waiting or already given one. A bad manifest fails the avatar later with SONA_E_MANIFEST, as sona_avatar_add.

sona_avatar_set_manifest

sona_result sona_avatar_set_manifest(
    sona_avatar *a, const uint8_t manifest[SONA_MANIFEST_BYTES]);
Parameter and type Meaning
a
sona_avatar *
The avatar (required)
manifest
const uint8_t [SONA_MANIFEST_BYTES]
The manifest's 1,000 bytes (required)

Returns SONA_OK. Errors SONA_E_ARGUMENT, SONA_E_DESTROYED (what each means).

Example:

sona_result result = sona_avatar_set_manifest(avatar, manifest);
if (result != SONA_OK) printf("sona_avatar_set_manifest: %s\n",
    sona_result_name(result));

Gives an avatar added with sona_avatar_add_waiting its manifest, once; it then loads as if it had been added with it. SONA_E_ARGUMENT for an avatar not added waiting or already given one.

sona_avatar_set_manifest_base64

sona_result sona_avatar_set_manifest_base64(sona_avatar *a,
                                            const char *b64);
Parameter and type Meaning
a
sona_avatar *
The avatar (required)
b64
const char *
The manifest as base64 text, at most 4096 characters (required)

Returns SONA_OK. Errors SONA_E_ARGUMENT, SONA_E_DESTROYED (what each means).

Example (also in Loading placeholders):

sona_avatar *seat;
/* QUEUED, the neutral figure */
sona_avatar_add_waiting(ctx, &opts, &seat);
/* ... later, when the network brings the manifest ... */
/* now it loads like any avatar */
sona_avatar_set_manifest_base64(seat, b64);

sona_avatar_set_manifest with the manifest as base64 text.

This page as Markdown · All the docs as one file (llms-full.txt)