ครอสแบบข้ามแพลตฟอร์มที่มีน้ำหนักเบาส่วนหัวเดียวที่ใช้งานง่ายมากสำหรับการใช้งานห้องสมุดนามธรรมสำหรับการสร้างไลบรารีกราฟิกหรือโปรแกรมกราฟิกที่เรียบง่าย เขียนด้วย C99 บริสุทธิ์
RGFW เป็นเฟรมเวิร์กแบบนามธรรมแบบหลายแพลตฟอร์มแบบหลายแพลตฟอร์มที่ใช้งานง่ายสำหรับการสร้างไลบรารีกราฟิกหรือโปรแกรมกราฟิกที่เรียบง่าย มันหมายถึงการใช้เป็นห้องสมุดทางเลือกที่เล็กและยืดหยุ่นมากสำหรับ GLFW
แบ็กเอนด์หน้าต่างรองรับ XLIB (UNIX), Cocoas (MacOS), Webasm (Emscripten) และ Winapi (ทดสอบบน Windows XP , 10 และ 11 และ ReactOS)
Windows 95 & 98 ได้รับการทดสอบด้วย RGFW แม้ว่าผลลัพธ์จะไม่แน่นอน
Wayland: เพื่อรวบรวม Wayland เพิ่ม (rgfw_wayland = 1) การสนับสนุนของ Wayland นั้นมีการทดลองและแตกหักมาก
แบ็กเอนด์กราฟิกรองรับ OpenGL (EGL, ซอฟต์แวร์, OSMESA, GLES), Vulkan, DirectX, Metal และ Buffers การแสดงผลซอฟต์แวร์
RGFW ได้รับการออกแบบเป็นแบ็กเอนด์สำหรับ RSGL แต่สามารถใช้แบบสแตนด์อโลนหรือสำหรับไลบรารีอื่น ๆ เช่น Raylib ซึ่งใช้เป็นแบ็กเอนด์ทางเลือกเสริม
RGFW เป็นหลาย paradigm
โดยค่าเริ่มต้น RGFW ใช้ระบบเหตุการณ์ที่ยืดหยุ่นคล้ายกับของ SDL อย่างไรก็ตามคุณสามารถใช้การเรียกกลับหากคุณต้องการวิธีนั้น
ห้องสมุดนี้
ห้องสมุดนี้ไม่ได้
#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
คุณสามารถค้นหาตัวอย่างเพิ่มเติมได้ที่นี่หรือเรียกใช้ในเบราว์เซอร์ของคุณด้วย emscripten
รายการห้องสมุด GUI ที่สามารถใช้กับ RGFW สามารถพบได้ใน RGFW Wiki ที่นี่
มีเอกสารจำนวนมาก แต่สามารถดูเอกสารเพิ่มเติมได้ที่ https://colleagueriley.github.io/rgfw/docs/index.html หากคุณต้องการสร้างเอกสารด้วยตัวคุณเองนอกจากนี้ยังมีไฟล์ doxygen ที่แนบมา
รายการของการผูกสามารถพบได้ใน rgfw wiki ที่นี่
รายการโครงการที่ใช้ RGFW สามารถพบได้ใน RGFW Wiki ที่นี่
มีหน้า RGFW Wiki เกี่ยวกับสิ่งที่คุณสามารถทำได้หากคุณต้องการสนับสนุนการพัฒนา RGFW ที่นี่
การเปรียบเทียบ RGFW และ GLFW สามารถพบได้ที่ Wiki
RGFW ใช้ใบอนุญาต zlib/libpng ซึ่งหมายความว่าคุณสามารถใช้ RGFW ได้อย่างอิสระตราบใดที่คุณไม่ได้อ้างว่าคุณเขียนซอฟต์แวร์นี้ Mark Murted Version เช่นและเก็บใบอนุญาตที่รวมอยู่ในส่วนหัว
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.