Expand description
A friendly renderer built with WGPU.
Frenderer currently manages a wgpu::Instance
and associated
types, initializing a custom SpriteRenderer based on
storage buffers (for native) and instance buffers (for WebGL).
It also provides a convenience type input::Input
for
processing user input and a utility function for loading a texture
(from disk or from a relative URL).
Except for the WGPU initialization, frenderer is fully modular; in
particular, it does not take control of the event loop. Typical
usage will call frenderer::with_default_runtime()
to install
frenderer inside a winit::window::Window
, call
sprites::SpriteRenderer::add_sprite_group()
on the resulting
frenderer::Renderer
value, and eventually call
frenderer::Renderer::process_window_event()
,
sprites::SpriteRenderer::upload_sprites()
, and
frenderer::Renderer::render
or
frenderer::Renderer::render_into
to draw.
In the future, more types of renderers including 3D renderers will also be provided.
Re-exports
pub use meshes::Camera3D;
pub use meshes::Transform3D;
pub use bitfont::BitFont;
pub use wgpu;
pub use frenderer::*;
Modules
Renderer
is the main user-facing type of this crate. You can make one usingwith_default_runtime()
or provide your ownsuper::Runtime
implementor viaRenderer::with_runtime()
.- A wrapper for a current and previous input button/mouse state.
Structs
- Camera2D is a transform for a sprite layer, defining a scale followed by a translation.
- A runtime using
pollster
for native builds - A SheetRegion defines the visual appearance of a sprite: which spritesheet (of an array of spritesheets), its pixel region within the spritesheet, and its visual depth (larger meaning further away).
- SpriteRenderer hosts a number of sprite groups. Each group has a specified spritesheet texture array, parallel vectors of
Transform
s andSheetRegion
s, and aCamera2D
to define its transform. Currently, all groups render into the same depth buffer so their outputs are interleaved. - A Transform describes a location, an extent, and a rotation in 2D space. Width and height are crammed into 4 bytes meaning the maximum width and height are
u16::MAX
and fractional widths and heights are not supported. The location(x,y)
is typically interpreted as the center of the object after translation. Rotations are in radians, counterclockwise about the center point. - A wrapper for a WGPU instance, surface, adapter, device, queue, and surface configuration.
Traits
- A runtime for frenderer; mainly wraps an async runtime, but also sets up logging, etc. In the future it might be responsible for setting up WGPU/providing a rendering context as well.