• naruhodo 6 hours ago

    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.

    • int_19h 9 hours ago

      That's not a GUI. It's something a GUI might be implemented in.

      • dragonwriter 3 hours ago

        > 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”.

      • vmsp 11 hours ago

        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/

        • unwind 2 hours ago

          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:

              memset(f->buf, rgb, f->width*f->height*sizeoof(uint32_t));
          
          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.

          [1]: https://man7.org/linux/man-pages/man3/memset.3.html

        • kookamamie 7 hours ago

          A windowing library, not a GUI library.

          • rmonvfer 12 hours ago

            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.

            • lstodd 3 hours ago

              there are always tons of imgui-like libs.

            • Surac an hour ago

              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.

              • Avshalom 19 minutes ago

                http://homepages.enterprise.net/murphy/thickline/index.html

                pascal not C but you should be able to translate it pretty easy.

                • tubs an hour ago

                  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.

                • socalgal2 11 hours ago

                  > 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.

                  • IcyWindows 10 hours ago

                    Which one are you referring to?

                    • gt0 9 hours ago

                      I'm assuming they mean the web.

                    • adastra22 8 hours ago

                      I assume you mean the web? I’m not sure why that’d be relevant to a C library.

                      • socalgal2 7 hours ago

                        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.

                        • hyperhello 6 hours ago

                          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?

                      • CyberDildonics 10 hours ago

                        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.

                        • Zardoz84 3 hours ago

                          why hell would you use a c library to make a gui on the web when you have HTML ?

                          • dardeaup 2 hours ago

                            Maybe it was a personal goal?

                        • lelanthran 6 hours ago

                          > Fenster /ˈfɛnstɐ/ -- a German word for "window".

                          Same in Afrikaans as well - "venster"[1] means window.

                          • porphyra 5 hours ago

                            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.

                            • kristianp 5 hours ago

                              > Latin fenestra.

                              Hence defenestrate, to throw out the window.

                            • dvh an hour ago

                              Okno in Slovak

                              • brabel 4 hours ago

                                Fönster in Swedish.

                              • CyberDildonics 12 hours ago

                                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.

                                • phtrivier 3 hours ago

                                  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 ?

                                • fitsumbelay 5 hours ago

                                  no single facet of this that I don't love

                                  • thisislife2 13 hours ago

                                    I chuckled at, "And, yes, it can run Doom!"

                                    • Forgret 3 hours ago

                                      Hahaha, so it makes sense that DOOM can be run anywhere.

                                    • ijidak 12 hours ago

                                      This is exciting. This is great for data visualization and financial applications!