Eine plattformübergreifende leichte Einzelhochschule, die sehr einfach zu bedienende Fensterabstraktionsbibliothek zum Erstellen von Grafikbibliotheken oder einfachen grafischen Programmen. Geschrieben in reinem C99.
RGFW ist ein kostenloses Multi-Plattform-Einzelkopf-Fensterabstraktions-Framework zum Erstellen von Grafikbibliotheken oder einfachen grafischen Programmen. Es soll als sehr kleine und flexible alternative Bibliothek für GLFW verwendet werden.
Das Fenster -Backend unterstützt XLIB (UNIX), Cocoas (MacOS), Webasm (EMSCIPTEN) und WinAPI (getestet unter Windows XP , 10 und 11 und ReactOS)
Windows 95 & 98 wurden ebenfalls mit RGFW getestet, obwohl die Ergebnisse zweifelhaft sind
Wayland: Um Wayland -Add zu kompilieren (rgfw_wayland = 1). Die Unterstützung von Wayland ist sehr experimentell und gebrochen.
Das Grafik -Backend unterstützt OpenGL (EGL, Software, Osmesa, GLES), Vulkan, DirectX, Metall und Software -Rendering -Puffer.
RGFW wurde als Backend für RSGL entwickelt, kann jedoch eigenständig oder für andere Bibliotheken verwendet werden, wie Raylib, der es als optionales alternatives Backend verwendet.
RGFW ist Multi-Paradigma,
Standardmäßig verwendet RGFW ein flexibles Ereignissystem, das dem von SDL ähnlich ist. Wenn Sie diese Methode bevorzugen, können Sie jedoch Rückrufe verwenden.
Diese Bibliothek
Diese Bibliothek nicht
#define RGFW_IMPLEMENTATION
#include "RGFW.h"
void keyfunc ( RGFW_window * win , u32 keycode , char keyName [ 16 ], u8 lockState , u8 pressed ) {
if ( keycode == RGFW_Escape && pressed ) {
RGFW_window_setShouldClose ( win );
}
}
int main () {
RGFW_window * win = RGFW_createWindow ( "a window" , RGFW_RECT ( 0 , 0 , 800 , 600 ), ( u16 )( RGFW_CENTER | RGFW_NO_RESIZE ));
RGFW_setKeyCallback ( keyfunc ); // you can use callbacks like this if you want
while ( RGFW_window_shouldClose ( win ) == RGFW_FALSE ) {
while ( RGFW_window_checkEvent ( win )) { // or RGFW_window_checkEvents(); if you only want callbacks
// you can either check the current event yourself
if ( win -> event . type == RGFW_mouseButtonPressed && win -> event . button == RGFW_mouseLeft ) {
printf ( "You clicked at x: %d, y: %dn" , win -> event . point . x , win -> event . point . y );
}
// or use the existing functions
if ( RGFW_isMousePressed ( win , RGFW_mouseRight )) {
printf ( "The right mouse button was clicked at x: %d, y: %dn" , win -> event . point . x , win -> event . point . y );
}
}
glClearColor ( 0.1f , 0.1f , 0.1f , 1.0f );
glClear ( GL_COLOR_BUFFER_BIT );
// You can use modern OpenGL techniques, but this method is more straightforward for drawing just one triangle.
glBegin ( GL_TRIANGLES );
glColor3f ( 1 , 0 , 0 ); glVertex2f ( -0.6 , -0.75 );
glColor3f ( 0 , 1 , 0 ); glVertex2f ( 0.6 , -0.75 );
glColor3f ( 0 , 0 , 1 ); glVertex2f ( 0 , 0.75 );
glEnd ();
RGFW_window_swapBuffers ( win );
}
RGFW_window_close ( win );
return 0 ;
}linux : gcc main.c -lX11 -lGL -lXrandr -lm
windows : gcc main.c -lopengl32 -lshell32 -lgdi32 -lwinmm -lm
macos : gcc main.c -framework Foundation -framework AppKit -framework OpenGL -framework CoreVideo -lm
Weitere Beispiele finden Sie hier oder führen Sie es in Ihrem Browser mit EMSCIPTEN aus
Eine Liste der GUI -Bibliotheken, die mit RGFW verwendet werden können
Es gibt eine Menge In-Header-Dokumentation, aber weitere Unterlagen finden Sie unter https://coleagueriley.github.io/rgfw/docs/index.html Wenn Sie die Dokumentation selbst erstellen möchten, ist auch eine Doxygen-Datei beigefügt.
Eine Liste von Bindungen finden Sie im RGFW -Wiki hier
Eine Liste von Projekten, die RGFW verwenden
Es gibt eine RGFW -Wiki -Seite über Dinge, die Sie tun können, wenn Sie die Entwicklung von RGFW hier unterstützen möchten.
Ein Vergleich von RGFW und GLFW finden Sie auf dem Wiki
RGFW verwendet die ZLIB/LIBPNG -Lizenz. Dies bedeutet, dass Sie RGFW frei verwenden können, solange Sie nicht behaupten, dass Sie diese Software geschrieben haben, veränderte Versionen als solche markieren und die Lizenz im Kopf enthalten.
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.