Files
wsg/lib/src
Jérôme Bousquié 440f2dffa3 refactor(resources): activate diffuse textures on all render paths (Étape 10)
Implémente le plan Étape 10 (Phase 4.1 Textures), décisions D1-D4 actées :
- 10.1 : nouveau type resources::Texture (device+view+sampler), format
  Rgba8UnormSrgb, sampler linear/repeat, dep 'image' (png/jpeg). Constructeurs
  from_rgba8 / from_bytes / from_file / white_placeholder.
- 10.2 : create_texture_bind_group_layout (groupe 2 : sampler+texture, fragment).
  build_pipeline pose désormais 3 layouts [frame, object, texture] — « un seul
  layout pour tous » (D1). PipelineCache détient le layout + le placeholder blanc.
- 10.3 : shader standard — UV transmis au fragment (location 2), groupe @2
  texture_sampler + diffuse_texture, échantillonnage inconditionnel
  base = texel * couleur(vertex) (D2) : sans texture (placeholder blanc) pas
  de régression en lit comme en unlit.
- 10.4 : Material gagne texture: Option<Arc<Texture>> + texture_bind_group,
  construit dans le constructeur via le cache (layout partagé + placeholder).
- 10.5 : draw_entity bind @group(2) ; Scene : add_texture / get_texture /
  add_material_texture ; init_gpu accepte la Queue pour bâtir le placeholder.
- exemple cube : géométrie avec UV [0,1]² par face + texture damier procédurale.

Validation : fmt, check 0 warning, tests verts (3 + doc), doc sans missing_docs,
cube/simple/manual lancés sans erreur backend.
2026-09-18 14:18:02 +02:00
..
doc
2026-07-08 15:46:50 +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 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.