Sursface is a small cross-platform rendering library designed to simplify the development of WebGPU applications, without compromising developer control.
It builds upon well-established APIs (wgpu
and winit
) to wrap over the core lifecycle operations of a graphical app, while re-exposing the full capabilities of these APIs unchanged. Sursface's goal is to enable writing plain WebGPU code with less hassle.
- Cross-Platform Desktop: Compile and run on Linux or Windows.
- WASM: Automatically generate JavaScript bindings for the
wasm32-unknown
Nix target, making your apps trivially embeddable into webpages.
- Ready-made WebGPU Surface: Sursface provides the entrypoint to your graphical app by supplying a platform window configured to be used as a surface by
wgpu
. - Event Loop: Sursface abstracts away the specifics of the event loop, whether it's running on desktop or in the browser. You simply need to provide the function pointer to your frame-by-frame logic, and Sursface will regularly call it for you.
- No New Tech: Once the setup is done, keep using
wgpu
as ifsursface
wasn't there. - Default Logic (WIP): Sursface will offer opt-in shortcuts for some elementary operations through simple functions, further reducing graphical boilerplate.
To compile Sursface, ensure you have the following tools installed: Rust, Cargo, and optionally Nix (recommended).
Clone the repository:
git clone https://github.com/boralg/sursface.git
cd sursface
You can compile Sursface on your native platform using Cargo:
cargo build --release
To build a binary inside the Nix store, ready to run locally:
nix build .
Sursface supports cross-compilation to various targets. Here are some examples:
nix build .#x86_64-linux
nix build .#x86_64-windows
nix build .#wasm32-unknown
Releases consist of executable binaries of the examples. These are automatically built by a pipeline on every push to main
, and can be directly downloaded, unzipped, and ran, without any installation process.
Examples can also be run directly with cargo
:
cargo run --bin <example_name>
For instance:
cargo run --bin hello_triangle