Files
wsg/lib/src

wsg-lib Source Directory

Overview

This is the source tree for wsg-lib, a Rust library wrapping wgpu for simple 3D drawing operations. The crate follows a layered architecture organized into seven modules:

Module Responsibility
core Manager (Context) + Executor (Renderer) layers — GPU lifecycle and draw call orchestration
resources Data types: Vertex (CPU-side), Mesh (GPU geometry), Material (appearance descriptor)
pipeline PipelineCache — WGSL shader loading and RenderPipeline compilation cache
scene Scene — resource depot and entity graph for declarative rendering setup
utils Configuration constants and WsgError type
app App facade — high-level application orchestration with window lifecycle, event loop, and render automation
handler AppHandler trait — user-defined game logic interface injected into the render loop

Architecture Pattern

The library supports two workflows:

  • Declarative (recommended): Use Scene to register resources and associate entities before the render loop begins. This is the "App facade" pattern described in ARCHI_APP.
  • Manual: Manipulate Context, Renderer, and PipelineCache directly for fine-grained control.

Dependency Flow

scene → core → pipeline → utils
        ↘→ resources → utils (via Vertex offsets)
                  ↗
              scene (consumes)

Each submodule's mod.rs re-exports its public types so consumers import through the module level rather than deep paths.