-
Notifications
You must be signed in to change notification settings - Fork 16
RGFW vs GLFW
RGFW and GLFW are both multi-platform libraries for creating and managing windows. Since RGFW is made as an alternative to GLFW, it seems appropriate to make a comparison of the two.
This should be a good resource for deciding which library you want to use.
(Note: I will only be including official features directly from the respective repositories)
RGFW is a lightweight, single-header, cross-platform window abstraction library. It supports X11, Windows (XP+), macOS, and HTML5. It also allows you to load a graphics context for OpenGL, Vulkan, DirectX, or buffer/software rendering.
GLFW is a cross-platform window abstraction library. It supports X11, Wayland, Windows (7+), and macOS. It also allows you to load a graphics context for OpenGL or Vulkan.
RGFW is designed to be flexible, supporting many different paradigms and methods for achieving certain tasks. For example, RGFW's events can be handled using functions (isPressed
), callbacks (RGFW_setMousePosCallback
), or an event loop (while (RGFW_window_shouldClose(win) == 0)
).
GLFW, on the other hand, mostly handles events via callbacks. This is less flexible, and you may have to work around GLFW instead of with GLFW, depending on what you want to do.
RGFW is also designed to be portable and lightweight, using a less complicated design philosophy with few internal abstractions. GLFW, however, has a more abstract design philosophy, focusing on functional programming and loading functions inside objects of C structures. This makes GLFW's source code significantly larger.
There is a GitHub repository that builds GLFW into a single-header library. The output cannot be viewed directly on GitHub because it is ~10 MB. RGFW, on the other hand, can be viewed on GitHub because it is only ~280 KB.
Feature | RGFW | GLFW |
---|---|---|
.o size (avg) | 46 KB | 280 KB |
.so size (avg) | 94 KB | 433 KB |
.h size | 283 KB | 256 KB |
Memory usage (Linux) | ~40 MiB | 55.9 MiB |
FPS counter | ✓ | X |
Multi-threading | ✓ | X |
Drag and drop (input) | ✓ | ✓ |
Drag and drop (output) | X | X |
Joystick input | ~ (no macOS support) | ✓ |
Live window struct | ✓ | X |
Event pipeline (dynamic) | ✓ | X |
Multi-buffering | ✓ | ✓ |
Set icon based on bitmap | ✓ | ✓ |
Clipboard I/O | ✓ | ✓ |
Multi-window support | ✓ | ✓ |
Hide/show mouse | ✓ | ✓ |
No resize window | ✓ | ✓ |
No border window | ✓ | X |
Transparent window | ✓ | ✓ |
Key strings | ✓ | ✓ |
Custom cursors | ✓ | ✓ |
Wayland | ~(experimental or XWayland) | ✓ |
OpenGL | ✓ | ✓ |
Vulkan | ✓ | ✓ |
OpenGL ES | ✓ | ✓ |
EGL | ✓ | ✓ |
OSMesa | ✓ | ✓ |
Metal | ✓ | ✓ |
DirectX | ✓ | X |
Although RGFW is significantly more lightweight than GLFW, that doesn’t mean you should use it over GLFW. Ultimately, the choice is up to you. RGFW is more lightweight but RGFW is also newer and has a tiny community. So there's less support and it hasn't yet been tested in a production-ready project.