Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
MiniFB: Small cross platform library to create framebuffer to draw pixels in (github.com/emoon)
102 points by ingve on Aug 15, 2020 | hide | past | favorite | 23 comments


For Rust, there's the very similar https://github.com/parasyte/pixels. Unlike MiniFB, it doesn't handle windowing for you (you use winit/sdl2/glfw).

It's built over wgpu-rs, so it runs on Vulkan/Metal/DirectX12/WEBGPU. You can compile to wasm, and then run your game in the browser, which is neat. And you can add custom shaders on top.

I used it for my game, and was very happy with it https://github.com/JMS55/sandbox


There's already a version of minifb for Rust though: https://github.com/emoon/rust_minifb


I've used this library on a few occasions on personal projects, and once the necessary system deps are installed (just a few apt-get commands that are well-documented), it's worked pretty flawlessly. Fairly low boilerplate, good examples--I haven't had any regrets on deciding to use it.


Yes, that's also an option. I tried that initially for my game, but I ended up liking pixels better, in part due to the WASM and shader support.


Do you mean it will run on browsers when/if they enable webgpu, or does wgpu-rs have other browser compatible backends?


There's early support for an OpenGL backend, which can then run on WebGL.


It will run on (stable) browsers when the WEBGPU spec gets finished (it's in nightly for firefox/chrome right now).


I still miss the simplicity of Borland's BGI and somewhat happy with direction SDL_bgi is taking: http://libxbgi.sourceforge.net/ . Latest version has support to Broland's .CHR fonts and seeing those glyphs rendered on modern hardware after 30 years is very cool.

Disclaimer: I'm a contributor.


....the amount of times I have typed initgraph(&gdriver,&gmode,"");


This is cool!


Looks very similar to SDL (http://www.libsdl.org/). What's the difference?


SDL has more features: joystick/gamepad input, image loading from PNG/etc, scaling/rotating/overlapping images onto the framebuffer, multiple windows, touch events, audio, and a lot more[0]. And is GPU accelerated for 2d, or 3d with opengl.

It's more of a generic application framework which works well for games, whereas this seems to be more of put a window on a screen, fill pixels, and get mouse/KB/resize events.

http://wiki.libsdl.org/Introduction

SDL also has stuff that lets it work nicely with HiDPI screens.


I think SDL also mostly started like that (just a window where you fill pixels, and very basic kb/mouse events). You can also very easily use it just like that (which is why this looked so similar to me like MiniFB).

Then over time, more and more people used it, and had special request. E.g. to be able to setup an OpenGL context. Use gamepad input (as this was used mostly for games). Multiple windows. Etc.


SDL supports hardware acceleration (opengl: glx, wgl; vulkan; etc.). It also has its own drawing library, and generic platform abstraction library.


this is a great crate for doing quick prototypes, testing image processing and graphics ideas, or just to go back to 1990


One of the only nice things about X11 is that getting a drawing context and drawing lines and (unwrapped) text on it is super easy.


Feels a lot like raylib or sdl to me. Both of those projects are more about games and have other functionality.


So frustrating to see a graphics related tool not have any example screenshots in the README.


Is there something similar for JVM?


Oh wow, blast from the past!

Yes there was! I built something for the JVM, way back in the days as I wanted exactly this for my Zaurus (X11 'wasted' 800kb!)

My first pass was pure-Java as that was a thing back then, that and at 320x240 it was plenty fast enough; accessing the framebuffer as a random-access file and streaming from the input devices worked well enough. This also made it easy to support VNC. The BDF font renderer was fun to write and eventually got re-used in JNode and I think there was query about Maemo too.

The project went through a few name changes (fbAWT, Odonata, FBToolkit)[0] and later also formed part of a collaboration with Guillaume Legris refactoring the rendering plugins and adding microbackend support.

Guillaume added native libraries to speed things up for larger screens and generally took over maintenance; my life had got a bit busy.

FBToolkit was also accepted as one of the projects used to try out the emerging OpenJDK open collaboration process [1].

Happy to answer questions if I remember that far back :-)

[0] fbAWT, Odonata, FBToolkit (zips actually work?!): http://web.archive.org/web/20060821072155/http://odonata.tan...

[1] Framebuffer Toolkit: http://openjdk.java.net/projects/fbtoolkit/


Isn't Graphics2D quite capable?


Something cross-platform would be nice, and without some quirks (e.g. can draw a line fine, but to draw a pixel an extra object layer is needed).


nice. I am writing a hobby OS for RISC-V and I might implement this in it.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: