Files
wsg/lib/src
Jérôme Bousquié 5ae978da23 doc
2026-09-21 10:07:32 +02:00
..
doc
2026-09-21 10:07:32 +02:00
doc
2026-09-21 10:07:32 +02:00
doc
2026-09-21 10:07:32 +02:00
doc
2026-09-21 10:07:32 +02:00
doc
2026-09-21 10:07:32 +02:00
doc
2026-09-21 10:07:32 +02:00
doc
2026-09-21 10:07:32 +02:00
doc
2026-09-21 10:07:32 +02:00
doc
2026-09-21 10:07:32 +02:00

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 eight modules:

Module Responsibility
core Manager (Context) + Executor (Renderer) layers — GPU lifecycle and draw call orchestration; also InputState (unified keyboard/mouse input, Step 15.B)
resources Data types: Vertex (CPU-side), Mesh (GPU geometry), Material (appearance descriptor), Texture, Lights, Camera + CameraController
pipeline PipelineCache — WGSL shader loading and RenderPipeline compilation cache
scene Scene — resource depot and entity graph for declarative rendering setup
math Transform, Geometry (per-attribute mesh data) and primitives (procedural mesh generators)
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.