Expand description
Guest SDK for 0x1 games (target wasm32-unknown-unknown).
gpu: a wgpu custom backend.sg_guest::gpu::instance()returns a normalwgpu::Instance, so existing wgpu code runs unchanged on the host GPU.- Safe wrappers for the rest of the
sgAPI: clock, input, TCP, HTTP fetch, key/value storage, audio, and workers/messages. logintegration and a panic hook that reports through the host log.
A game exports sg_init() -> i32 and sg_frame(t: f64, dt: f64); worker
instances export sg_worker_init() -> i32 and sg_worker_tick(t: f64) -> i32.
Re-exports§
pub use sg_abi as abi;
Modules§
- audio
- display
- Presentation settings and HDR output (see
sg_abi::displayandsg_abi::hdr). - gpu
- A wgpu custom backend that forwards to the host through the sg GPU API.
- kv
- Per-game persistent key/value storage (requires
storage_mbin the manifest). - rtc
- WebRTC data channels to other players, browsers included (manifest permission
rtc). The game carries the SDP strings itself (non-trickle: candidates are inside them). Each connection has one reliable, ordered channel. - sys
- Raw imports from module
sg. See runtime/docs/API.md for the contract. - worker
Structs§
- Fetch
- An HTTP(S) request to a URL prefix declared in the manifest.
- TcpStream
- A non-blocking TCP stream to a destination declared in the manifest.
Enums§
Functions§
- arg
- Looks up one launch argument (like
URLSearchParams.get). - arg_
pairs - Parsed launch arguments (
a=1&b=x→ [(“a”,“1”), (“b”,“x”)]), percent-decoded. - args
- The game’s launch arguments: the manifest URL’s query string.
- asset
- init
- Installs the
logbackend and a panic hook. Call first insg_init. - log_str
- Writes a line to the host log.
- now_ms
- Milliseconds since the instance started (monotonic, like
performance.now()). - pointer_
locked - poll_
input - Drains pending input events.
- quit
- random_
bytes - set_
pointer_ lock - set_
title - surface_
size - wall_ms
- Unix time in milliseconds (like
Date.now()). - window_
focused - worker_
id - 0 in the main instance, else this worker’s id.