#windowing #window #framebuffer

minifb

Cross-platform window setup with optional bitmap rendering

33 releases

0.10.7 Aug 10, 2018
0.10.6 May 18, 2018
0.10.4 Jan 8, 2018
0.10.3 Oct 1, 2017
0.5.0 Mar 4, 2016

#9 in Rendering

Download history 128/week @ 2018-05-18 129/week @ 2018-05-25 255/week @ 2018-06-01 185/week @ 2018-06-08 233/week @ 2018-06-15 79/week @ 2018-06-22 254/week @ 2018-06-29 81/week @ 2018-07-06 27/week @ 2018-07-13 136/week @ 2018-07-20 143/week @ 2018-07-27 162/week @ 2018-08-03 378/week @ 2018-08-10

730 downloads per month

Crates.io Build Status Build Status Documentation

minifb is a cross platform library written in Rust and that makes it easy to setup a window and to (optional) display a 32-bit pixel buffer. It also makes it easy to get input from keyboard and mouse. An example is the best way to show how it works:

Changelog

Usage

# Cargo.toml
[dependencies]
minifb = "0.10"

Example

extern crate minifb;

use minifb::{Key, WindowOptions, Window};

const WIDTH: usize = 640;
const HEIGHT: usize = 360;

fn main() {
    let mut buffer: Vec<u32> = vec![0; WIDTH * HEIGHT];

    let mut window = Window::new("Test - ESC to exit",
                                 WIDTH,
                                 HEIGHT,
                                 WindowOptions::default()).unwrap_or_else(|e| {
        panic!("{}", e);
    });

    while window.is_open() && !window.is_key_down(Key::Escape) {
        for i in buffer.iter_mut() {
            *i = 0; // write something more funny here!
        }

        // We unwrap here as we want this code to exit if it fails. Real applications may want to handle this in a different way
        window.update_with_buffer(&buffer).unwrap();
    }
}

Status

Currently Mac, Redox, Linux and Windows (64-bit and 32-bit) are the current supported platforms. X11 (Linux/FreeBSD/etc) support has been tested on Ubuntu (x64). Bug report(s) for other OSes/CPUs are welcome!

Build instructions

cargo build
cargo run --example noise

This will run the noise example which should look something like this (Mac screenshot)

mac_screenshot

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

MIT/Apache-2.0 license

Dependencies

  • build build.rs
  • build cc 1.0

Reverse deps