September 8th, 2024

Microui+fenster=Small GUI

Max Bernstein discusses a new backend integrating the fenster and microui libraries for simplified GUI development. The project is open-source, inviting contributions while still needing refinements in rendering and shortcuts.

Read original articleLink Icon
Microui+fenster=Small GUI

Max Bernstein discusses the development of a small GUI solution using two libraries: fenster and microui. Fenster, created by Serge Zaitsev, is a lightweight 2D canvas library that simplifies drawing pixels on the screen without the complexities of SDL or OpenGL. It is a header-only C/C++ library with around 400 lines of code, compatible with WinAPI, Cocoa, and X11, and supports keyboard and mouse input. Microui, developed by rxi, allows for the creation of GUI elements like menus and buttons, translating them into a simple drawing bytecode, but it typically relies on SDL as a backend. Bernstein and his collaborator Kartik created a fenster backend for microui, resulting in a compact file of less than 250 lines that integrates the two libraries. This new backend simplifies the rendering process and includes additional functions for handling input. While the project is functional, there are still aspects to refine, such as rendering logic and keyboard shortcuts. The blog post encourages readers to explore the project and contribute to its open-source development.

- Fenster is a lightweight 2D canvas library for simple pixel drawing.

- Microui translates GUI elements into drawing bytecode and is typically used with SDL.

- A new backend was created to integrate microui with fenster, simplifying GUI development.

- The project is open-source, inviting contributions and improvements.

- There are still features to refine, including rendering logic and keyboard shortcuts.

Link Icon 12 comments
By @mark_l_watson - about 1 month
Very cool project. I followed some link’s to Max’s personal web site: a renaissance man!

Many decades ago when I worked on a C++ team we hired very smart but not C++ guru employees. I wrote a portable graphics library so team members could write X11 apps without learning details that domain experts really didn’t need to learn. With my company’s permission, I rewrote that code on my own time and added support for Mac, and Windows. That code became the two editions of my Portable GUIs with C++ books for McGraw-Hill.

Sorry to rant so much off topic, but mostly being retired now I have been thinking of getting back into C++ (I usually use Lisp languages and Python now). I think this very cool project will be the start of a few very fun days of playing with C++ again.

By @strlenf - about 1 month
You probably want to use simd-optimized pixman[1] for rendering rectangles and glyphs. There is also luigi[2] which draws without opengl and written in C.

[1] https://github.com/freedesktop/pixman [2] https://github.com/nakst/luigi

By @jll29 - about 1 month
Such boilerfree graphics is important, for example for educational purpose where you don't want to be distracted by having to explain what an "allocator" or a "handle" are.

Also, to keep the core drawing code short so that it can be fully listed on a blog post or in a print magazine.

What I liked is is a self-sufficient set of files that compile immediately without any dependency issues (even on the Mac). There should be more work like that:

- making it even easier to use

- making it simpler and simpler

- making it faster

- making the library footprint smaller

Thanks!

By @rwbt - about 1 month
It uses Microui lib written by rxi. Checkout other single header only C libs written by rxi[0]. They're really elegant C in my view. [0] - https://github.com/rxi
By @zamadatix - about 1 month
This is great, particular the fenster side which is truly about as "If you remember Borland BGI or drawing things in QBASIC or INT 10h- you know what I mean" as I've ever seen for cross platform C.

Microui seems very cool as well but not in a "the comments section is very often longer than this code" sense. Still, I'll definitely be poking around with this a bit more for the novelty.

By @zem - about 1 month
love it :) next step, some tiny scripting language bindings? s7 would fit in well e.g. https://ccrma.stanford.edu/software/snd/snd/s7.html
By @Esras - about 1 month
Cool project! Graphics programming is _hard_ and anything to make it easier is welcome.

Maybe a dumb question, but why not Dear ImGui (https://github.com/ocornut/imgui). "It's way too big and complex" is a completely reasonable answer, but I found it fantastic for debug menus, and there are a few applications that have used it as their _main_ GUI (Ship of Harkinian as an example).

(Edit for fixing the name of the project)

By @movedx - about 1 month
Here's something I struggle with: where do I install the C libraries too and then how do you include them? I always want to try these really cool libs, but then I remember that although I know C well enough to try them, I've not solved the ecosystem and dependency management side of developing in C.

Any suggested reading?

By @throwaway47765 - about 1 month
This sounds awesome. I can't wait to use it with Lua, like lua-fenster.

Or, can I already?

By @a1o - about 1 month
This is great for some things, is there something small like fenster but written in C?

Or is it just the header there? I see there is both a Cpp and a Go file there too, so I am a bit unsure which does what.

By @ezekielmudd - about 1 month
I like it! Bravo!
By @icar - about 1 month
I wonder if they could add Wayland…