30
30
/*
31
31
#define RGFW_IMPLEMENTATION - (required) makes it so the source code is included
32
32
#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
33
34
#define RGFW_OSMESA - (optional) use OSmesa as backend (instead of system's opengl api + regular opengl)
34
35
#define RGFW_BUFFER - (optional) just draw directly to (RGFW) window pixel buffer that is drawn to screen (the buffer is in the RGBA format)
35
36
#define RGFW_EGL - (optional) use EGL for loading an OpenGL context (instead of the system's opengl api)
@@ -207,11 +208,7 @@ int main() {
207
208
#endif
208
209
209
210
#ifndef RGFWDEF
210
- #ifdef __clang__
211
- #define RGFWDEF static inline
212
- #else
213
- #define RGFWDEF inline
214
- #endif
211
+ #define RGFWDEF inline
215
212
#endif
216
213
217
214
#ifndef RGFW_ENUM
@@ -1959,7 +1956,7 @@ void RGFW_updateLockState(RGFW_window* win, b8 capital, b8 numlock) {
1959
1956
MacOS and Windows do this using a structure called a "pixel format"
1960
1957
X11 calls it a "Visual"
1961
1958
This function returns the attributes for the format we want */
1962
- static u32 * RGFW_initFormatAttribs (u32 useSoftware ) {
1959
+ u32 * RGFW_initFormatAttribs (u32 useSoftware ) {
1963
1960
RGFW_UNUSED (useSoftware );
1964
1961
static u32 attribs [] = {
1965
1962
#if defined(RGFW_X11 ) || defined(RGFW_WINDOWS )
@@ -2422,6 +2419,10 @@ Start of Linux / Unix defines
2422
2419
2423
2420
win -> buffer = (u8 * )RGFW_MALLOC (RGFW_bufferSize .w * RGFW_bufferSize .h * 4 );
2424
2421
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
+
2425
2426
#ifdef RGFW_OSMESA
2426
2427
win -> src .ctx = OSMesaCreateContext (OSMESA_RGBA , NULL );
2427
2428
OSMesaMakeCurrent (win -> src .ctx , win -> buffer , GL_UNSIGNED_BYTE , win -> r .w , win -> r .h );
@@ -2739,6 +2740,10 @@ Start of Linux / Unix defines
2739
2740
2740
2741
RGFW_windowsOpen ++ ;
2741
2742
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
+
2742
2747
return win ; /*return newly created window*/
2743
2748
}
2744
2749
@@ -3783,6 +3788,10 @@ Start of Linux / Unix defines
3783
3788
monitor .scaleY = (float ) (dpi_height ) / (float ) 96 ;
3784
3789
XRRFreeScreenResources (sr );
3785
3790
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
3786
3795
return monitor ;
3787
3796
}
3788
3797
@@ -3812,6 +3821,10 @@ Start of Linux / Unix defines
3812
3821
3813
3822
XCloseDisplay (display );
3814
3823
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
+
3815
3828
return monitor ;
3816
3829
}
3817
3830
@@ -4421,6 +4434,9 @@ static void keyboard_key (void *data, struct wl_keyboard *keyboard, uint32_t ser
4421
4434
char name [16 ];
4422
4435
xkb_keysym_get_name (keysym , name , 16 );
4423
4436
4437
+
4438
+ printf ("%c\n" , keysym );
4439
+
4424
4440
u32 RGFW_key = RGFW_apiKeyCodeToRGFW (key );
4425
4441
RGFW_keyboard [RGFW_key ].prev = RGFW_keyboard [RGFW_key ].current ;
4426
4442
RGFW_keyboard [RGFW_key ].current = state ;
@@ -4764,6 +4780,10 @@ static const struct wl_callback_listener wl_surface_frame_listener = {
4764
4780
4765
4781
win -> src .eventIndex = 0 ;
4766
4782
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
4767
4787
4768
4788
return win ;
4769
4789
}
@@ -5606,6 +5626,10 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */
5606
5626
wglShareLists (RGFW_root -> src .ctx , win -> src .ctx );
5607
5627
#endif
5608
5628
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
+
5609
5633
return win ;
5610
5634
}
5611
5635
@@ -6208,6 +6232,10 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */
6208
6232
monitor .physW = GetSystemMetrics (SM_CYSCREEN ) / (float ) ppiX ;
6209
6233
monitor .physH = GetSystemMetrics (SM_CXSCREEN ) / (float ) ppiY ;
6210
6234
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
+
6211
6239
return monitor ;
6212
6240
}
6213
6241
#endif /* RGFW_NO_MONITOR */
@@ -6738,7 +6766,6 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */
6738
6766
typedef void NSDraggingInfo ;
6739
6767
typedef void NSWindow ;
6740
6768
typedef void NSApplication ;
6741
- typedef void NSScreen ;
6742
6769
typedef void NSEvent ;
6743
6770
typedef void NSString ;
6744
6771
typedef void NSOpenGLContext ;
@@ -7210,7 +7237,7 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */
7210
7237
return false;
7211
7238
}
7212
7239
7213
- static void NSMoveToResourceDir (void ) {
7240
+ void NSMoveToResourceDir (void ) {
7214
7241
/* sourced from glfw */
7215
7242
char resourcesPath [255 ];
7216
7243
@@ -7497,6 +7524,10 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */
7497
7524
NSRetain (win -> src .window );
7498
7525
NSRetain (NSApp );
7499
7526
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
+
7500
7531
return win ;
7501
7532
}
7502
7533
@@ -8097,7 +8128,7 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */
8097
8128
return objc_msgSend_bool (win -> src .window , sel_registerName ("isZoomed" ));
8098
8129
}
8099
8130
8100
- static RGFW_monitor RGFW_NSCreateMonitor (CGDirectDisplayID display ) {
8131
+ RGFW_monitor RGFW_NSCreateMonitor (CGDirectDisplayID display ) {
8101
8132
RGFW_monitor monitor ;
8102
8133
8103
8134
CGRect bounds = CGDisplayBounds (display );
@@ -8111,19 +8142,23 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */
8111
8142
float dpi_height = round ((double )monitor .rect .h /(double )monitor .physH );
8112
8143
8113
8144
monitor .scaleX = (float ) (dpi_width ) / (float ) 96 ;
8114
- monitor .scaleY = (float ) (dpi_height ) / (float ) 96 ;
8145
+ monitor .scaleY = (float ) (dpi_height ) / (float ) 96 ;
8115
8146
8116
8147
if (isinf (monitor .scaleX ) || (monitor .scaleX > 1 && monitor .scaleX < 1.1 ))
8117
8148
monitor .scaleX = 1 ;
8118
8149
8119
8150
if (isinf (monitor .scaleY ) || (monitor .scaleY > 1 && monitor .scaleY < 1.1 ))
8120
8151
monitor .scaleY = 1 ;
8121
8152
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
+
8122
8157
return monitor ;
8123
8158
}
8124
8159
8125
8160
8126
- static RGFW_monitor RGFW_monitors [7 ];
8161
+ RGFW_monitor RGFW_monitors [7 ];
8127
8162
8128
8163
RGFW_monitor * RGFW_getMonitors (void ) {
8129
8164
static CGDirectDisplayID displays [7 ];
@@ -8778,6 +8813,10 @@ RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, u16 args) {
8778
8813
RGFW_window_resize (win , RGFW_getScreenSize ());
8779
8814
}
8780
8815
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
+
8781
8820
return win ;
8782
8821
}
8783
8822
@@ -9099,6 +9138,8 @@ RGFW_monitor RGFW_window_getMonitor(RGFW_window* win) { RGFW_UNUSED(win) return
9099
9138
void RGFW_joinThread (RGFW_thread thread ) { pthread_join ((pthread_t ) thread , NULL ); }
9100
9139
#ifdef __linux__
9101
9140
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 ); }
9102
9143
#endif
9103
9144
#endif
9104
9145
0 commit comments