Expand description
A modular framework for async 2D and 3D graphics applications.
§Getting started
Add the published crate to your application:
[dependencies]
wgame = "0.1.0"use wgame::{Window, prelude::*, gfx::types::color};
#[wgame::window(size = (800, 600), title = "Hello wgame")]
async fn main(mut window: Window<'_>) -> wgame::Result<()> {
while let Some(mut frame) = window.next_frame().await? {
frame.clear(color::BLACK);
frame.present();
}
Ok(())
}Window owns the graphics surface; each Frame borrows it. Create a
Library outside the frame loop to reuse graphics resources. See guide
for links to ownership, drawing, resource, and input contracts.
§Features and platforms
Defaults select desktop, shapes, fs, image, typography, and utils.
Optional content features are independently usable. Library::load_texture
requires fs + image; Library::load_font requires fs + typography.
desktop enables native windowing and the Vulkan/GLES/Metal/DX12 backends as
appropriate for the target. web selects WebGL2: disable default features when
using it. Native and web runtime features cannot be combined. WebGPU is available
at the lower gfx layer but is not selected by the facade’s web feature.
Re-exports§
pub use host::ContentFrame;pub use host::WindowHost;pub use wgame_input as canvas;pub use wgame_app as app;pub use wgame_gfx as gfx;pub use wgame_gfx_texture as texture;pub use wgame_fs as fs;pub use wgame_gfx_shapes as shapes;pub use wgame_gfx_3d as shapes3d;pub use wgame_gfx_typography as typography;pub use wgame_image as image;pub use wgame_utils as utils;pub use glam;pub use half;pub use rgb;
Modules§
- guide
- Navigation to the contracts documented by each owning API.
- host
- A replaceable host for one interactive drawing area.
- input
- Application framework items.
- prelude
- Commonly used types and traits.
- shader
- Shader utilities and types.
Macros§
- run_app
- Creates a main function that runs an application.
- run_
window - Creates a main function that runs a windowed application.
Structs§
- Error
- Error type for wgame applications.
The
Errortype, a wrapper around a dynamic error type. - Frame
- Public items from config, library, and window modules. Public items from config, library, and window modules. Public items from config, library, and window modules. A drawing frame borrowing its window.
- Input
- Application framework items. An independent buffered stream of window events.
- Library
- Public items from config, library, and window modules. Public items from config, library, and window modules. Public items from config, library, and window modules. Shared graphics helpers for reusable shapes, textures, and fonts.
- Runtime
- Application framework items. Runtime handle
- Window
- Public items from config, library, and window modules. Public items from config, library, and window modules. Public items from config, library, and window modules. A window with an async drawing loop and its graphics surface.
- Window
Config - Public items from config, library, and window modules. Public items from config, library, and window modules. Public items from config, library, and window modules. Configuration for a window.
- Windowed
Task - Single-consumer window task. Dropping it detaches the task.
Clone
Self::handlefor cancellation access. Cancellation before creation resolves without waiting for OS resume and prevents queued window creation. Suspension cancels the window function and reportsWindowError::Suspended; a manually managed caller decides whether to recreate the window.
Enums§
- Event
- Application framework items.
Describes an event from a [
Window]. - Window
Error
Functions§
- app_
with_ single_ window - Runs an application with a single window.
- create_
windowed_ task - Public items from config, library, and window modules. Public items from config, library, and window modules. Public items from config, library, and window modules.
- sleep
- Application framework items.
- spawn
- Application framework items.
- within_
window - Public items from config, library, and window modules. Public items from config, library, and window modules. Public items from config, library, and window modules.
Type Aliases§
- Result
- Error type for wgame applications.
Result<T, Error>