Click here to Skip to main content
15,887,135 members
Articles / Desktop Programming / Cocoa
Tip/Trick

RGFW | Singler-Header Lightweight Framework for Basic Window and Graphics Context Handling (like GLFW)

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
25 Feb 2024CPOL1 min read 3.1K   1   2
A multi-platform single-header very simple-to-use framework library for creating GUI Libraries or simple GUI programs.
RGFW is a multi-platform single-header and very simple-to-use framework library used for creating GUI Libraries or simple GUI programs. It is written to be as portable as possible and supports winapi, Xlib and cocoas for windowing APIs. For graphics APIs, it supports OpenGL legacy, modern OpenGL, Vulkan and DirectX. It lets you create a window with a graphics context (opengl, vulkan or directX) and manage the window and its events only with a few function calls.

Image 2Introduction

RGFW is a lightweight and versatile alternative to GLFW, written in C, which puts simplicity and flexibility at the forefront of your graphics programming experience.

At its core, RGFW is designed with performance in mind. With just a single header file, it offers a portable solution that can be seamlessly integrated into your projects. Built with C89 compatibility in mind, RGFW ensures broad accessibility across different platforms and environments.

What sets RGFW apart is its focus on keeping things small and nimble. Unlike other libraries, RGFW prioritizes efficiency and simplicity, allowing you to get up and running with minimal overhead.

With RGFW, you have the power to create windows and manage events with ease, all through a handful of intuitive function calls. Whether you're working with OpenGL, Vulkan, or DirectX, RGFW provides the tools you need to handle graphics contexts effortlessly.

If you're looking for a small, flexible, and easy-to-use alternative to GLFW, look no further than RGFW. Experience the simplicity and efficiency of Riley's Gui library FrameWork and unlock the true potential of your graphics projects.

Using the Code

Below is very basic example code (in C):

C
#define RGFW_IMPLEMENTATION
#include "RGFW.h"

int main() {
    RGFW_window* win = RGFW_createWindow("name", RGFW_RECT(500, 500, 500, 500), (u64)0);
       
    while running = 1;
    
    for (running) {
        while(RGFW_window_checkEvent(win)) {
            if (win->event.type == RGFW_quit) {
               running = 0;
               break;
            }
        }
        
       if (RGFW_isPressedI(win, RGFW_Escape))
            break;
        
        RGFW_window_swapBuffers(win);

        glClearColor(0xFF, 0XFF, 0xFF, 0xFF);
        glClear(GL_COLOR_BUFFER_BIT);
    }

    RGFW_window_close(win);
}

Example screenshots (basic and gl33)
Image 3
More Info / RGFW Repo

A table provided in the header to show specific things RGFW supports and other information about RGFW compared to GLFW:

Image 4

More information can be found on the RGFW rep and documentation can be found in the header itself, RGFW.h.

History

  • 21st February, 2024: Initial version

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Student
United States United States
An objectivist, C programmer who's been programming for ~5 years. I specialize in system programming, mainly with low level tech currently. I'm currently just a hobbyist as I am still making my way through high school.

Comments and Discussions

 
QuestionScreenshots Pin
Giles23-Feb-24 2:18
Giles23-Feb-24 2:18 
Would be nice to see a few image examples.



"Je pense, donc je mange." - Rene Descartes 1689 - Just before his mother put his tea on the table.


AnswerRe: Screenshots Pin
ColleagueRiley23-Feb-24 13:16
ColleagueRiley23-Feb-24 13:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.