RGFW:
- is an stb-style single headerfile and is very portable
- is primarly written in C99 in mind
- has a C89 compatible API on going changes to make the implementation more C89 friendly
- is comparable to GLFW or aspects of SDL but it's leading motive is to be a flexible and lightweight windowing library
- is a very small compared to other libraries
- is a general framework and can be used for games, apps or tools
- does only depend on system API libraries, Winapi, X11, Cocoa, etc NO dependencies
- does help you create a window with a graphics context (OpenGL, Vulkan, WebGPU, Metal, or DirectX) and manage the window and its events only with a few function calls
- is customizable, you enable or disable features
- does work with X11 (UNIX), Wayland (experimental) (LINUX), Cocoa (MacOS), Emscripten (WASM) and WinAPI (tested on windows XP, 10, 11, reactOS and has limited 9x support)
- is multi-paradigm, with a flexible event system, including multiple ways of handling events (callbacks, queue, state lookups)
- does include a large number of examples for learning RGFW
RGFW:
- does not handle any rendering for you (other than creating your graphics context)
- is not an OpenGL focused library, RGFW can be used with ANY graphics API
- does not do anything above the bare minimum in terms of functionality
There is a Makefile including for compiling th examples. NOTE: WAYLAND=1
OR can be defined to compile for wayland. WAYLAND_X11=1
can be used instead if you want examples to fallback to X11 if a Wayland display is not found. This adds #define RGFW_WAYLAND
in the implementation (or defines RGFW_WAYLAND
AND RGFW_X11
)
Included in the framework are helper functions for multiple rendering APIs OpenGL (Native, EGL, GLES), Vulkan, DirectX, Metal and WebGPU, you can also easily blit raw data directly onto the window with the RGFW_surface
object using RGFW_window_blitSurface
.
You must explicitly request these helper functions via, #define RGFW_OPENGL
, #define RGFW_VULKAN
, #define RGFW_DIRECTX
, #define RGFW_WEBGPU
.
#define RGFW_IMPLEMENTATION
#define RGFW_OPENGL /* if this line is not added, OpenGL functions will not be included */
#include "RGFW.h"
#include <stdio.h>
#ifdef RGFW_MACOS
#include <OpenGL/gl.h> /* why does macOS do this */
#else
#include <GL/gl.h>
#endif
void keyfunc(RGFW_window* win, RGFW_key key, u8 keyChar, RGFW_keymod keyMod, RGFW_bool repeat, RGFW_bool pressed) {
RGFW_UNUSED(repeat);
if (key == RGFW_escape && pressed) {
RGFW_window_setShouldClose(win, 1);
}
}
int main() {
/* the RGFW_windowOpenGL flag tells it to create an OpenGL context, but you can also create your own with RGFW_window_createContext_OpenGL */
RGFW_window* win = RGFW_createWindow("a window", 0, 0, 800, 600, RGFW_windowCenter | RGFW_windowNoResize | RGFW_windowOpenGL);
RGFW_setKeyCallback(keyfunc); // you can use callbacks like this if you want
while (RGFW_window_shouldClose(win) == RGFW_FALSE) {
RGFW_event event;
while (RGFW_window_checkEvent(win, &event)) { // or RGFW_pollEvents(); if you only want callbacks
// you can either check the current event yourself
if (event.type == RGFW_quit) break;
if (event.type == RGFW_mouseButtonPressed && event.button.value == RGFW_mouseLeft) {
printf("You clicked at x: %d, y: %d\n", event.mouse.x, event.mouse.y);
}
// or use the existing functions
if (RGFW_isMousePressed(RGFW_mouseRight)) {
printf("The right mouse button was clicked at x: %d, y: %d\n", event.mouse.x, event.mouse.y);
}
}
// OpenGL 1.1 is used here for a simple example, but you can use any version you want (if you request it first (see gl33/gl33.c))
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glBegin(GL_TRIANGLES);
glColor3f(1.0f, 0.0f, 0.0f); glVertex2f(-0.6f, -0.75f);
glColor3f(0.0f, 1.0f, 0.0f); glVertex2f(0.6f, -0.75f);
glColor3f(0.0f, 0.0f, 1.0f); glVertex2f(0.0f, 0.75f);
glEnd();
RGFW_window_swapBuffers_OpenGL(win);
glFlush();
}
RGFW_window_close(win);
return 0;
}
linux : gcc main.c -lX11 -lGL -lXrandr
windows : gcc main.c -lopengl32 -lgdi32
macos : gcc main.c -framework Cocoa -framework OpenGL
You can find more examples here or run it in your browser with emscripten
A list of GUI libraries that can be used with RGFW can be found on the RGFW wiki here
There is a lot of in-header-documentation, but more documentation can be found at https://colleagueriley.github.io/RGFW/docs/index.html If you wish to build the documentation yourself, there is also a Doxygen file attached.
A list of bindings can be found on the RGFW wiki here
A list of projects that use RGFW can be found on the RGFW wiki here
- email : ColleagueRiley@gmail.com
- discord : ColleagueRiley
- discord server : https://discord.gg/pXVNgVVbvh
- matrix space: https://matrix.to/#/#rsgl-is-sili:matrix.org
- BlueSky https://bsky.app/profile/colleagueriley.bsky.social
- Twitter/X : https://x.com/ColleagueRiley
There is a RGFW wiki page about things you can do if you want to support the development of RGFW here.
A comparison of RGFW and GLFW can be found at on the wiki
RGFW uses the Zlib/libPNG license, this means you can use RGFW freely as long as you do not claim you wrote this software, mark altered versions as such and keep the license included with the header.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.