# Build simple GUIs with MiniFB

**URL:** <https://discourse.julialang.org/t/build-simple-guis-with-minifb/46195>\
**Category:** General Usage\
**Tags:** announcement, guis\
**Created:** [September 7, 2020, 12:33pm UTC](https://discourse.julialang.org/t/build-simple-guis-with-minifb/46195 "2020-09-07T12:33:54Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [September 11, 2020, 12:20pm UTC](https://discourse.julialang.org/t/build-simple-guis-with-minifb/46195/21 "2020-09-11T12:20:42Z")

</div>

haha, yes - it’s just a quick copy/paste of a bit of old code to see if it worked…

[https://gist.github.com/cormullion/e264603402792674ff1058660f34bb59](https://gist.github.com/cormullion/e264603402792674ff1058660f34bb59)

---

<div class="post-metadata">

**Author:** ![affans](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/affans/32/11911_2.png) [@affans](https://discourse.julialang.org/u/affans)\
**Post date:** [September 11, 2020, 12:25pm UTC](https://discourse.julialang.org/t/build-simple-guis-with-minifb/46195/22 "2020-09-11T12:25:32Z")

</div>

I know very little about how GUIs and frame buffers work, but instead of the CPU, can a GPU be used to compute the frame buffer instead? I would imagine that’s much faster? Would the transfer of data from GPU to CPU really slow it down?

---

<div class="post-metadata">

**Author:** ![Raf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raf/32/3383_2.png) [@Raf](https://discourse.julialang.org/u/Raf)\
**Post date:** [September 11, 2020, 12:36pm UTC](https://discourse.julialang.org/t/build-simple-guis-with-minifb/46195/23 "2020-09-11T12:36:13Z")

</div>

I’m getting 140fps displaying 600\*400 `Life` with DynamicGrids.jl.

Seems very stable so far. This is awesome.

---

<div class="post-metadata">

**Author:** ![avik](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/avik/32/17_2.png) [@avik](https://discourse.julialang.org/u/avik)\
**Post date:** [September 11, 2020, 6:08pm UTC](https://discourse.julialang.org/t/build-simple-guis-with-minifb/46195/24 "2020-09-11T18:08:40Z")

</div>

This looks really cool, and I’m so glad you are playing 😃. It’s always been on the back of my mind that MiniFB would make a great backend for Luxor, allowing Luxor to provide realtime visualisations, and simple interactivity. It’s really nice to see that the integration is so simple.

If you don’t mind, I’d like to add this code as an example in the MiniFB repo. Thanks!  
.  
Avik

---

<div class="post-metadata">

**Author:** ![avik](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/avik/32/17_2.png) [@avik](https://discourse.julialang.org/u/avik)\
**Post date:** [September 11, 2020, 6:12pm UTC](https://discourse.julialang.org/t/build-simple-guis-with-minifb/46195/25 "2020-09-11T18:12:24Z")

</div>

> can a GPU be used to compute the frame buffer instead?

Yes, of course you could. Things like GLFW mentioned upthread help you do that, Many parts of modern operating systems do frame buffer calculations on the GPU. However, the point of MiniFB is that it is very simple, and that is it’s appeal. So it is good that it does not have any advanced functionality – if you wanted that, there are many other existing libraries that do those things very well.

---

<div class="post-metadata">

**Author:** ![viralbshah](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/viralbshah/32/54_2.png) [@viralbshah](https://discourse.julialang.org/u/viralbshah)\
**Post date:** [September 11, 2020, 8:46pm UTC](https://discourse.julialang.org/t/build-simple-guis-with-minifb/46195/26 "2020-09-11T20:46:05Z")

</div>

Just tried it out. So straightforward and easy to get the example working. Suggestion - put the random noise second and the colorful animation first in the manual.

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [September 12, 2020, 7:43am UTC](https://discourse.julialang.org/t/build-simple-guis-with-minifb/46195/27 "2020-09-12T07:43:26Z")

</div>

Yes, it’s a nice simple extension that will be very useful. I’ve tidied the code a bit (removed global variables…:)) so I’m very happy for you to use it…!

---

<div class="post-metadata">

**Author:** ![jonathanBieler](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@jonathanBieler](https://discourse.julialang.org/u/jonathanBieler)\
**Post date:** [September 12, 2020, 12:28pm UTC](https://discourse.julialang.org/t/build-simple-guis-with-minifb/46195/28 "2020-09-12T12:28:35Z")

</div>

I think most GUI frameworks use complicated scenes structure to avoid redrawing as much as possible, that’s why they were already quite snappy 20 years ago. That said I think there’s some moderns libraries that tries the “redraw everything” route on the GPU, which simplify things but also risk to make your laptop sound like a reactor.

---

<div class="post-metadata">

**Author:** ![xiaodai](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xiaodai/32/15937_2.png) [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Post date:** [September 15, 2020, 2:29am UTC](https://discourse.julialang.org/t/build-simple-guis-with-minifb/46195/30 "2020-09-15T02:29:10Z")

</div>

Not a MiniFB question as such but it works well even in WSL2 which is great.

But if I run the MiniFB code in VSCODE’s repl by starting “julia” from bash then MiniFB.jl works via the xserver that I set up

But if I run it through the Julia extension and send code to the Julia repl via Ctrl-Enter then the windows doesn’t show up. And there is no error message.

Just in case someone has this worked out. Otherwise I will file an issue with vscode extension later since it’s not an issue with VScode but how vscode julia start the julia repl.

---

<div class="post-metadata">

**Author:** ![avik](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/avik/32/17_2.png) [@avik](https://discourse.julialang.org/u/avik)\
**Post date:** [September 23, 2020, 9:44am UTC](https://discourse.julialang.org/t/build-simple-guis-with-minifb/46195/31 "2020-09-23T09:44:27Z")

</div>

There is a new version that makes it easier to set callbacks (Thanks @jebej) and some improved documentation, which includes @Cormullion’s amazing Guilloche example.

[https://juliahub.com/docs/MiniFB/](https://juliahub.com/docs/MiniFB/)

Regards

Avik

---

<div class="post-metadata">

**Author:** ![purplishrock](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/purplishrock/32/13451_2.png) [@purplishrock](https://discourse.julialang.org/u/purplishrock)\
**Post date:** [September 23, 2020, 6:29pm UTC](https://discourse.julialang.org/t/build-simple-guis-with-minifb/46195/32 "2020-09-23T18:29:34Z")

</div>

and therein lies the question.

Why didn’t miniFB just build around OpenGL using GLFW in the first place ?

At this point OpenGL is ubiquitous and i’ve never had problems bringing up GLFW in any language I’ve tried it in.

Then you would have the GPU taking care of the bit display (which is a big win!) AND you could use miniFB with 3D graphics.

I absolutely LOVE the idea of MiniFB, but I really think this is an interface problem. We didn’t need a miniFB library, we need a MiniFB interface sitting on top of something like GLFW.

This sounds like a comment that should make me volunteer to write some code, doesn’t it ? 😉

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [September 23, 2020, 6:57pm UTC](https://discourse.julialang.org/t/build-simple-guis-with-minifb/46195/33 "2020-09-23T18:57:01Z")

</div>

Well, that already exist in big parts in Makie & GLMakie, which is exactly this…  
Could be more modular to tailor to use cases outside plotting - I never got around to do these refactors, but should be fairly trivial to factor out the windowing bits.

Btw, I also tried to make Observables.jl the goto signal abstractions for UI, which is also used across the Interact ecosystem & in WidgetsBase.jl.  
So it’d be quite easy to swap out the windowing library, and make other widget libraries rely on a window event struct like: [https://github.com/JuliaPlots/AbstractPlotting.jl/blob/master/src/types.jl#L23](https://github.com/JuliaPlots/AbstractPlotting.jl/blob/master/src/types.jl#L23)

---

<div class="post-metadata">

**Author:** ![purplishrock](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/purplishrock/32/13451_2.png) [@purplishrock](https://discourse.julialang.org/u/purplishrock)\
**Post date:** [September 23, 2020, 7:00pm UTC](https://discourse.julialang.org/t/build-simple-guis-with-minifb/46195/34 "2020-09-23T19:00:44Z")

</div>

It’s funny you should mention this , because i often look at Makie wishing i could use it as a general purpose 3D graphics library.

Admittedly I haven’t looked very hard to see if this is possible, I tend to get lost as i go through the code. it’s kind of a large project isn’t it ? lol

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [September 23, 2020, 7:05pm UTC](https://discourse.julialang.org/t/build-simple-guis-with-minifb/46195/35 "2020-09-23T19:05:44Z")

</div>

Yeah, I does seem so^^  
I can see how it would be hard to see from outside, but the core could be factored out quite easily in a week or so (by me I guess)…  
I currently in the feature phase, so no backend work will be done for quite some time… Maybe next summer or so, I will have time to factor out the OpenGL parts nice and square 😉

I plan to heavily use ShaderAbstraction, to make a framework that works nicely with WebGL/OpenGL/Vulkan alike 😉

---

<div class="post-metadata">

**Author:** ![jebej](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jebej/32/1784_2.png) [@jebej](https://discourse.julialang.org/u/jebej)\
**Post date:** [September 23, 2020, 8:02pm UTC](https://discourse.julialang.org/t/build-simple-guis-with-minifb/46195/36 "2020-09-23T20:02:39Z")

</div>

> [@purplishrock](#):
>
> Then you would have the GPU taking care of the bit display (which is a big win!) AND you could use miniFB with 3D graphics.

If you just want to display an image you have in RAM you shouldn’t really need to go through the GPU. But yeah, for more complex application it makes sense to use the GPU, it’s just not what MiniFB is for.

---

<div class="post-metadata">

**Author:** ![jpsamaroo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jpsamaroo/32/46804_2.png) [@jpsamaroo](https://discourse.julialang.org/u/jpsamaroo)\
**Post date:** [September 23, 2020, 8:50pm UTC](https://discourse.julialang.org/t/build-simple-guis-with-minifb/46195/37 "2020-09-23T20:50:48Z")

</div>

I believe the point of minifb is minimalism and reduction of dependencies. GLFW and OpenGL rely on having a reasonably large number of libraries available and working (which isn’t always the easiest to set up if you’re on a less common system), but minifb relies on much fewer working pieces. For many simple projects, especially those which don’t need a GPU for rendering (or do, but don’t mind the extra data copy), minifb is more than sufficient.

---

<div class="post-metadata">

**Author:** ![scelles](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/scelles/32/220408_2.png) [@scelles](https://discourse.julialang.org/u/scelles)\
**Post date:** [November 16, 2021, 8:03pm UTC](https://discourse.julialang.org/t/build-simple-guis-with-minifb/46195/38 "2021-11-16T20:03:01Z")

</div>

Hello,

I wonder if MiniFB.jl can be used as backend for GUI librairies such as Nuklear.jl [https://github.com/Gnimuc/Nuklear.jl](https://github.com/Gnimuc/Nuklear.jl) or CImGui.jl [GitHub - Gnimuc/CImGui.jl: Julia wrapper for cimgui](https://github.com/Gnimuc/CImGui.jl)  
Pinging @Gnimuc

Kind regards

---

<div class="post-metadata">

**Author:** ![Gnimuc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gnimuc/32/2194_2.png) [@Gnimuc](https://discourse.julialang.org/u/Gnimuc)\
**Post date:** [November 17, 2021, 1:28pm UTC](https://discourse.julialang.org/t/build-simple-guis-with-minifb/46195/39 "2021-11-17T13:28:07Z")

</div>

In the 3D rendering mode, it seems that somehow we can draw imgui’s components over MiniFB’s canvas.

---

<div class="post-metadata">

**Author:** ![scelles](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/scelles/32/220408_2.png) [@scelles](https://discourse.julialang.org/u/scelles)\
**Post date:** [November 17, 2021, 1:43pm UTC](https://discourse.julialang.org/t/build-simple-guis-with-minifb/46195/40 "2021-11-17T13:43:21Z")

</div>

An other question… I’m wondering if Julia can draw on Linux framebuffer (to build Linux application with GUI but without the need of a desktop environment). In such a case I wonder if MiniFB couldn’t be used as a “draft” for such development and turn to Linux framebuffer display when application is nearly finished. Developing this way could help to provide embedded application written with Julia. Creating a minimal Linux distribution with Julia could be an other interesting work.

---

<div class="post-metadata">

**Author:** ![Freya\_the\_Goddess](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/freya_the_goddess/32/36835_2.png) [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Post date:** [June 29, 2022, 2:52pm UTC](https://discourse.julialang.org/t/build-simple-guis-with-minifb/46195/41 "2022-06-29T14:52:43Z")

</div>

@scelles your idea is interesting, I am using Linux. Instead of using KDE or Xfce we just need terminal but everything can be plotted in terminal. Work with terminal is faster, we never need mouse anyway, work faster.

[Previous page](https://discourse.julialang.org/t/build-simple-guis-with-minifb/46195.md?page=1)

[Next page](https://discourse.julialang.org/t/build-simple-guis-with-minifb/46195.md?page=3)
