▲ 6 r/raylib

C Polymorphism, Partial redrawing (clipping?) and double-buffer update for my UI

Hello everyone,

Last time here I posted several questions in relation to creating a retained-mode UI. So far, the project has been going on smoothly, and I've taken a similar approach to what zraygui does (code from zraygui):

struct _widget {
    Layout *parent;
    Rectangle rect;
    char *label;
    WidgetType type;
    Component *component;
    bool visible;
    bool active;
    MouseEvent widgetStatus;
    MouseListeners mouseListener;
};

The widgets share a common struct type Widget, but polymorphism happens inside the Component. It is an empty struct type, and for each type of widget, a pointer to their unique structs is cast as Component* into component. Then when manipulating the widget, the Component* is cast back to the original pointer type, enabling access to the fields.

I found this approach very smart, and I plan on implementing a similar thing (unless another better polymorphism exists in C). In my Widget struct, I have

typedef struct Widget {
  Frame* parent;
  Rect bounds;
  bool active;
  void *
  void (*draw)(Widget *w);
}

Implementing partial rendering seemed easy, just redraw the exact area indicated by bounds, until i remembered I have to call EndDrawing() which swaps buffers. Hence, the updated widget will only exist on one buffer, and If I don't call EndDrawing(), inputs will not be polled.

I would like to create something similar to FLTK, which only renders the parts that need to be updated (AFAIK, I only studied a small part of the code yet, but it seems very interesting to learn about performant desktop UI systems)

So I have two ideas :
- Ditch the double buffer and write a custom "EndDrawing()" which does not swap but keeps all other functionality

- Draw to a render texture that I apply on both buffers. While exploring this idea, I realized that it could be beneficial for tooltips and floating windows, as they could be other textures overlaid on the main one.

reddit.com
u/Any-Fox-1822 — 4 days ago
▲ 6 r/raylib

Retained-mode UI rendering with raylib : Where to start ?

Hello everyone,

I'm working on a retained mode UI library with a similar look and feel to raygui, either in C++ with classes and interfaces, or plain C with function pointers if I really feel adventurous. This isn't meant to be a serious project, more of a proof of concept.

However I kind of feel lost as to what I should implement first. So here are a few questions that i'd like to ask :

I would like the library to only draw when necessary, that is only when events occur rather than constantly. How does raylib handle events, and are there debug options to print all input ? PollInputEvents() is basically a per-backend implementation.

Are there widget categories I should try to go after first (besides the button) ?

Do you have resources on building such interfaces ? I found a book called Developing User Interfaces by Dan Olsen, but it isn't available on the Internet Archive.

reddit.com
u/Any-Fox-1822 — 7 days ago
▲ 48 r/plan9

Writing a display, keyboard and audio driver for 9front uConsole ?

Hello everyone,

A few weeks ago I had made a post (with the same mockup) asking if it was possbile to run 9front on the clockworkpi uConsole, given that it is built around a Raspberry Pi 4 . I managed to flash the image, but as expected nothing happened.

The uConsole needs a specific variety of drivers to work with, both for the display, the keyboard and the speakers. Are there references to write a driver in Plan9 / 9front C ?

u/Any-Fox-1822 — 8 days ago
▲ 10 r/raylib

Adding layouts to raygui, or create my own UI ?

Hello everyone,

I made a post recently in r/suckless about using raylib for desktop UI. Despite falling in love with that library, I am quite confused by raygui, and the fact that immediate mode GUIs seem to behave better without layout systems.

