Expand description
CPU texture atlases, GPU render textures, and shared sampling for wgpu.
Texture owns CPU-editable pixels through a TextureAtlas, uploading them
on use. RenderTexture implements wgame_gfx::Target and owns a dedicated
GPU allocation; its explicit asynchronous readback produces a detached image.
Both implement SampledTexture, accepted by shapes and normal-map materials.
Neither type changes ownership mode, and no CPU mirror is kept for GPU rendering.
use wgame_gfx::{Target, types::color};
use wgame_gfx_texture::{SampledTexture, TexturingLibrary, TextureSettings};
let textures = TexturingLibrary::new(graphics);
let mut preview = textures.render_texture((256, 256), TextureSettings::linear())?;
preview.clear(color::BLUE);
// Draw through Target::render, Target::scene, or borrowed viewports as usual.
preview.submit(); // Submit drawing before another target samples it.
let sampled = preview.sample(); // Can outlive the drawing target.
let pixels = preview.readback().await?; // Detached snapshot; no automatic downloads.
let frozen = textures.texture(&pixels, TextureSettings::linear());See Texture for atlas updates/relocation, RenderTexture for submission
and snapshot contracts, and TextureSample for retained sampling handles.
Structs§
- Render
Texture - GPU-owned color texture with depth, ordinary target drawing, and sampling.
- Texture
- CPU-editable texture handle tracking its live atlas item.
- Texture
Atlas - GPU mirror of an append-only
Atlas. - Texture
Attribute - Per-instance UV mapping and tint, shared by every sampling source.
- Texture
Resource - Owned sampling resource. Equality identifies a shared source and sampler, allowing different items in one atlas to batch. Atlas uploads and generation resolution happen when a bind group is requested, preserving baked resources.
- Texture
Sample - Read-only sampling handle retained by shapes and scenes.
- Texture
Settings - Texturing
Library - A library for managing textures.
- Texturing
State - Shared samplers and binding layouts.
Enums§
- Readback
Error - GPU snapshot allocation, transfer, or mapping failure.
- Render
Texture Error - Invalid render texture dimensions or format.
Traits§
- Sampled
Texture - A texture usable by drawing APIs, independent of how its pixels are produced.
- Texel