3 unstable releases

Uses new Rust 2024

0.2.0 Jan 13, 2026
0.1.1 Jul 9, 2025
0.1.0 Jul 8, 2025

#2068 in Graphics APIs

MIT/Apache

21KB
240 lines

Examples

// Minimal example of a WGPU/Winit application using Wume
// This example creates a window and renders a solid color to it.

use std::sync::Arc;
use wume::{wgpu, winit};

use winit::application::ApplicationHandler;
use winit::window::Window;

struct App {
    context: wume::WgpuContext,
}

impl From<Arc<Window>> for App {
    fn from(window: Arc<Window>) -> Self {
        let context = wume::WgpuContext::new(window).unwrap();
        Self { context }
    }
}

impl ApplicationHandler for App {
    fn resumed(&mut self, _event_loop: &winit::event_loop::ActiveEventLoop) {}

    fn window_event(
        &mut self,
        event_loop: &winit::event_loop::ActiveEventLoop,
        _window_id: winit::window::WindowId,
        event: winit::event::WindowEvent,
    ) {
        use winit::event::WindowEvent;
        match event {
            WindowEvent::CloseRequested => {
                event_loop.exit();
            }

            WindowEvent::Resized(size) => {
                self.context.resize(size.width, size.height);
            }

            WindowEvent::RedrawRequested => {
                let clear_color = wgpu::Color { r: 0.5, g: 0.2, b: 0.2, a: 1.0, };
                self.context.simple_frame(clear_color, |_render_pass| {
                    // nothing to do here, simple_frame handles clearing the screen
                });
            }
            _ => {}
        }
    }
}

fn main() {
    let window_attributes = winit::window::WindowAttributes::default();
    wume::lazy_run::<App>(Some(window_attributes)).unwrap()
}

Dependencies

~10–32MB
~397K SLoC