Skip to main content

Crate wgame_gfx

Crate wgame_gfx 

Source
Expand description

GPU rendering with ordered scenes, reusable renderers, and window/offscreen targets.

Collect changing objects in a Scene, then draw through Target::render_iter. For unchanged content, Scene::bake produces a BakedScene that reuses its instance buffers across frames and cameras. See those types for painter order, resource lifetimes, and rebaking rules.

Target::camera supplies aspect-correct coordinates; Target::physical_camera uses physical pixels. AutoScene provides automatic rendering on normal drop. Target::viewport borrows a clipped rectangle with its own camera coordinates for previews, split-screen views, and nested drawing areas.

§Custom and headless rendering

Use Graphics::device and Graphics::queue for direct wgpu access. Implement Renderer<C> to encode drawing in a supplied render pass and Context for shared bindings. Target abstracts window frames and Offscreen textures. Graphics::new wraps a supplied adapter/device/queue for headless applications. The facade’s raw_wgpu example demonstrates a custom pipeline.

Modules§

modifiers
prelude
Commonly used types and traits.
types
utils

Macros§

delegate_transformable
impl_object_for_instance
impl_transformable

Structs§

AutoScene
A scene borrowing its target and rendering on normal drop. Use Self::render for an explicit boundary or Self::discard to abandon it. Panic unwinding does not render. Finish the scene’s borrow before presenting the enclosing frame.
BakedScene
Renderer snapshot with fixed instance buffers and resource bindings.
Camera
Config
Surface presentation and GPU device requirements.
DepthBuffer
Reusable depth attachment. Recreate it when the target size changes. Clear to 1 before its first use and at the beginning of each new scene/frame.
Error
The Error type, a wrapper around a dynamic error type.
Frame
Graphics
Offscreen
Reusable render target without a window. Submitted pixels can be sampled or copied from Offscreen::texture. Resize by constructing a new target.
Ordered
Scene
Painter-ordered collection of drawing instances.
Surface
Viewport
A borrowed rectangle of a render target, created by Target::viewport.

Enums§

DepthMode
Depth policy for a drawable. Smaller projected depth is nearer.
PresentMode
Timing and queueing with which frames are actually displayed to the user.
ViewportError
Invalid viewport rectangle. The parent remains usable after an error.

Constants§

DEPTH_FORMAT
Depth format used by built-in targets and pipelines (including WebGL2).

Traits§

AnyResource
AnyStorage
Context
Instance
Single instance to draw.
InstanceVisitor
Object
Renderer
Encodes drawing in a target-configured pass. Custom renderers must preserve its viewport and scissor state so borrowed targets retain their bounds.
Resource
Shared resource required to draw an instance.
Storage
Target
Color and depth render target. All built-in targets use crate::DEPTH_FORMAT. clear resets color and depth; successive render calls share depth. Clear depth explicitly when starting an independent camera/overlay scene. Custom pipelines used by render must declare the same depth format, even when ignoring depth (see crate::DepthMode::Overlay). Borrow a Viewport to draw into a smaller rectangle without allocating another render texture.