Build simple GUIs with MiniFB

avik
Mon, 07 Sep 2020 12:33:54 +0000
General Usage

I’d like to announce a little vacation project of mine. I’ve just released the first version of MiniFB.jl, a Julia wrapper around a small C library called MiniFB.

MiniFB is possibly the simplest way to get a graphical window up on a screen in a cross platform way on modern OSs. The basic idea is to create a 32bit buffer of pixels yourself, and pass it on to the framework to display. So you’d write code like this:

window = mfb_open_ex("my display", 800, 600, MiniFB.WF_RESIZABLE);
while true
	#TODO: add some fancy rendering to the buffer of size 800 * 600
	state = mfb_update(window, buffer);
	if state < 0
	    break
     end
end

Note that this is not a full fledged GUI framework – in particular, there is no widget library. There is however support for mouse and keyboard input, so pretty sophisticated UIs are indeed possible.

So, in summary, if you want to throw up an image viewer in a few dozen lines of code, with a TTFP of 1.5 seconds* (after precompilation), this may be what you need.

Documentation here: https://juliahub.com/docs/MiniFB/

Regards

Avik

*(I fully expect ttfp to go down to less than a second after Elliot’s chages to jll loading in 1.6)

41 posts - 16 participants