not connected to this, but i wish i would find a c code example on how to draw a line with a width, without antialias while only setting each pixel once. this seems to be a real hard problem.
40 years ago, I cut my teeth on graphics programming in x86 assembly language and Turbo Pascal. Little graphical plots are just a really fun way to learn a language and programming concepts.
This is exactly what I want to practice some Zig programming.
> That's not a GUI. It's something a GUI might be implemented in.
A GUI library is indeed not a GUI, but a library with which one might implement a GUI.
Usually, a GUI library does have things like actual controls implemented, but then most GUI libraries tend to present themselves as something closer to complete than most minimal.
It is unusual but not unreasonable to describe the combination of cross-platform canvas + keyboard/mouse events + audio playback as the “most-minimal GUI library”.
The first is the obvious typo around `sizeof`, which I didn't even see at first (edit: this).
The second is that code will only work for 8-bit colors, i.e. only the 8 (technically CHAR_BIT, "a byte") least-significant bits of `rgb` will be used. This is a quirk of the `memset()` standard C function, which has the prototype:
void *memset(void s[.n], int c, size_t n);
but then the man page [1] says:
The memset() function fills the first n bytes of the memory area pointed to by s with the constant byte c.
Looks neat! I’m using C in a little side project and it would benefit from a simple GUI, let’s see what I can do with this. Also, just a recommendation but there isn’t even a single screenshot and I’d say that’s pretty important in a GUI library.
IMO this is a mistake. The most popular platform in the world does not allow using a polling loop. You can hack things to simulate it but eventually you'll run into where this will break for you. Better to start with something more forward compatible.
The Web runs C via WebAssembly, but if you're porting a polling loop app you're going to have a bad time. Conversely, if you start with an event driven app then you lose nothing but gain portability.
The most popular platform in the world does not allow using a polling loop
I don't know what that means, but just because something else doesn't use a polling loop doesn't mean it's a mistake or the wrong fit.
Something like this so simple there is likely to be a lot that gets done inside the main loop, not the least of which is drawing into the buffer which is most of the point.
That's not surprising as Afrikaans is highly related to Dutch which is in turn highly related to German. In this case it all comes from the Latin fenestra.
The problem is that the title says "cross-platform GUI", so some people would expect, you know, a GUI - windows, menus, text, buttons, sliders, scrollbars, input fields, etc...
This is more like a cross platform canvas on which you can draw.
Raylib was my goto for that, but an alternative can't hurt, I guess ?
not connected to this, but i wish i would find a c code example on how to draw a line with a width, without antialias while only setting each pixel once. this seems to be a real hard problem.
You want to define a parallelogram or rectangle, turn it into edge equations, then iterate the spans.
Alternative is bresenham then for each point iterate a span in the minor axis.
40 years ago, I cut my teeth on graphics programming in x86 assembly language and Turbo Pascal. Little graphical plots are just a really fun way to learn a language and programming concepts.
This is exactly what I want to practice some Zig programming.
That's not a GUI. It's something a GUI might be implemented in.
> That's not a GUI. It's something a GUI might be implemented in.
A GUI library is indeed not a GUI, but a library with which one might implement a GUI.
Usually, a GUI library does have things like actual controls implemented, but then most GUI libraries tend to present themselves as something closer to complete than most minimal.
It is unusual but not unreasonable to describe the combination of cross-platform canvas + keyboard/mouse events + audio playback as the “most-minimal GUI library”.
There's an accompanying blog post at https://zserge.com/posts/fenster/
This author has some pretty cool stuff, like a tiny alternative to Firebase https://zserge.com/posts/pennybase/
There is at least two bugs in the blog post, here:
Next simple task would be to fill the complete framebuffer with a solid colour:
The first is the obvious typo around `sizeof`, which I didn't even see at first (edit: this).The second is that code will only work for 8-bit colors, i.e. only the 8 (technically CHAR_BIT, "a byte") least-significant bits of `rgb` will be used. This is a quirk of the `memset()` standard C function, which has the prototype:
but then the man page [1] says:The memset() function fills the first n bytes of the memory area pointed to by s with the constant byte c.
[1]: https://man7.org/linux/man-pages/man3/memset.3.html
A windowing library, not a GUI library.
Looks neat! I’m using C in a little side project and it would benefit from a simple GUI, let’s see what I can do with this. Also, just a recommendation but there isn’t even a single screenshot and I’d say that’s pretty important in a GUI library.
there are always tons of imgui-like libs.
> API is designed to be a polling loop
IMO this is a mistake. The most popular platform in the world does not allow using a polling loop. You can hack things to simulate it but eventually you'll run into where this will break for you. Better to start with something more forward compatible.
Which one are you referring to?
I'm assuming they mean the web.
I assume you mean the web? I’m not sure why that’d be relevant to a C library.
The Web runs C via WebAssembly, but if you're porting a polling loop app you're going to have a bad time. Conversely, if you start with an event driven app then you lose nothing but gain portability.
Okay -- this code is pathologically minimal. If you modify it to use events on the web, will your work extend to all the other platforms?
why hell would you use a c library to make a gui on the web when you have HTML ?
Maybe it was a personal goal?
The most popular platform in the world does not allow using a polling loop
I don't know what that means, but just because something else doesn't use a polling loop doesn't mean it's a mistake or the wrong fit.
Something like this so simple there is likely to be a lot that gets done inside the main loop, not the least of which is drawing into the buffer which is most of the point.
> Fenster /ˈfɛnstɐ/ -- a German word for "window".
Same in Afrikaans as well - "venster"[1] means window.
That's not surprising as Afrikaans is highly related to Dutch which is in turn highly related to German. In this case it all comes from the Latin fenestra.
> Latin fenestra.
Hence defenestrate, to throw out the window.
Okno in Slovak
Fönster in Swedish.
Could be cool, but if it is supposed to be a single header file it should say that instead of 'minimal'.
Also if it's just about getting a single window up with a pixel buffer it should say that.
Top priority should be getting screenshots on the github landing page.
The problem is that the title says "cross-platform GUI", so some people would expect, you know, a GUI - windows, menus, text, buttons, sliders, scrollbars, input fields, etc...
This is more like a cross platform canvas on which you can draw.
Raylib was my goto for that, but an alternative can't hurt, I guess ?
no single facet of this that I don't love
I chuckled at, "And, yes, it can run Doom!"
Hahaha, so it makes sense that DOOM can be run anywhere.
This is exciting. This is great for data visualization and financial applications!