7 releases

0.3.5 Feb 27, 2024
0.3.4 Feb 16, 2024
0.2.4 Feb 16, 2024
0.1.2 Feb 13, 2024

#76 in Rendering

42 downloads per month

Custom license

31KB
707 lines

kopki

Simple graphical engine, based on wgpu and winit.

Minimal Example

use kopki::{
    wgpu, winit, core::context::Context
};

use winit::{
    event::{Event, WindowEvent},
    event_loop::EventLoop,
    window::WindowBuilder
};

use kopki::{
    wgpu, winit, Context
};

use winit::{
    event::{Event, WindowEvent},
    event_loop::EventLoop,
    window::WindowBuilder
};

fn main() {
    let ctx = Context::blocked_new();
    let event_loop = EventLoop::new().unwrap();
    let window = WindowBuilder::new()
    .build(&event_loop).expect("failed to build");
    let mut surface = ctx.create_surface(&window);

    _ = event_loop.run(move |event,elwt| {
        match event {
            Event::AboutToWait => {
                window.request_redraw();
            }
            Event::WindowEvent { event, .. } => {
                match event {
                    WindowEvent::CloseRequested => elwt.exit(),
                    WindowEvent::RedrawRequested => {
                        ctx.render(
                            &surface,&[],&[],
                            wgpu::Color {
                                r: 0.0,
                                g: 0.0,
                                b: 0.0,
                                a: 0.0,
                            }
                        )
                    }
                    WindowEvent::Resized(size) => {
                        surface.resize(&ctx, size)
                    }
                    _ => ()
                }
            }
            _ => ()
        }
    })
}

for more examples look for the examples folder in the github repo

Dependencies

~8–45MB
~749K SLoC