Skip to content
This repository was archived by the owner on Jul 8, 2025. It is now read-only.

pastthepixels/softbuffer-quickstart

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Softbuffer Quickstart

A wrapper that makes using Softbuffer as easy as using minifb.

Running the Softbuffer example in softbuffer-quickstart:

use softbuffer_quickstart::{SoftbufferWindow, WindowProperties};
use winit::event::WindowEvent;

fn main() {
    let mut window = SoftbufferWindow::new(WindowProperties::default());
    window
        .run(move |window, event| match event {
            WindowEvent::RedrawRequested => {
                let (width, height) = window.inner_size();
                let mut buffer = window.buffer_mut();
                for index in 0..(width * height) {
                    let y = index / width;
                    let x = index % width;
                    let red = x % 255;
                    let green = y % 255;
                    let blue = (255 - (red + green).min(255)) % 255;

                    buffer[index] = (blue | (green << 8) | (red << 16)).try_into().unwrap();
                }
            }
            _ => (),
        })
        .expect("window can't run :(");
}

I wanna know more!

cargo add softbuffer_quickstart and read the documentation at doc/!

Contributing

PRs are welcome! As with any of my other projects it might take a while for me to respond to issues/pull requests. I recommend not squashing your commits before you submit a PR as doing so makes it a bit harder to review your code.
I'm looking for any ways to boost performance as much as possible while making the library simpler and more intuitive.

Ideas:

  • Adding icons to WindowProperties (probably good for new contributors)
  • Supporting compiling to wasm (hell)

About

Attempt at a minifb-like interface for softbuffer and winit

Topics

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •  

Languages