I would like to add basic layouts to raygui (even if it's just to align widgets, nothing really fancy, but I wonder how it could be achieved. The widgets do not have a lifespan longer than the frame, and I didn't find a way to create widget trees. There is enum GuiControl that lists all types, but none of them contain any data about the widgets.

Would layouts necessarily clash with the immediate-ness of raygui, or do you think it's possible to reconcile the two ? Apparently someone tried with zraygui, a project for a retained-mode UI using raylib.

reddit.com
u/Any-Fox-1822 — 10 days ago
▲ 6 r/raylib

Creating a pixman backend for raygui ?

Hello everyone,

I have been using Raylib for personal projects since a year, and I absolutely love it. Being interested in small but powerful applications, I started looking at suckless.org and their projects, but also some graphical applications created by members of wayland.fyi, dedicated to minimal software & graphics on Wayland.

With these inspirations, I decided to start creating my own desktop tools, starting with a simple clock. However, the program is constantly at 1-2% CPU, even with several optimizations. I am wondering if the abstraction layers aren't causing excessive resource usage. I compiled Raylib against SDL2 as I thought it would use less resources than GLFW.

When trying out other clocks such as the default Xorg xclock or wayland.fyi's swclock, their cpu usage is almost zero. Looking inside, their graphics calls seem to be much lower level than raylib, and both use pixman (one of the lowest level graphics libraries IIRC, that is the base of cairo).

Hence, I am wondering if creating a pixman backend for raygui (not all of raylib as I think 3D would be impossibly hard) is a feasible task for a solo developer. If you have previously worked with such libraries, what was your experience with it ?

Thanks for your advice !

reddit.com
u/Any-Fox-1822 — 16 days ago

Would raylib/raygui be suckless enough for desktop UI ? (Scared about resource usage)

Hello everyone,

I recently started a project to create my own desktop apps. Ideally, I'd want a notebook, music player, file explorer & system tray. I've been inspired by the work of wayland.fyi and 100rabbits, as the minimalism of their GUI programs is something I was looking for. I would want this project to be some sort of mini desktop environment aimed at low-power devices (Raspberry Pi mainly)

To me raylib seems like a good choice. It's heavily documented, has several backend options (even software render since the latest version), and is still high-level enough to avoid creating an entire widget system from scratch.

However, tests have put that choice in question. My clone of xclock always sits at 2-3% CPU, with Raylib compiled against SDL2, whereas xclock or wayland.fyi's swclock basically idle at 0% when not interacted with. Both use pixman for rendering*

Even though raylib feels perfect from a programming standpoint, being challenging enough to provide a great experience (in C) all while providing some confort, I'm unsure of its performance. Am I doing premature optimization?

Thanks for your advice.

^(*swclock uses a custom drawing lib called) ^(neuwld)^(, which contains calls to pixman.)

u/Any-Fox-1822 — 16 days ago

Does anyone have a guide for suckless wayland/neuwld on Debian ?

Hello everyone,

This summer, i'd like to switch to Wayland on my uConsole, and try a tiling window manager. I've stumbled upon wayland.fyi and dérive linux, and I'm wondering if there is a guide to get the most barebones Wayland install on Debian. The Debian wiki mentions several compositors, but I'd like to test the more experimental ones, as well as playing with the wld drawing library.

Thanks for your answers & help

reddit.com
u/Any-Fox-1822 — 2 months ago

First try at a thrash metal band logo for a future project (no AI)

Hello everyone, this is my first post here

I have recently been listening to a lot of old school metal, especially thrash and heavy, as well as newer bands. I might get to learning guitar and singing next year, if I have time with uni. In the meantime, I created a logo for the hypothetical project, more as a test than anything.

I wanted the name to relate to raccoons, just by appreciation of the animal, and so i thought that a pun on the scientific name (procyon lotor) would be neat. I hesitated with a few words before choosing motor, as I'm currently following a motorcycle riding course.

As the design progressed, motor proved to be an ideal word, mainly because of the two O's that perfectly fit as eyes. To call back to the "mask" around the eyes, i decided to make MOTOR bolder, and angle the O's to give a frowning/angry expression. The T was at first separate, but I prefered to turn it into a connection between the bottom & nose and the middle.

I have checked other logos to see if there was not accidental plagiarism, or if the logo didn't recall illegal symbols or references (especially the cat emblem in Art Spiegelman's Maus)

All in all, i'm quite satisfied with the result and its readability.

Is there something you would change ?
Thanks for your answers

u/Any-Fox-1822 — 3 months ago

Unknown typewriter font

I've found this font at the house of one of my mother's friends. She says the text was probably typed before 1990

u/Any-Fox-1822 — 3 months ago
▲ 3 r/AskACobbler+1 crossposts

Is it possible to narrow the shaft diameter of a boot ?

Hello everyone, first post here

I recently bought a pair of Solovair biker boots in UK 6 size (picture is from the store page), and so far i've been loving them. They feel very solid, but are still malleable.

Here are the specs : https://eu.nps-solovair.com/collections/mens/products/gf0-11000-bg

However, I'm having a problem with the top of the boot, as I find the shaft slightly too wide therr, even with the buckles at the narrowest position. Since I have slim calves, It feels like I'm slightly floating.

I have tried slightly shrinking the boots by dampening them and going soflty with a hairdryer, but it didn't have a noticeable effect.

Could a cobbler modify the shaft to make it narrower ? I have no idea on what the process could be

Thanks for your answers

u/Any-Fox-1822 — 3 months ago

Hello everyone, first post here.
I sometimes hear (whether it is on YT or on toher social media) that art of the past centuries was objectively better because it seemed to be more in line with the social norms of these times (even though i'm grossly oversimplifying), and some channles use this to qualitfy contemporary art as unworthy. I personally do not believe these arguments, and think that the reason most of the famous works have a limited range of subjects was due to the control of patrons on artists. Are there any good publications that explain the relationships of patrons & artists through the centuries and up to the 21st century ?

Thanks for your answers !

reddit.com
u/Any-Fox-1822 — 4 months ago

Hello everyone,

I've seen since some time on r/unixart and r/unixporn that more and more people are saying "no GNU tools in this rice" in their titles or dotfiles, or "moving from GNU". Some new distros live Dérive Linux also state that the have no dependencies on GNU tools.

Why is this happening, and what is the main reason behind it ? I'm not here to judge, simply confused as what the benefits may be.

reddit.com
u/Any-Fox-1822 — 4 months ago