Skip to main content

Crate denise_winit

Crate denise_winit 

Source
Expand description

Desktop development and preview backend for Denise.

This backend exists so the core abstraction can be proven — and iterated on — without a Raspberry Pi on the desk. It is not a deployment target: shipping Denise on a desktop means shipping a compositor you did not need.

Pixels come from the software rasteriser into a buffer the compositor uploads — or, behind the gpu feature and Present::Gpu, from denise-wgpu into a swapchain. The second is for the designer on a large display; an application chooses it per window and draws through DeniseApp::paint, which is the same call on either path.

use denise::{Color, DamageTracker, Frame, InputEvent, Rect};
use denise_render::Canvas;
use denise_winit::{DeniseApp, WindowConfig, run};

struct Hello;

impl DeniseApp for Hello {
    fn update(&mut self, _events: &[InputEvent], _damage: &mut DamageTracker) {}

    fn render(&mut self, frame: &mut Frame<'_>, damage: &[Rect]) {
        let mut canvas = Canvas::new(frame);
        for region in damage {
            canvas.with_clip(*region).clear(Color::from_rgb888(0x1E1E2E));
        }
    }
}

run(WindowConfig::default(), Hello).unwrap();

Structs§

GpuSurface
A winit window drawn into through denise-wgpu.
Waker
Wakes a running loop from any thread, so every window is asked for a frame as soon as one can be drawn.
WindowConfig
How the preview window is created.
WindowRequest
A window the application wants opened, and the application that will run in it.
WinitSurface
A resizable window surface backed by a persistent shadow buffer.

Enums§

Error
Failures from this backend.
Modality
How a secondary window relates to the one that opened it.
Present
What draws a window’s pixels.

Traits§

DeniseApp
An application driven by this backend.

Functions§

run
Opens a window and runs app until it exits.
run_with
Opens a window and builds the application once the surface behind it is known.