Skip to main content

Crate wgame_gfx_texture

Crate wgame_gfx_texture 

Source
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§

RenderTexture
GPU-owned color texture with depth, ordinary target drawing, and sampling.
Texture
CPU-editable texture handle tracking its live atlas item.
TextureAtlas
GPU mirror of an append-only Atlas.
TextureAttribute
Per-instance UV mapping and tint, shared by every sampling source.
TextureResource
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.
TextureSample
Read-only sampling handle retained by shapes and scenes.
TextureSettings
TexturingLibrary
A library for managing textures.
TexturingState
Shared samplers and binding layouts.

Enums§

ReadbackError
GPU snapshot allocation, transfer, or mapping failure.
RenderTextureError
Invalid render texture dimensions or format.

Traits§

SampledTexture
A texture usable by drawing APIs, independent of how its pixels are produced.
Texel

Type Aliases§

FilterMode