RGFW: Single-header C99 window abstraction library

93 pointsposted 10 hours ago
by klaussilveira

19 Comments

felipefar

6 hours ago

You could support mobile platforms as well. IIRC, even if Android allows creating only one window per activity, this behavior can be easily mapped on the abstraction that you provide.

colleagueRiley

6 hours ago

That's something I plan on looking into at some point. I'm unsure if I want that in the main version or a separate branch for embedded devices.

It's low priority though because my main focus is desktop applications.

dmitrygr

5 hours ago

> Wayland support is very experimental and broken

You and everyone else, RGFW, you and everyone else.

colleagueRiley

5 hours ago

X11 needs a real alternative :(

akira2501

36 minutes ago

X11 is fine. It's mostly just Video Games that need an alternative. It'd be nice if there was a "pause X11 video card control and give exclusive access to a single application." Then there's no need to care.

themerone

2 hours ago

What do you expect from an alternative?

amjoshuamichael

4 hours ago

Yeah, I've been looking for a minimal SDL alternative for a long time and I was really excited reading through this as that solution, but the lack of Wayland support is a huge dealbreaker for me.

Are there any good minimal windowing utilities that support Wayland? SDL does a lot I don't need and I try to maintain minimal dependencies. I suppose I could just use glfw & libsoundio, haven't tried that yet.

marcthe12

an hour ago

Waylands problem is that to use it, you need code generation so the wayland backend kinda hard to design for a header only lib.

colleagueRiley

4 hours ago

As far as I know, RGFW is the only minimal windowing of its kind. I guess I would suggest either targeting XWayland or using GLFW.

The Wayland API itself also really sucks to work with, even more so than Xlib....

But, RGFW's Wayland support will probably be improved in the future. :)

CyberDildonics

6 hours ago

I love single header libraries and I like the idea here of taking care of one necessity well. It seems like good modularity all around.

A quick heads up, the micro UI emscripten example doesn't work on chrome or firefox. The error is: DrawElements doesn't actually prepareClientAttributes properly.

colleagueRiley

6 hours ago

I'm aware of the errors for the micro UI (on the web), it's something I plan on looking into soon!

ranger_danger

5 hours ago

The one big downside I see is that if you want to actually work on the library itself, it's a pain to have to re-compile the entire thing every time you change something.

Nuklear (https://github.com/Immediate-Mode-UI/Nuklear) uses separate files with a deploy script that combines them all into a single header; I think that approach is quicker for iterating on the code.

colleagueRiley

5 hours ago

Sure, but the library is also relatively small, so it compiles quickly. Although if you want to you can compile it on its own.

It's also possible to compile it on its own using `gcc -c -x c -D RGFW_IMPLEMENTATION RGFW.h`

Nuklear is not a true single-header style library, it only uses that as a format. The difference is that the design is far less compact and lightweight than a stb-style library.

I'm pretty sure GLFW has some files that are nearly the same size as RGFW, for example.

ranger_danger

5 hours ago

Why do you claim Nuklear is not a "true single-header style library"? And who gets to say what that even means?

colleagueRiley

4 hours ago

It is a single-header library in terms of the format, yes. But it is also not designed to be a single-header library, unlike an STB-style library.

Nuklear is a full-sized library that can be compiled into and used as one file. However, RGFW and STB are designed to be lightweight and minimalistic. That's the distinctive part of single-header libraries, also known as STB-style libraries.

To be clear, I don't mean this to hate on Nuklear, it's a cool UI library, but its design doesn't match the single-header format.

CyberDildonics

2 hours ago

Have you actually tried? This is 287 KB of C. MSVC on computers from 15 years ago will compile C at about 60 MB/s. I'm skeptical this is actually a problem.

SQLite is distributed as a single 6 MB .c file and compiles in ... 0.1 seconds.