3030/*
3131 #define RGFW_IMPLEMENTATION - (required) makes it so the source code is included
3232 #define RGFW_PRINT_ERRORS - (optional) makes it so RGFW prints errors when they're found
33+ #define RGFW_DEBUG - (optional) makes it so RGFW prints debug messages
3334 #define RGFW_OSMESA - (optional) use OSmesa as backend (instead of system's opengl api + regular opengl)
3435 #define RGFW_BUFFER - (optional) just draw directly to (RGFW) window pixel buffer that is drawn to screen (the buffer is in the RGBA format)
3536 #define RGFW_EGL - (optional) use EGL for loading an OpenGL context (instead of the system's opengl api)
@@ -207,11 +208,7 @@ int main() {
207208#endif
208209
209210#ifndef RGFWDEF
210- #ifdef __clang__
211- #define RGFWDEF static inline
212- #else
213- #define RGFWDEF inline
214- #endif
211+ #define RGFWDEF inline
215212#endif
216213
217214#ifndef RGFW_ENUM
@@ -1959,7 +1956,7 @@ void RGFW_updateLockState(RGFW_window* win, b8 capital, b8 numlock) {
19591956 MacOS and Windows do this using a structure called a "pixel format"
19601957 X11 calls it a "Visual"
19611958 This function returns the attributes for the format we want */
1962- static u32 * RGFW_initFormatAttribs (u32 useSoftware ) {
1959+ u32 * RGFW_initFormatAttribs (u32 useSoftware ) {
19631960 RGFW_UNUSED (useSoftware );
19641961 static u32 attribs [] = {
19651962 #if defined(RGFW_X11 ) || defined(RGFW_WINDOWS )
@@ -2422,6 +2419,10 @@ Start of Linux / Unix defines
24222419
24232420 win -> buffer = (u8 * )RGFW_MALLOC (RGFW_bufferSize .w * RGFW_bufferSize .h * 4 );
24242421
2422+ #ifdef RGFW_DEBUG
2423+ printf ("RGFW INFO: createing a 4 channel %i by %i buffer\n" , RGFW_bufferSize .w , RGFW_bufferSize .h );
2424+ #endif
2425+
24252426 #ifdef RGFW_OSMESA
24262427 win -> src .ctx = OSMesaCreateContext (OSMESA_RGBA , NULL );
24272428 OSMesaMakeCurrent (win -> src .ctx , win -> buffer , GL_UNSIGNED_BYTE , win -> r .w , win -> r .h );
@@ -2739,6 +2740,10 @@ Start of Linux / Unix defines
27392740
27402741 RGFW_windowsOpen ++ ;
27412742
2743+ #ifdef RGFW_DEBUG
2744+ printf ("RGFW INFO: a window with a rect of {%i, %i, %i, %i} \n" , win -> r .x , win -> r .y , win -> r .w , win -> r .h );
2745+ #endif
2746+
27422747 return win ; /*return newly created window*/
27432748 }
27442749
@@ -3783,6 +3788,10 @@ Start of Linux / Unix defines
37833788 monitor .scaleY = (float ) (dpi_height ) / (float ) 96 ;
37843789 XRRFreeScreenResources (sr );
37853790 XCloseDisplay (display );
3791+
3792+ #ifdef RGFW_DEBUG
3793+ printf ("RGFW INFO: monitor found: scale (%s):\n rect: {%i, %i, %i, %i}\n physical size:%f %f\n scale: %f %f\n" , monitor .name , monitor .rect .x , monitor .rect .y , monitor .rect .w , monitor .rect .h , monitor .physW , monitor .physH , monitor .scaleX , monitor .scaleY );
3794+ #endif
37863795 return monitor ;
37873796 }
37883797
@@ -3812,6 +3821,10 @@ Start of Linux / Unix defines
38123821
38133822 XCloseDisplay (display );
38143823
3824+ #ifdef RGFW_DEBUG
3825+ printf ("RGFW INFO: monitor found: scale (%s):\n rect: {%i, %i, %i, %i}\n physical size:%f %f\n scale: %f %f\n" , monitor .name , monitor .rect .x , monitor .rect .y , monitor .rect .w , monitor .rect .h , monitor .physW , monitor .physH , monitor .scaleX , monitor .scaleY );
3826+ #endif
3827+
38153828 return monitor ;
38163829 }
38173830
@@ -4421,6 +4434,9 @@ static void keyboard_key (void *data, struct wl_keyboard *keyboard, uint32_t ser
44214434 char name [16 ];
44224435 xkb_keysym_get_name (keysym , name , 16 );
44234436
4437+
4438+ printf ("%c\n" , keysym );
4439+
44244440 u32 RGFW_key = RGFW_apiKeyCodeToRGFW (key );
44254441 RGFW_keyboard [RGFW_key ].prev = RGFW_keyboard [RGFW_key ].current ;
44264442 RGFW_keyboard [RGFW_key ].current = state ;
@@ -4764,6 +4780,10 @@ static const struct wl_callback_listener wl_surface_frame_listener = {
47644780
47654781 win -> src .eventIndex = 0 ;
47664782 win -> src .eventLen = 0 ;
4783+
4784+ #ifdef RGFW_DEBUG
4785+ printf ("RGFW INFO: a window with a rect of {%i, %i, %i, %i} \n" , win -> r .x , win -> r .y , win -> r .w , win -> r .h );
4786+ #endif
47674787
47684788 return win ;
47694789 }
@@ -5606,6 +5626,10 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */
56065626 wglShareLists (RGFW_root -> src .ctx , win -> src .ctx );
56075627 #endif
56085628
5629+ #ifdef RGFW_DEBUG
5630+ printf ("RGFW INFO: a window with a rect of {%i, %i, %i, %i} \n" , win -> r .x , win -> r .y , win -> r .w , win -> r .h );
5631+ #endif
5632+
56095633 return win ;
56105634 }
56115635
@@ -6208,6 +6232,10 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */
62086232 monitor .physW = GetSystemMetrics (SM_CYSCREEN ) / (float ) ppiX ;
62096233 monitor .physH = GetSystemMetrics (SM_CXSCREEN ) / (float ) ppiY ;
62106234
6235+ #ifdef RGFW_DEBUG
6236+ printf ("RGFW INFO: monitor found: scale (%s):\n rect: {%i, %i, %i, %i}\n physical size:%f %f\n scale: %f %f\n" , monitor .name , monitor .rect .x , monitor .rect .y , monitor .rect .w , monitor .rect .h , monitor .physW , monitor .physH , monitor .scaleX , monitor .scaleY );
6237+ #endif
6238+
62116239 return monitor ;
62126240 }
62136241 #endif /* RGFW_NO_MONITOR */
@@ -6738,7 +6766,6 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */
67386766 typedef void NSDraggingInfo ;
67396767 typedef void NSWindow ;
67406768 typedef void NSApplication ;
6741- typedef void NSScreen ;
67426769 typedef void NSEvent ;
67436770 typedef void NSString ;
67446771 typedef void NSOpenGLContext ;
@@ -7210,7 +7237,7 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */
72107237 return false;
72117238 }
72127239
7213- static void NSMoveToResourceDir (void ) {
7240+ void NSMoveToResourceDir (void ) {
72147241 /* sourced from glfw */
72157242 char resourcesPath [255 ];
72167243
@@ -7497,6 +7524,10 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */
74977524 NSRetain (win -> src .window );
74987525 NSRetain (NSApp );
74997526
7527+ #ifdef RGFW_DEBUG
7528+ printf ("RGFW INFO: a window with a rect of {%i, %i, %i, %i} \n" , win -> r .x , win -> r .y , win -> r .w , win -> r .h );
7529+ #endif
7530+
75007531 return win ;
75017532 }
75027533
@@ -8097,7 +8128,7 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */
80978128 return objc_msgSend_bool (win -> src .window , sel_registerName ("isZoomed" ));
80988129 }
80998130
8100- static RGFW_monitor RGFW_NSCreateMonitor (CGDirectDisplayID display ) {
8131+ RGFW_monitor RGFW_NSCreateMonitor (CGDirectDisplayID display ) {
81018132 RGFW_monitor monitor ;
81028133
81038134 CGRect bounds = CGDisplayBounds (display );
@@ -8111,19 +8142,23 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */
81118142 float dpi_height = round ((double )monitor .rect .h /(double )monitor .physH );
81128143
81138144 monitor .scaleX = (float ) (dpi_width ) / (float ) 96 ;
8114- monitor .scaleY = (float ) (dpi_height ) / (float ) 96 ;
8145+ monitor .scaleY = (float ) (dpi_height ) / (float ) 96 ;
81158146
81168147 if (isinf (monitor .scaleX ) || (monitor .scaleX > 1 && monitor .scaleX < 1.1 ))
81178148 monitor .scaleX = 1 ;
81188149
81198150 if (isinf (monitor .scaleY ) || (monitor .scaleY > 1 && monitor .scaleY < 1.1 ))
81208151 monitor .scaleY = 1 ;
81218152
8153+ #ifdef RGFW_DEBUG
8154+ printf ("RGFW INFO: monitor found: scale (%s):\n rect: {%i, %i, %i, %i}\n physical size:%f %f\n scale: %f %f\n" , monitor .name , monitor .rect .x , monitor .rect .y , monitor .rect .w , monitor .rect .h , monitor .physW , monitor .physH , monitor .scaleX , monitor .scaleY );
8155+ #endif
8156+
81228157 return monitor ;
81238158 }
81248159
81258160
8126- static RGFW_monitor RGFW_monitors [7 ];
8161+ RGFW_monitor RGFW_monitors [7 ];
81278162
81288163 RGFW_monitor * RGFW_getMonitors (void ) {
81298164 static CGDirectDisplayID displays [7 ];
@@ -8778,6 +8813,10 @@ RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, u16 args) {
87788813 RGFW_window_resize (win , RGFW_getScreenSize ());
87798814 }
87808815
8816+ #ifdef RGFW_DEBUG
8817+ printf ("RGFW INFO: a window with a rect of {%i, %i, %i, %i} \n" , win -> r .x , win -> r .y , win -> r .w , win -> r .h );
8818+ #endif
8819+
87818820 return win ;
87828821}
87838822
@@ -9099,6 +9138,8 @@ RGFW_monitor RGFW_window_getMonitor(RGFW_window* win) { RGFW_UNUSED(win) return
90999138 void RGFW_joinThread (RGFW_thread thread ) { pthread_join ((pthread_t ) thread , NULL ); }
91009139#ifdef __linux__
91019140 void RGFW_setThreadPriority (RGFW_thread thread , u8 priority ) { pthread_setschedprio ((pthread_t )thread , priority ); }
9141+ #else
9142+ void RGFW_setThreadPriority (RGFW_thread thread , u8 priority ) { RGFW_UNUSED (thread ); RGFW_UNUSED (priority ); }
91029143#endif
91039144#endif
91049145
0 commit comments