Files
wsg/lib/src
Jérôme Bousquié 531c43a457 material batching
2026-09-22 17:07:52 +02:00
..
2026-09-22 17:07:52 +02:00
2026-09-22 15:48:15 +02:00
2026-09-22 15:48:15 +02:00
2026-09-22 15:48:15 +02:00
2026-09-22 15:48:15 +02:00
2026-09-22 17:07:52 +02:00
2026-09-22 15:48:15 +02:00
2026-09-22 15:48:15 +02:00
2026-09-21 12:01:28 +02:00
2026-09-22 15:48:15 +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 (plus the shaders/ asset directory):

Module Responsibility
core Manager (Context) + Executor (Renderer) layers — GPU lifecycle and draw call orchestration (incl. the GPU-driven compute passes + opt-in frustum culling); also InputState (unified keyboard/mouse input, Step 15.B)
resources Data types: Vertex (CPU-side), Mesh (GPU geometry + bounding box), Material (appearance descriptor), Texture, Lights, Camera + CameraController, and the uniform slot types (TransformSlot/MatSlot/BBoxSlot/DrawSlot/CullUniforms)
pipeline PipelineCache — WGSL shader loading and RenderPipeline compilation cache
shaders Embedded WGSL sources (standard, shadow, gpu_driven) loaded via the include_str! fallback in utils::conf
scene Scene — resource depot and slot-based entity graph for declarative rendering setup (Step 17)
math Transform, Geometry (per-attribute mesh data + AABB), Frustum (Gribb–Hartmann, WebGPU [0,1] z) 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.