• Stars
    star
    887
  • Rank 51,456 (Top 2 %)
  • Language
    Rust
  • License
    MIT License
  • Created about 9 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Cross platfrom window and framebuffer crate for Rust

Build Status Crates.io 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. Notice that minifb is primary designed for prototyping and may not include all the features found in full window handling libraries. An example is the best way to show how it works:

Changelog

Usage

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

Example

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

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);
    });

    // Limit to max ~60 fps update rate
    window.limit_update_rate(Some(std::time::Duration::from_micros(16600)));

    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, WIDTH, HEIGHT)
            .unwrap();
    }
}

Status

Currently macOS, Linux and Windows (64-bit and 32-bit) are the current supported platforms. X11 (Linux/FreeBSD/etc) support has been tested on Ubuntu (x64). Linux Wayland support is also available. Bug report(s) for other OSes/CPUs are welcome! Notice: That after 0.13 Redox hasn't been updated and some work is required to get that working again. PR are welcome.

Build instructions

On Linux you may need to install these dependencies first:

sudo apt install libxkbcommon-dev libwayland-cursor0 libwayland-dev
cargo build
cargo run --example noise

This will run the noise example

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.

More Repositories

1

minifb

MiniFB is a small cross platform library to create a frame buffer that you can draw pixels in
C
969
star
2

ProDBG

Debugging the way it's meant to be done
C++
513
star
3

dynamic_reload

Dynamic reloading of shared libraries
Rust
351
star
4

rocket

GNU Rocket Git mirror
Lua
109
star
5

bgfx-rs

Rust wrapper for BGFX
Rust
84
star
6

Score

Score! is a new programming language based on the ideas from GOAL
Common Lisp
46
star
7

Rute

Rute is a UI library implemented on top of Qt
Rust
39
star
8

evfs

Virtual File System written in Rust
Rust
37
star
9

remotery-rs

Realtime CPU Profiler with web browser viewer
Rust
31
star
10

AmigaHunkParser

Parser written in C for Amiga Hunk (executable) files
C
13
star
11

cfixed-string

Pass Rust strings to C with potentially not needing heap allocation
Rust
13
star
12

ps2dev_tools

Binaries of the ps2dev toolchain (for win32 and osx)
C
12
star
13

remotelink

Remote running executables on a Linux style system
Rust
9
star
14

wrui

C wrapper for UI libraries (like Qt, wxWidgets, dear imgui) with a common C API
Lua
8
star
15

sico

SICO - SImple COmpute
Lua
8
star
16

Arika

Arika is a cross-platform UI library written in C and Lua
C
7
star
17

usb2snes

Rust crate for talking with SD2SNES over USB
Rust
6
star
18

csimd

Cross platform SIMD intrinsics in C
5
star
19

bgfx-sys

Rust FFI bindings for bgfx
C
5
star
20

m68k_cpu_tester_api

Uses data from the (Win)UAE cpu test generator
C
4
star
21

flowi

Flowi is a research UI aimed at speed, good looks and ease of use
C
4
star
22

amiga_hunk_parser

Parses Amiga exceutable (hunk files) in Rust
Rust
4
star
23

text_render

Fiddling around with Text Rendering to make something that looks less crap
Rust
4
star
24

modland_hash

Rust
3
star
25

68k_disassemble_gen

68k disassembler for C made in Rust
Rust
3
star
26

dotvim

vimconfig files and plugins
Vim Script
2
star
27

prodbg_addons

Addons/Plugins to ProDBG
C++
2
star
28

ssagen

Playing around with SSA form
C
2
star
29

wrui_rust

Rust wrapper for WRUI
Rust
2
star
30

prodbg-web

Webpages for ProDBG
JavaScript
2
star
31

68k_documentation_gen

Generate documentation including cycle tables for Motorola 680x0
C
2
star
32

docking_system

Docking system based on the i3wm code
Lua
1
star
33

apigen

Basic API/data description lang + parser that can be used for generating API/data interfaces, etc
Rust
1
star
34

extract-opencl-docs-dash

Script that is used for generating OpenCL docs for Dash
Python
1
star
35

bgfx-rs-bindgen

Rust binding generator for bgfx
Rust
1
star
36

IMCocoa

Experimental project to try to do Immediate mode GUI in Cocoa (Mac OS X)
Objective-C
1
star
37

flowi_rust

Lets do Flowi in Rust instead
1
star
38

prodbg-third-party

Third Party libs used by ProDBG
C++
1
star
39

dms-rs

DMS (Amiga Disk Masher System) unpacker written in Rust
Rust
1
star
40

anidb-rs

Rust crate that makes using the AniDB API easier
Rust
1
star
41

fx68x_verilator

verilator testing of fx68k
C++
1
star
42

scintilla

Scintilla is a free source code editing component.
C++
1
star