screen-13 0.2.0

An easy-to-use 2D/3D rendering engine in the spirit of QBasic.
Documentation

Screen 13

Crates.io Docs.rs LoC

Screen 13 is an easy-to-use 2D/3D rendering engine in the spirit of QBasic.

Overview

Screen 13 provides a thin Vulkan 1.2 driver using smart pointers.

Features of the Vulkan driver:

  • Lifetime management calls free for you
  • Resource information comes with each smart pointer
  • Easy-to-use hashable/orderable types (no raw pointers)
  • CommandChain abstraction for executions outside of render passes

Example usage:

let window = ...your winit window...
let cfg = Default::default();
let desired_resolution = uvec2(320, 200);
let driver = Driver::new(&window, cfg, desired_resolution)?;

unsafe {
    // Let's start using the ash::Device driver provides
    driver.device.create_fence(....);
}

Render Graph

Screen 13 provides a fully-generic render graph structure for simple and statically typed access to all the resources used while rendering. The RenderGraph structure allows Vulkan smart pointer resources to be bound as "nodes" which may be used anywhere in a graph. The graph itself is not tied to swapchain access and may be used from a headless environment too.

Features of the render graph:

  • Compute, Graphic, and Ray-trace pipelines
  • You specify code which runs on input and creates output
  • Automatic Vulkan management (Render passes, subpasses, descriptors, pools, etc.)
  • Automatic render pass scheduling, re-ordering, merging, with resource aliasing

Example usage (See source for variable values):

render_graph
    .record_pass("Buffer A")
    .bind_pipeline(&buf_pipeline)
    .read_descriptor(0, input)
    .read_descriptor(1, noise_image)
    .read_descriptor(2, flowers_image)
    .read_descriptor(3, blank_image)
    .clear_color(0)
    .store_color(0, output)
    .push_constants(push_consts)
    .draw(move |device, cmd_buf, _| unsafe {
        device.cmd_draw(cmd_buf, 6, 1, 0, 0);
    });

Event Loop

Screen 13 provides an event loop abstraction which helps you setup and display images easily. Also included are keyboard, mouse, and typing input helpers.

Example usage:

fn main() -> Result<(), DisplayError> {
    let event_loop = EventLoop::new().build()?;

    event_loop.run(|frame| {
        // Draw using frame.render_graph here!
    })
}

Pak File Format

Programs made using Screen 13 are built as regular executables using an optional design-time asset baking process. Screen 13 provides all asset-baking logic and aims to provide wide support for texture formats, vertex formats, and other associated data. Baked assets are stored in .pak files.

Goals

Screen 13 aims to provide a simple to use, although opinionated, ecosystem of tools and code that enable very high performance portable graphics programs for developers using the Rust programming language.

Just Enough: Only core 2D and 3D rendering features are included, along with window event handling and window-based input. Additional things, such as an entity component system, physics, sound, and gamepad input must be handled by your code.

Quick Start

Included are some examples you might find helpful:

  • hello_world.rs — Displays a window on the screen. Please start here.
  • bake_pak.rs — Bakes a simple .pak file from a .toml definition.
  • shader-toy/ — Recreation of a two-pass shader toy using the original shader code.

See the example code for more information, including a helpful getting started guide.

NOTE: Required development packages and libraries are listed in the getting started guide. All new users should read and understand the guide.

Optional Features

Screen 13 puts a lot of functionality behind optional features in order to optimize compile time for the most common use cases. The following features are available.

  • pak (enabled by default) — Ability read .pak files.
  • bake — Ability to write .pak files, enables pak feature.

History

As a child I was given access to a computer that had GW-Basic; and later one with QBasic. All of my favorite programs started with:

CLS
SCREEN 13

These commands cleared the screen of text and setup a 320x200 256-color paletized video mode. There were other video modes available, but none of them had the 'magic' of 256 colors.

Additional commands QBasic offered, such as DRAW, allowed you to build simple games quickly because you didn't have to grok the entirety of compiling and linking. I think we should have options like this today, and so I started this project to allow future developers to have the ability to get things done quickly while using modern tools.

Insipirations

Screen-13 was built from the learnings and lessons shared by others throughout our community. In particular, here are some of the repositories I found useful:

  • Bevy: A refreshingly simple data-driven game engine built in Rust
  • Granite - Open-source Vulkan renderer
  • Kajiya - Experimental real-time global illumination renderer made with Rust and Vulkan