Skip to content

About

Realm 2D renderer and input on wgpu and winit

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Realm Render

Draw a 2D game in a native window or render the same frame to a PNG.

Quick start  ·  Frame API  ·  Tests

use realm_render::{Error, render_to_png};

fn main() -> Result<(), Error> {
    render_to_png(320, 180, |frame| {
        frame.clear([0.08, 0.18, 0.16, 1.0]);
        frame.circle([160.0, 90.0], 18.0, [0.95, 0.65, 0.22, 1.0]);
        frame.hud().text([8.0, 8.0], 2.0, [1.0; 4], "Spawn");
    }, "spawn.png")
}

What is Realm Render?

Realm Render is a standalone Rust library for drawing 2D games with wgpu and winit. It batches shapes, sprites, and bitmap text into world and HUD layers, collects keyboard and mouse input, and can render a frame directly to a PNG.

Keep the HUD still

Set a Camera2d on the frame to pan or zoom the world. Commands on frame.hud() use screen pixels and draw last, so a label stays in the corner as the camera moves. Frame and layer API

The sample frame shows a gold circle in the world and the Spawn label at the upper left.

click at screen pixel
↓ screen_to_world
world coordinate

Pick a point in the world

Read keyboard edges, typed text and mouse clicks in Game2d::update. A click carries its screen position, which screen_to_world converts using the camera you drew with. Input state

Capture one frame

Pass a drawing closure and a path to render_to_png. It uses an offscreen GPU target and writes the completed RGBA image without opening a window. Offscreen rendering

draw → GPU target
readback → PNG

Features

Geometry

  • Rectangles and circles
  • Lines with a width

Sprites

  • RGBA or PNG texture input
  • Ordered, batched draws

Text

  • Printable Basic Latin glyphs
  • Bitmap scale and colour

Camera

  • Orthographic pan and zoom
  • World and screen conversion

Input

  • Pressed, held and released states
  • Text, clicks and scroll deltas

Output

  • Native window via Game2d
  • Offscreen PNG and screen-space HUD

Built with

Rust

wgpu and WGSL draw the frame. winit supplies window events, glam supplies vectors and font8x8 supplies the bitmap glyphs.

Quick start

With Rust 1.99 or newer and Cargo, add the crate to an existing Rust project.

cargo add --git https://github.com/mpge/realm-render realm-render

Use a machine with a compatible wgpu adapter. Put the example in src/main.rs and run cargo run to write spawn.png in the working directory. The windowed example draws through Game2d.

Learn more

Topic Reference
Drawing Textures · Camera · WGSL shader
Output Window runner · Offscreen pixel tests

License

MIT License, copyright © 2026 Matthew Gros.

Realm is an independent project and is not affiliated with or endorsed by Laravel Holdings Inc.

About

Realm 2D renderer and input on wgpu and winit

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages