Skip to content

Cross-Platform

Every target is built from the same jengine-core crate:

TargetRuntimeRenderingAudioScripting
Windowsjengine-runtime (winit + wgpu)DX12 / Vulkankira (cpal)Luau (mlua) + JavaScript (rquickjs)
Androidjengine-runtime as a NativeActivity APKVulkan, GLES fallbackkiraLuau only
Webjengine-web (wasm-bindgen)WebGPU, WebGL2 fallbackWeb Audio APIFengari (Lua 5.3)
Editorjengine-editor-viewport inside TauriWebGPU in WebView2Web Audio APIFengari — the same bundle as web builds

So what you verify in the editor is what a web build runs, while native runs Luau. Keep scripts to the common subset of the two Lua dialects, standard library included.

A project with its own Rust packages gets a generated crate per target — <project>/.jengine/runtime/, /web/ and /viewport/ — that links them in.

Platform-specific code uses cfg attributes (#[cfg(target_arch = "wasm32")], #[cfg(target_os = "android")]) and Cargo features. jengine-core’s features:

FeatureBrings
native (default)mlua (Luau)
physics (default)rapier2d
audio (default)kira
js-adapter-hostrquickjs, for JavaScript and batch scripts on the desktop
webwasm-bindgen, web-sys, js-sys
gpu-wgputhe wgpu renderer
backend-dx12, backend-vulkan, backend-metal, backend-webgpu, backend-webglone wgpu backend each

cargo check -p jengine-core without gpu-wgpu does not compile the renderer; check renderer changes with --features gpu-wgpu, or against the editor’s real target with cargo check -p jengine-editor-viewport --target wasm32-unknown-unknown. Android-only code is checked with cargo ndk -t arm64-v8a check -p jengine-runtime.

Shaders are WGSL, one source for every backend. They live in crates/jengine-core/assets/shaders/wgsl/ and are embedded at compile time with include_str!(); wgpu translates them to whatever the chosen backend speaks. Shader graphs generate WGSL too.

Avoid WGSL’s bit functions (firstTrailingBit and kin) in a shader the lights or sprites use: naga writes them as GLSL ES 3.10 calls that WebGL2 cannot compile.

Which backends a build carries is a project setting (Project Settings → Graphics). A crate that enables jengine-core/gpu-wgpu must name at least one backend feature or it compiles with no backend and fails at adapter request at runtime.

  • image crate: must use default-features = false on WASM (rayon breaks single-threaded WASM)
  • WebGPU canvases offer no sRGB format: the browser hosts draw through an sRGB view of the canvas, so colours match native
  • winit 0.30: windows are created inside the event loop (the Resumed handler), not before
  • glam SIMD: enabled on WASM via .cargo/config.toml with -C target-feature=+simd128
  • Batch scripts run on the native desktop runtime only
  • A web page served over https cannot open a plain ws:// socket to the online relay