-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRGFW.h
More file actions
12559 lines (10314 loc) · 470 KB
/
RGFW.h
File metadata and controls
12559 lines (10314 loc) · 470 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
*
* RGFW 1.8.0-dev
* Copyright (C) 2022-25 Riley Mabb (@ColleagueRiley)
*
* libpng license
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
* 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.
*
*
*/
/*
(MAKE SURE RGFW_IMPLEMENTATION is in exactly one header or you use -D RGFW_IMPLEMENTATION)
#define RGFW_IMPLEMENTATION - makes it so source code is included with header
*/
/*
#define RGFW_IMPLEMENTATION - (required) makes it so the source code is included
#define RGFW_DEBUG - (optional) makes it so RGFW prints debug messages and errors when they're found
#define RGFW_EGL - (optional) compile with OpenGL functions, allowing you to use to use EGL instead of the native OpenGL functions
#define RGFW_DIRECTX - (optional) include integration directX functions (windows only)
#define RGFW_VULKAN - (optional) include helpful vulkan integration functions and macros
#define RGFW_WEBGPU - (optional) use WebGPU for rendering
#define RGFW_NATIVE - (optional) define native RGFW types that use native API structures
#define RGFW_X11 (optional) (unix only) if X11 should be used. This option is turned on by default by unix systems except for MacOS
#define RGFW_WAYLAND (optional) (unix only) use Wayland. (This can be used with X11)
#define RGFW_NO_X11 (optional) (unix only) don't fallback to X11 when using Wayland
#define RGFW_NO_LOAD_WGL (optional) (windows only) if WGL should be loaded dynamically during runtime
#define RGFW_NO_X11_CURSOR (optional) (unix only) don't use XCursor
#define RGFW_NO_X11_CURSOR_PRELOAD (optional) (unix only) use XCursor, but don't link it in code, (you'll have to link it with -lXcursor)
#define RGFW_NO_X11_EXT_PRELOAD (optional) (unix only) use Xext, but don't link it in code, (you'll have to link it with -lXext)
#define RGFW_NO_LOAD_WINMM (optional) (windows only) use winmm (timeBeginPeriod), but don't link it in code, (you'll have to link it with -lwinmm)
#define RGFW_NO_WINMM (optional) (windows only) don't use winmm
#define RGFW_NO_IOKIT (optional) (macOS) don't use IOKit
#define RGFW_NO_UNIX_CLOCK (optional) (unix) don't link unix clock functions
#define RGFW_NO_DWM (windows only) - do not use or link dwmapi
#define RGFW_USE_XDL (optional) (X11) if XDL (XLib Dynamic Loader) should be used to load X11 dynamically during runtime (must include XDL.h along with RGFW)
#define RGFW_COCOA_GRAPHICS_SWITCHING - (optional) (cocoa) use automatic graphics switching (allow the system to choose to use GPU or iGPU)
#define RGFW_COCOA_FRAME_NAME (optional) (cocoa) set frame name
#define RGFW_NO_DPI - do not calculate DPI (no XRM nor libShcore included)
#define RGFW_ADVANCED_SMOOTH_RESIZE - use advanced methods for smooth resizing (may result in a spike in memory usage or worse performance) (eg. WM_TIMER and XSyncValue)
#define RGFW_NO_INFO - do not define the RGFW_info struct (without RGFW_IMPLEMENTATION)
#define RGFW_ALLOC x - choose the default allocation function (defaults to standard malloc)
#define RGFW_FREE x - choose the default deallocation function (defaults to standard free)
#define RGFW_USERPTR x - choose the default userptr sent to the malloc call, (NULL by default)
#define RGFW_EXPORT - use when building RGFW
#define RGFW_IMPORT - use when linking with RGFW (not as a single-header)
#define RGFW_USE_INT - force the use c-types rather than stdint.h (for systems that might not have stdint.h (msvc))
#define RGFW_bool x - choose what type to use for bool, by default u32 is used
*/
/*
Example to get you started :
linux : gcc main.c -lX11 -lXrandr -lGL
windows : gcc main.c -lopengl32 -lgdi32
macos : gcc main.c -framework Cocoa -framework CoreVideo -framework OpenGL -framework IOKit
#define RGFW_IMPLEMENTATION
#include "RGFW.h"
u8 icon[4 * 3 * 3] = {0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF};
int main() {
RGFW_window* win = RGFW_createWindow("name", 100, 100, 500, 500, (u64)0);
RGFW_event event;
RGFW_window_setExitKey(win, RGFW_escape);
RGFW_window_setIcon(win, icon, 3, 3, RGFW_formatRGBA8);
while (RGFW_window_shouldClose(win) == RGFW_FALSE) {
while (RGFW_window_checkEvent(win, &event)) {
if (event.type == RGFW_quit)
break;
}
}
RGFW_window_close(win);
}
compiling :
if you wish to compile the library all you have to do is create a new file with this in it
rgfw.c
#define RGFW_IMPLEMENTATION
#include "RGFW.h"
You may also want to add
`#define RGFW_EXPORT` when compiling and
`#define RGFW_IMPORT`when linking RGFW on it's own:
this reduces inline functions and prevents bloat in the object file
then you can use gcc (or whatever compile you wish to use) to compile the library into object file
ex. gcc -c RGFW.c -fPIC
after you compile the library into an object file, you can also turn the object file into an static or shared library
(commands ar and gcc can be replaced with whatever equivalent your system uses)
static : ar rcs RGFW.a RGFW.o
shared :
windows:
gcc -shared RGFW.o -lopengl32 -lgdi32 -o RGFW.dll
linux:
gcc -shared RGFW.o -lX11 -lGL -lXrandr -o RGFW.so
macos:
gcc -shared RGFW.o -framework CoreVideo -framework Cocoa -framework OpenGL -framework IOKit
*/
/*
Credits :
EimaMei/Sacode : Code review, helped with X11, MacOS and Windows support, Silicon, siliapp.h -> referencing
stb : This project is heavily inspired by the stb single header files
SDL, GLFW and other online resources : reference implementations
contributors : (feel free to put yourself here if you contribute)
krisvers (@krisvers) -> code review
EimaMei (@SaCode) -> code review
Nycticebus (@Code-Nycticebus) -> bug fixes
Rob Rohan (@robrohan) -> X11 bugs and missing features, MacOS/Cocoa fixing memory issues/bugs
AICDG (@THISISAGOODNAME) -> vulkan support (example)
@Easymode -> support, testing/debugging, bug fixes and reviews
Joshua Rowe (omnisci3nce) - bug fix, review (macOS)
@lesleyrs -> bug fix, review (OpenGL)
Nick Porcino (@meshula) - testing, organization, review (MacOS, examples)
@therealmarrakesh -> documentation
@DarekParodia -> code review (X11) (C++)
@NishiOwO -> fix BSD support, fix OSMesa example
@BaynariKattu -> code review and documentation
Miguel Pinto (@konopimi) -> code review, fix vulkan example
@m-doescode -> code review (wayland)
Robert Gonzalez (@uni-dos) -> code review (wayland)
@TheLastVoyager -> code review
@yehoravramenko -> code review (winapi)
@halocupcake -> code review (OpenGL)
@GideonSerf -> documentation
Alexandre Almeida (@M374LX) -> code review (keycodes)
Vũ Xuân Trường (@wanwanvxt) -> code review (winapi)
Lucas (@lightspeedlucas) -> code review (msvc++)
Jeffery Myers (@JeffM2501) -> code review (msvc)
Zeni (@zenitsuyo) -> documentation
TheYahton (@TheYahton) -> documentation
nonexistant_object (@DiarrheaMcgee
*/
#if _MSC_VER
#pragma comment(lib, "gdi32")
#pragma comment(lib, "shell32")
#pragma comment(lib, "User32")
#pragma warning( push )
#pragma warning( disable : 4996 4191 4127)
#if _MSC_VER < 600
#define RGFW_C89
#endif
#else
#if defined(__STDC__) && !defined(__STDC_VERSION__)
#define RGFW_C89
#endif
#endif
#if defined(RGFW_EGL) && !defined(RGFW_OPENGL)
#define RGFW_OPENGL
#endif
/* these OS macros look better & are standardized */
/* plus it helps with cross-compiling */
#ifdef __EMSCRIPTEN__
#define RGFW_WASM
#endif
#if defined(RGFW_X11) && defined(__APPLE__) && !defined(RGFW_CUSTOM_BACKEND)
#define RGFW_MACOS_X11
#define RGFW_UNIX
#endif
#if defined(_WIN32) && !defined(RGFW_X11) && !defined(RGFW_UNIX) && !defined(RGFW_WASM) && !defined(RGFW_CUSTOM_BACKEND) /* (if you're using X11 on windows some how) */
#define RGFW_WINDOWS
#endif
#if defined(RGFW_WAYLAND)
#define RGFW_DEBUG /* wayland will be in debug mode by default for now */
#define RGFW_UNIX
#ifdef RGFW_OPENGL
#define RGFW_EGL
#endif
#ifdef RGFW_X11
#define RGFW_DYNAMIC
#endif
#endif
#if (!defined(RGFW_WAYLAND) && !defined(RGFW_X11)) && (defined(__unix__) || defined(RGFW_MACOS_X11) || defined(RGFW_X11)) && !defined(RGFW_WASM) && !defined(RGFW_CUSTOM_BACKEND)
#define RGFW_MACOS_X11
#define RGFW_X11
#define RGFW_UNIX
#elif defined(__APPLE__) && !defined(RGFW_MACOS_X11) && !defined(RGFW_X11) && !defined(RGFW_WASM) && !defined(RGFW_CUSTOM_BACKEND)
#define RGFW_MACOS
#endif
#if !defined(RGFW_SNPRINTF) && (defined(RGFW_X11) || defined(RGFW_WAYLAND))
/* required for X11 errors */
#include <stdio.h>
#define RGFW_SNPRINTF snprintf
#endif
#ifndef RGFW_USERPTR
#define RGFW_USERPTR NULL
#endif
#ifndef RGFW_UNUSED
#define RGFW_UNUSED(x) (void)(x)
#endif
#ifndef RGFW_ROUND
#define RGFW_ROUND(x) (i32)((x) >= 0 ? (x) + 0.5f : (x) - 0.5f)
#endif
#ifndef RGFW_MIN
#define RGFW_MIN(x, y) ((x < y) ? x : y)
#endif
#ifndef RGFW_ALLOC
#include <stdlib.h>
#define RGFW_ALLOC malloc
#define RGFW_FREE free
#endif
#ifndef RGFW_ASSERT
#include <assert.h>
#define RGFW_ASSERT assert
#endif
#if !defined(RGFW_MEMCPY) || !defined(RGFW_STRNCMP) || !defined(RGFW_STRNCPY) || !defined(RGFW_MEMSET)
#include <string.h>
#endif
#ifndef RGFW_MEMSET
#define RGFW_MEMSET(ptr, value, num) memset(ptr, value, num)
#endif
#ifndef RGFW_MEMCPY
#define RGFW_MEMCPY(dist, src, len) memcpy(dist, src, len)
#endif
#ifndef RGFW_STRNCMP
#define RGFW_STRNCMP(s1, s2, max) strncmp(s1, s2, max)
#endif
#ifndef RGFW_STRNCPY
#define RGFW_STRNCPY(dist, src, len) strncpy(dist, src, len)
#endif
#ifndef RGFW_STRSTR
#define RGFW_STRSTR(str, substr) strstr(str, substr)
#endif
#ifndef RGFW_STRTOL
/* required for X11 XDnD and X11 Monitor DPI */
#include <stdlib.h>
#define RGFW_STRTOL(str, endptr, base) strtol(str, endptr, base)
#define RGFW_ATOF(num) atof(num)
#endif
#if !defined(RGFW_PRINTF) && ( defined(RGFW_DEBUG) || defined(RGFW_WAYLAND) )
/* required when using RGFW_DEBUG */
#include <stdio.h>
#define RGFW_PRINTF printf
#endif
#ifndef RGFW_MAX_PATH
#define RGFW_MAX_PATH 260 /* max length of a path (for drag andn drop) */
#endif
#ifndef RGFW_MAX_DROPS
#define RGFW_MAX_DROPS 260 /* max items you can drop at once */
#endif
#ifndef RGFW_COCOA_FRAME_NAME
#define RGFW_COCOA_FRAME_NAME NULL
#endif
#ifdef RGFW_WIN95 /* for windows 95 testing (not that it really works) */
#define RGFW_NO_MONITOR
#define RGFW_NO_PASSTHROUGH
#endif
#if defined(RGFW_EXPORT) || defined(RGFW_IMPORT)
#if defined(_WIN32)
#if defined(__TINYC__) && (defined(RGFW_EXPORT) || defined(RGFW_IMPORT))
#define __declspec(x) __attribute__((x))
#endif
#if defined(RGFW_EXPORT)
#define RGFWDEF __declspec(dllexport)
#else
#define RGFWDEF __declspec(dllimport)
#endif
#else
#if defined(RGFW_EXPORT)
#define RGFWDEF __attribute__((visibility("default")))
#endif
#endif
#ifndef RGFWDEF
#define RGFWDEF
#endif
#endif
#ifndef RGFWDEF
#ifdef RGFW_C89
#define RGFWDEF __inline
#else
#define RGFWDEF inline
#endif
#endif
#if defined(__cplusplus) && !defined(__EMSCRIPTEN__)
extern "C" {
#endif
/* makes sure the header file part is only defined once by default */
#ifndef RGFW_HEADER
#define RGFW_HEADER
#include <stddef.h>
#ifndef RGFW_INT_DEFINED
#ifdef RGFW_USE_INT /* optional for any system that might not have stdint.h */
typedef unsigned char u8;
typedef signed char i8;
typedef unsigned short u16;
typedef signed short i16;
typedef unsigned long int u32;
typedef signed long int i32;
typedef unsigned long long u64;
typedef signed long long i64;
#else /* use stdint standard types instead of c "standard" types */
#include <stdint.h>
typedef uint8_t u8;
typedef int8_t i8;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint32_t u32;
typedef int32_t i32;
typedef uint64_t u64;
typedef int64_t i64;
#endif
#define RGFW_INT_DEFINED
#endif
#ifndef RGFW_BOOL_DEFINED
#define RGFW_BOOL_DEFINED
typedef u8 RGFW_bool;
#endif
#define RGFW_BOOL(x) (RGFW_bool)((x) != 0) /* force a value to be 0 or 1 */
#define RGFW_TRUE (RGFW_bool)1
#define RGFW_FALSE (RGFW_bool)0
#define RGFW_ENUM(type, name) type name; enum
#define RGFW_BIT(x) (1 << (x))
/* runs whatever RGFW_ALLOC was/is at compile time */
RGFWDEF void* RGFW_alloc(size_t size);
/* runs whatever RGFW_FREE was/is at compile time */
RGFWDEF void RGFW_free(void* ptr);
typedef struct RGFW_window RGFW_window;
typedef struct RGFW_window_src RGFW_window_src;
RGFWDEF size_t RGFW_sizeofWindow(void);
RGFWDEF size_t RGFW_sizeofWindowSrc(void);
/*! (unix) Toggle use of wayland. This will be on by default if you use `RGFW_WAYLAND` (if you don't use RGFW_WAYLAND, you don't expose WAYLAND functions)
this is mostly used to allow you to force the use of XWayland
*/
RGFWDEF void RGFW_useWayland(RGFW_bool wayland);
RGFWDEF RGFW_bool RGFW_usingWayland(void);
/*! These functions return data from _RGFW.
* They return NULL if the platform is not in use (e.g. when trying to get OSX data on Windows).
* */
RGFWDEF void* RGFW_getLayer_OSX(void);
RGFWDEF void* RGFW_getDisplay_X11(void);
RGFWDEF struct wl_display* RGFW_getDisplay_Wayland(void);
/*!
* the class name for X11 and WinAPI. apps with the same class will be grouped by the WM
* by default the class name will == the root window's name
*/
RGFWDEF void RGFW_setClassName(const char* name);
RGFWDEF void RGFW_setXInstName(const char* name); /*!< X11 instance name (window name will by used by default) */
/*! (cocoa only) change directory to resource folder */
RGFWDEF void RGFW_moveToMacOSResourceDir(void);
typedef RGFW_ENUM(u8, RGFW_format) {
RGFW_formatRGB8 = 0, /*!< 8-bit RGB (3 channels) */
RGFW_formatBGR8, /*!< 8-bit BGR (3 channels) */
RGFW_formatRGBA8, /*!< 8-bit RGBA (4 channels) */
RGFW_formatARGB8, /*!< 8-bit RGBA (4 channels) */
RGFW_formatBGRA8, /*!< 8-bit BGRA (4 channels) */
RGFW_formatABGR8, /*!< 8-bit BGRA (4 channels) */
RGFW_formatCount
};
/*! copy image to another image, respecting each image's format */
RGFWDEF void RGFW_copyImageData(u8* dest_data, i32 w, i32 h, RGFW_format dest_format, u8* src_data, RGFW_format src_format);
typedef struct RGFW_nativeImage RGFW_nativeImage;
RGFWDEF size_t RGFW_sizeofNativeImage(void);
typedef struct RGFW_surface RGFW_surface;
RGFWDEF size_t RGFW_sizeofSurface(void);
/*
* NOTE: when you create a surface using RGFW_createSurface / ptr, on X11 it uses the root window's visual
* this means it may fail to render on any other window if the visual does not match
* RGFW_window_createSurface and RGFW_window_createSurfacePtr exist only for X11 to address this issues
* Of course, you can also manually set the root window with RGFW_setRootWindow
*/
RGFWDEF RGFW_surface* RGFW_createSurface(u8* data, i32 w, i32 h, RGFW_format format);
RGFWDEF RGFW_bool RGFW_createSurfacePtr(u8* data, i32 w, i32 h, RGFW_format format, RGFW_surface* surface);
RGFWDEF RGFW_nativeImage* RGFW_surface_getNativeImage(RGFW_surface* surface);
/*! free the surface pointer and buffers used for software rendering within the window */
RGFWDEF void RGFW_surface_free(RGFW_surface* surface);
/*! free only the buffers used for software rendering within the window */
RGFWDEF void RGFW_surface_freePtr(RGFW_surface* surface);
/* RGFW mouse loading */
typedef void RGFW_mouse;
/*!< loads mouse icon from bitmap (similar to RGFW_window_setIcon). Icon NOT resized by default */
RGFWDEF RGFW_mouse* RGFW_loadMouse(u8* data, i32 w, i32 h, RGFW_format format);
/*!< frees RGFW_mouse data */
RGFWDEF void RGFW_freeMouse(RGFW_mouse* mouse);
#ifndef RGFW_NO_MONITOR
#ifndef RGFW_MAX_MONITORS
#define RGFW_MAX_MONITORS 6
#endif
/* monitor mode data | can be changed by the user (with functions)*/
typedef struct RGFW_monitorMode {
i32 w, h; /*!< monitor workarea size */
u32 refreshRate; /*!< monitor refresh rate */
u8 red, blue, green;
} RGFW_monitorMode;
/*! structure for monitor data */
typedef struct RGFW_monitor {
i32 x, y; /*!< x - y of the monitor workarea */
char name[128]; /*!< monitor name */
float scaleX, scaleY; /*!< monitor content scale */
float pixelRatio; /*!< pixel ratio for monitor (1.0 for regular, 2.0 for hiDPI) */
float physW, physH; /*!< monitor physical size in inches */
RGFW_monitorMode mode;
} RGFW_monitor;
/*! get an array of all the monitors (max 6) */
RGFWDEF RGFW_monitor* RGFW_getMonitors(size_t* len);
/*! get the primary monitor */
RGFWDEF RGFW_monitor RGFW_getPrimaryMonitor(void);
typedef RGFW_ENUM(u8, RGFW_modeRequest) {
RGFW_monitorScale = RGFW_BIT(0), /*!< scale the monitor size */
RGFW_monitorRefresh = RGFW_BIT(1), /*!< change the refresh rate */
RGFW_monitorRGB = RGFW_BIT(2), /*!< change the monitor RGB bits size */
RGFW_monitorAll = RGFW_monitorScale | RGFW_monitorRefresh | RGFW_monitorRGB
};
/*! request a specific mode */
RGFWDEF RGFW_bool RGFW_monitor_requestMode(RGFW_monitor mon, RGFW_monitorMode mode, RGFW_modeRequest request);
/*! check if 2 monitor modes are the same */
RGFWDEF RGFW_bool RGFW_monitorModeCompare(RGFW_monitorMode mon, RGFW_monitorMode mon2, RGFW_modeRequest request);
/*! scale monitor to window size */
RGFWDEF RGFW_bool RGFW_monitor_scaleToWindow(RGFW_monitor mon, struct RGFW_window* win);
#endif
/*!
key codes and mouse icon enums
*/
typedef RGFW_ENUM(u8, RGFW_key) {
RGFW_keyNULL = 0,
RGFW_escape = '\033',
RGFW_backtick = '`',
RGFW_0 = '0',
RGFW_1 = '1',
RGFW_2 = '2',
RGFW_3 = '3',
RGFW_4 = '4',
RGFW_5 = '5',
RGFW_6 = '6',
RGFW_7 = '7',
RGFW_8 = '8',
RGFW_9 = '9',
RGFW_minus = '-',
RGFW_equals = '=',
RGFW_backSpace = '\b',
RGFW_tab = '\t',
RGFW_space = ' ',
RGFW_a = 'a',
RGFW_b = 'b',
RGFW_c = 'c',
RGFW_d = 'd',
RGFW_e = 'e',
RGFW_f = 'f',
RGFW_g = 'g',
RGFW_h = 'h',
RGFW_i = 'i',
RGFW_j = 'j',
RGFW_k = 'k',
RGFW_l = 'l',
RGFW_m = 'm',
RGFW_n = 'n',
RGFW_o = 'o',
RGFW_p = 'p',
RGFW_q = 'q',
RGFW_r = 'r',
RGFW_s = 's',
RGFW_t = 't',
RGFW_u = 'u',
RGFW_v = 'v',
RGFW_w = 'w',
RGFW_x = 'x',
RGFW_y = 'y',
RGFW_z = 'z',
RGFW_period = '.',
RGFW_comma = ',',
RGFW_slash = '/',
RGFW_bracket = '[',
RGFW_closeBracket = ']',
RGFW_semicolon = ';',
RGFW_apostrophe = '\'',
RGFW_backSlash = '\\',
RGFW_return = '\n',
RGFW_enter = RGFW_return,
RGFW_delete = '\177', /* 127 */
RGFW_F1,
RGFW_F2,
RGFW_F3,
RGFW_F4,
RGFW_F5,
RGFW_F6,
RGFW_F7,
RGFW_F8,
RGFW_F9,
RGFW_F10,
RGFW_F11,
RGFW_F12,
RGFW_F13,
RGFW_F14,
RGFW_F15,
RGFW_F16,
RGFW_F17,
RGFW_F18,
RGFW_F19,
RGFW_F20,
RGFW_F21,
RGFW_F22,
RGFW_F23,
RGFW_F24,
RGFW_F25,
RGFW_capsLock,
RGFW_shiftL,
RGFW_controlL,
RGFW_altL,
RGFW_superL,
RGFW_shiftR,
RGFW_controlR,
RGFW_altR,
RGFW_superR,
RGFW_up,
RGFW_down,
RGFW_left,
RGFW_right,
RGFW_insert,
RGFW_menu,
RGFW_end,
RGFW_home,
RGFW_pageUp,
RGFW_pageDown,
RGFW_numLock,
RGFW_kpSlash,
RGFW_kpMultiply,
RGFW_kpPlus,
RGFW_kpMinus,
RGFW_kpEqual,
RGFW_kp1,
RGFW_kp2,
RGFW_kp3,
RGFW_kp4,
RGFW_kp5,
RGFW_kp6,
RGFW_kp7,
RGFW_kp8,
RGFW_kp9,
RGFW_kp0,
RGFW_kpPeriod,
RGFW_kpReturn,
RGFW_scrollLock,
RGFW_printScreen,
RGFW_pause,
RGFW_world1,
RGFW_world2,
RGFW_keyLast = 256 /* padding for alignment ~(175 by default) */
};
/*! mouse button codes (RGFW_event.button.value) */
typedef RGFW_ENUM(u8, RGFW_mouseButton) {
RGFW_mouseLeft = 0, /*!< left mouse button is pressed */
RGFW_mouseMiddle, /*!< mouse-wheel-button is pressed */
RGFW_mouseRight, /*!< right mouse button is pressed */
RGFW_mouseMisc1, RGFW_mouseMisc2, RGFW_mouseMisc3, RGFW_mouseMisc4, RGFW_mouseMisc5,
RGFW_mouseFinal
};
/* for RGFW_event.lockstate */
typedef RGFW_ENUM(u8, RGFW_keymod) {
RGFW_modCapsLock = RGFW_BIT(0),
RGFW_modNumLock = RGFW_BIT(1),
RGFW_modControl = RGFW_BIT(2),
RGFW_modAlt = RGFW_BIT(3),
RGFW_modShift = RGFW_BIT(4),
RGFW_modSuper = RGFW_BIT(5),
RGFW_modScrollLock = RGFW_BIT(6)
};
typedef RGFW_ENUM(u8, RGFW_eventType) {
/*! event codes */
RGFW_eventNone = 0, /*!< no event has been sent */
RGFW_keyPressed, /* a key has been pressed */
RGFW_keyReleased, /*!< a key has been released */
/*! key event note
the code of the key pressed is stored in
RGFW_event.key.value
!!Keycodes defined at the bottom of the RGFW_HEADER part of this file!!
while a string version is stored in
RGFW_event.key.valueString
RGFW_event.key.mod holds the current mod
this means if CapsLock, NumLock are active or not
*/
RGFW_mouseButtonPressed, /*!< a mouse button has been pressed (left,middle,right) */
RGFW_mouseButtonReleased, /*!< a mouse button has been released (left,middle,right) */
RGFW_mouseScroll, /*!< a mouse scroll event */
RGFW_mousePosChanged, /*!< the position of the mouse has been changed */
/*! mouse event note
the x and y of the mouse can be found in the vector, RGFW_x, y
RGFW_event.button.value holds which mouse button was pressed
*/
RGFW_windowMoved, /*!< the window was moved (by the user) */
RGFW_windowResized, /*!< the window was resized (by the user), [on WASM this means the browser was resized] */
RGFW_focusIn, /*!< window is in focus now */
RGFW_focusOut, /*!< window is out of focus now */
RGFW_mouseEnter, /* mouse entered the window */
RGFW_mouseLeave, /* mouse left the window */
RGFW_windowRefresh, /* The window content needs to be refreshed */
/* attribs change event note
The event data is sent straight to the window structure
with win->x, win->y, win->w and win->h
*/
RGFW_quit, /*!< the user clicked the quit button */
RGFW_dataDrop, /*!< a file has been dropped into the window */
RGFW_dataDrag, /*!< the start of a drag and drop event, when the file is being dragged */
/* drop data note
The x and y coords of the drop are stored in the vector RGFW_x, y
RGFW_event.drop.count holds how many files were dropped
This is also the size of the array which stores all the dropped file string,
RGFW_event.drop.files
*/
RGFW_windowMaximized, /*!< the window was maximized */
RGFW_windowMinimized, /*!< the window was minimized */
RGFW_windowRestored, /*!< the window was restored */
RGFW_scaleUpdated /*!< content scale factor changed */
};
typedef RGFW_ENUM(u32, RGFW_eventFlag) {
RGFW_keyPressedFlag = RGFW_BIT(RGFW_keyPressed),
RGFW_keyReleasedFlag = RGFW_BIT(RGFW_keyReleased),
RGFW_mouseScrollFlag = RGFW_BIT(RGFW_mouseScroll),
RGFW_mouseButtonPressedFlag = RGFW_BIT(RGFW_mouseButtonPressed),
RGFW_mouseButtonReleasedFlag = RGFW_BIT(RGFW_mouseButtonReleased),
RGFW_mousePosChangedFlag = RGFW_BIT(RGFW_mousePosChanged),
RGFW_mouseEnterFlag = RGFW_BIT(RGFW_mouseEnter),
RGFW_mouseLeaveFlag = RGFW_BIT(RGFW_mouseLeave),
RGFW_windowMovedFlag = RGFW_BIT(RGFW_windowMoved),
RGFW_windowResizedFlag = RGFW_BIT(RGFW_windowResized),
RGFW_focusInFlag = RGFW_BIT(RGFW_focusIn),
RGFW_focusOutFlag = RGFW_BIT(RGFW_focusOut),
RGFW_windowRefreshFlag = RGFW_BIT(RGFW_windowRefresh),
RGFW_windowMaximizedFlag = RGFW_BIT(RGFW_windowMaximized),
RGFW_windowMinimizedFlag = RGFW_BIT(RGFW_windowMinimized),
RGFW_windowRestoredFlag = RGFW_BIT(RGFW_windowRestored),
RGFW_scaleUpdatedFlag = RGFW_BIT(RGFW_scaleUpdated),
RGFW_quitFlag = RGFW_BIT(RGFW_quit),
RGFW_dataDropFlag = RGFW_BIT(RGFW_dataDrop),
RGFW_dataDragFlag = RGFW_BIT(RGFW_dataDrag),
RGFW_keyEventsFlag = RGFW_keyPressedFlag | RGFW_keyReleasedFlag,
RGFW_mouseEventsFlag = RGFW_mouseButtonPressedFlag | RGFW_mouseButtonReleasedFlag | RGFW_mousePosChangedFlag | RGFW_mouseEnterFlag | RGFW_mouseLeaveFlag | RGFW_mouseScrollFlag ,
RGFW_windowEventsFlag = RGFW_windowMovedFlag | RGFW_windowResizedFlag | RGFW_windowRefreshFlag | RGFW_windowMaximizedFlag | RGFW_windowMinimizedFlag | RGFW_windowRestoredFlag | RGFW_scaleUpdatedFlag,
RGFW_focusEventsFlag = RGFW_focusInFlag | RGFW_focusOutFlag,
RGFW_dataDropEventsFlag = RGFW_dataDropFlag | RGFW_dataDragFlag,
RGFW_allEventFlags = RGFW_keyEventsFlag | RGFW_mouseEventsFlag | RGFW_windowEventsFlag | RGFW_focusEventsFlag | RGFW_dataDropEventsFlag | RGFW_quitFlag
};
/*! Event structure(s) and union for checking/getting events */
typedef struct RGFW_commonEvent {
RGFW_eventType type; /*!< which event has been sent?*/
RGFW_window* win; /*!< the window this event applies too (for event queue events) */
} RGFW_commonEvent;
typedef struct RGFW_mouseButtonEvent {
RGFW_eventType type; /*!< which event has been sent?*/
RGFW_window* win; /*!< the window this event applies too (for event queue events) */
u8 value; /* !< which mouse button was pressed */
} RGFW_mouseButtonEvent;
typedef struct RGFW_mouseScrollEvent {
RGFW_eventType type; /*!< which event has been sent?*/
RGFW_window* win; /*!< the window this event applies too (for event queue events) */
float x, y; /*!< the raw mouse scroll value */
} RGFW_mouseScrollEvent;
typedef struct RGFW_mousePosEvent {
RGFW_eventType type; /*!< which event has been sent?*/
RGFW_window* win; /*!< the window this event applies too (for event queue events) */
i32 x, y; /*!< mouse x, y of event (or drop point) */
float vecX, vecY; /*!< raw mouse movement */
} RGFW_mousePosEvent;
typedef struct RGFW_keyEvent {
RGFW_eventType type; /*!< which event has been sent?*/
RGFW_window* win; /*!< the window this event applies too (for event queue events) */
RGFW_key value; /*!< the physical key of the event, refers to where key is physically !!Keycodes defined at the bottom of the RGFW_HEADER part of this file!! */
u8 sym; /*!< mapped key char of the event */
RGFW_bool repeat; /*!< key press event repeated (the key is being held) */
RGFW_keymod mod;
} RGFW_keyEvent;
typedef struct RGFW_dataDropEvent {
RGFW_eventType type; /*!< which event has been sent?*/
RGFW_window* win; /*!< the window this event applies too (for event queue events) */
/* 260 max paths with a max length of 260 */
char** files; /*!< dropped files */
size_t count; /*!< how many files were dropped */
} RGFW_dataDropEvent;
typedef struct RGFW_dataDragEvent {
RGFW_eventType type; /*!< which event has been sent?*/
RGFW_window* win; /*!< the window this event applies too (for event queue events) */
i32 x, y; /*!< mouse x, y of event (or drop point) */
} RGFW_dataDragEvent;
typedef struct RGFW_scaleUpdatedEvent {
RGFW_eventType type; /*!< which event has been sent?*/
RGFW_window* win; /*!< the window this event applies too (for event queue events) */
float x, y; /*!< DPI scaling */
} RGFW_scaleUpdatedEvent;
/*! RGFW_event union */
typedef union RGFW_event {
RGFW_eventType type; /*!< which event has been sent?*/
RGFW_commonEvent common; /*!< common event data (e.g.) type and win */
RGFW_mouseButtonEvent button; /*!< data for a button press/release */
RGFW_mouseScrollEvent scroll; /*!< data for a mouse scroll */
RGFW_mousePosEvent mouse; /*!< data for mouse motion events */
RGFW_keyEvent key; /*!< data for key press/release/hold events */
RGFW_dataDropEvent drop; /*!< dropping a file events */
RGFW_dataDragEvent drag; /* data for dragging a file events */
RGFW_scaleUpdatedEvent scale; /* data for monitor scaling events */
} RGFW_event;
/*!
for RGFW_the code is stupid and C++ waitForEvent
waitMS -> Allows the function to keep checking for events even after there are no more events
if waitMS == 0, the loop will not wait for events
if waitMS > 0, the loop will wait that many miliseconds after there are no more events until it returns
if waitMS == -1 or waitMS == the max size of an unsigned 32-bit int, the loop will not return until it gets another event
*/
typedef RGFW_ENUM(i32, RGFW_eventWait) {
RGFW_eventNoWait = 0,
RGFW_eventWaitNext = -1
};
/*! sleep until RGFW gets an event or the timer ends (defined by OS) */
RGFWDEF void RGFW_waitForEvent(i32 waitMS);
/*! if you you want events to be queued or not.
* This is enabled when the queue is checked with RGFW_window_checkQueuedEvent or RGFW_window_checkEvent
* Otherwise it's disabled by default */
RGFWDEF void RGFW_setQueueEvents(RGFW_bool queue);
/*!
check all the events until there are none left and updates window structure attributes
adds them to a queue for RGFW_window_checkEvent to check if queueEvents is true
*/
RGFWDEF void RGFW_pollEvents(void);
/*!
tell RGFW_waitForEvent to stop waiting (to be ran from another thread)
*/
RGFWDEF void RGFW_stopCheckEvents(void);
/** * @defgroup Input
* @{ */
RGFWDEF RGFW_bool RGFW_isKeyPressed(RGFW_key key); /*!< if key is pressed during the current frame (key code)*/
RGFWDEF RGFW_bool RGFW_isKeyDown(RGFW_key key); /*!< if key is held (key code) */
RGFWDEF RGFW_bool RGFW_isKeyReleased(RGFW_key key); /*!< if key is released (key code) */
/*! if a mouse button is pressed during the current frame */
RGFWDEF RGFW_bool RGFW_isMousePressed(RGFW_mouseButton button /*!< mouse button code */ );
/*! if a mouse button is down */
RGFWDEF RGFW_bool RGFW_isMouseDown(RGFW_mouseButton button /*!< mouse button code */ );
/*! if a mouse button was released */
RGFWDEF RGFW_bool RGFW_isMouseReleased(RGFW_mouseButton button /*!< mouse button code */ );
/*! get the current scroll value (of the frame) */
RGFWDEF void RGFW_getMouseScroll(float* x, float* y);
/*! get the current vector value (of the frame) */
RGFWDEF void RGFW_getMouseVector(float* x, float* y);
/** @} */
/*! Optional arguments for making a windows */
typedef RGFW_ENUM(u32, RGFW_windowFlags) {
RGFW_windowNoBorder = RGFW_BIT(0), /*!< the window doesn't have a border */
RGFW_windowNoResize = RGFW_BIT(1), /*!< the window cannot be resized by the user */
RGFW_windowAllowDND = RGFW_BIT(2), /*!< the window supports drag and drop */
RGFW_windowHideMouse = RGFW_BIT(3), /*! the window should hide the mouse (can be toggled later on using `RGFW_window_showMouse`) */
RGFW_windowFullscreen = RGFW_BIT(4), /*!< the window is fullscreen by default */
RGFW_windowTransparent = RGFW_BIT(5), /*!< the window is transparent (only properly works on X11 and MacOS, although it's meant for for windows) */
RGFW_windowCenter = RGFW_BIT(6), /*! center the window on the screen */
RGFW_windowScaleToMonitor = RGFW_BIT(8), /*! scale the window to the screen */
RGFW_windowHide = RGFW_BIT(9), /*! the window is hidden */
RGFW_windowMaximize = RGFW_BIT(10),
RGFW_windowCenterCursor = RGFW_BIT(11),
RGFW_windowFloating = RGFW_BIT(12), /*!< create a floating window */
RGFW_windowFocusOnShow = RGFW_BIT(13), /*!< focus the window when it's shown */
RGFW_windowMinimize = RGFW_BIT(14), /*!< focus the window when it's shown */
RGFW_windowFocus = RGFW_BIT(15), /*!< if the window is in focus */
RGFW_windowOpenGL = RGFW_BIT(17), /*!< create an OpenGL context (you can also do this manually with RGFW_window_createContext_OpenGL) */
RGFW_windowEGL = RGFW_BIT(18), /*!< create an EGL context (you can also do this manually with RGFW_window_createContext_EGL) */
RGFW_windowedFullscreen = RGFW_windowNoBorder | RGFW_windowMaximize
};
/* NOTE: (windows) if the executable has an icon resource named RGFW_ICON, it will be set as the initial icon for the window */
RGFWDEF RGFW_window* RGFW_createWindow(
const char* name, /* name of the window */
i32 x, i32 y, /* position of the window */
i32 w, i32 h, /* size of the window */
RGFW_windowFlags flags /* extra arguments ((u32)0 means no flags used)*/
); /*!< function to create a window and struct */
RGFWDEF RGFW_window* RGFW_createWindowPtr(
const char* name, /* name of the window */
i32 x, i32 y, /* position of the window */
i32 w, i32 h, /* size of the window */
RGFW_windowFlags flags, /* extra arguments (NULL / (u32)0 means no flags used) */
RGFW_window* win/* ptr to the fat window struct you want to use */
); /*!< function to create a window (without allocating a window struct) */
/*
* NOTE: when you create a surface using RGFW_createSurface / ptr, on X11 it uses the root window's visual
* this means it may fail to render on any other window if the visual does not match
* RGFW_window_createSurface and RGFW_window_createSurfacePtr exist only for X11 to address this issues
* Of course, you can also manually set the root window with RGFW_setRootWindow
*/
RGFWDEF RGFW_surface* RGFW_window_createSurface(RGFW_window* win, u8* data, i32 w, i32 h, RGFW_format format);
RGFWDEF RGFW_bool RGFW_window_createSurfacePtr(RGFW_window* win, u8* data, i32 w, i32 h, RGFW_format format, RGFW_surface* surface);
/*! render the software rendering buffer */
RGFWDEF void RGFW_window_blitSurface(RGFW_window* win, RGFW_surface* surface);
RGFWDEF RGFW_bool RGFW_window_getPosition(RGFW_window* win, i32* x, i32* y); /*!< gets the position of the window | with RGFW_window.x and window.y */
RGFWDEF RGFW_bool RGFW_window_getSize(RGFW_window* win, i32* w, i32* h); /*!< gets the size of the window | with RGFW_window.w and window.h */
RGFWDEF u32 RGFW_window_getFlags(RGFW_window* win); /*!< gets the flags of the window | returns RGFW_window._flags */
RGFWDEF RGFW_key RGFW_window_getExitKey(RGFW_window* win); /*!< get the exit key for the window | returns RGFW_window.exitKey */
RGFWDEF void RGFW_window_setExitKey(RGFW_window* win, RGFW_key key); /*!< set the exit key for the window |edits RGFW_window.exitKey */
/*! sets the types of events you want to receive, RGFW_allEventFlags by default (modifies RGFW_window._enabledEvents) */
RGFWDEF void RGFW_window_setEnabledEvents(RGFW_window* win, RGFW_eventFlag events);
/*! gets all enabled events RGFW_window._enabledEvents (returns RGFW_window._enabledEvents) */
RGFWDEF RGFW_eventFlag RGFW_window_getEnabledEvents(RGFW_window* win);
/*! enables all events and then disables select events (modifies RGFW_window._enabledEvents)*/
RGFWDEF void RGFW_window_setDisabledEvents(RGFW_window* win, RGFW_eventFlag events);
/*! directly enables or disabled a specific event, (or cluster of events) (modifies RGFW_window._enabledEvents */
RGFWDEF void RGFW_window_setEventState(RGFW_window* win, RGFW_eventFlag event, RGFW_bool state);
RGFWDEF void* RGFW_window_getUserPtr(RGFW_window* win); /*!< gets the userPtr of the window | returns RGFW_window.userPtr */
RGFWDEF void RGFW_window_setUserPtr(RGFW_window* win, void* ptr); /*!< sets the userPtr of the window | writes to RGFW_window.userPtr */
RGFWDEF RGFW_window_src* RGFW_window_getSrc(RGFW_window* win); /*!< returns fat pointer of window, which is sourced from the window casted to the fast pointer */
/* thiese functions return data from the `RGFW_window_src` object in `RGFW_window`, they return NULL if the platform is not in use.
* (e.g. when trying to get OSX data on Windows) */
RGFWDEF void RGFW_window_setLayer_OSX(RGFW_window* win, void* layer);
RGFWDEF void* RGFW_window_getView_OSX(RGFW_window* win);
RGFWDEF void* RGFW_window_getWindow_OSX(RGFW_window* win);
RGFWDEF void* RGFW_window_getHWND(RGFW_window* win);
RGFWDEF void* RGFW_window_getHDC(RGFW_window* win);
RGFWDEF u64 RGFW_window_getWindow_X11(RGFW_window* win);
RGFWDEF struct wl_surface* RGFW_window_getWindow_Wayland(RGFW_window* win);
/** * @defgroup Window_management
* @{ */
/*! set the window flags (will undo flags if they don't match the old ones) */
RGFWDEF void RGFW_window_setFlags(RGFW_window* win, RGFW_windowFlags);
/*!
polls the event queue if it's empty and pops the first event for the window from the event queue
using this function without a while loop may cause event lag
because this function polls events, it may not work for multi-threaded systems
RGFW_pollEvents + RGFW_window_checkQueuedEvent should be used when using multi-threaded systems
ex.
RGFW_event;
while (RGFW_window_checkEvent(win, &event)) [this keeps checking events until it reaches the last queued event]
you may also use `RGFW_pollEvents` instead
*/
RGFWDEF RGFW_bool RGFW_window_checkEvent(RGFW_window* win, RGFW_event* event); /*!< check current event (returns RGFW_TRUE if there is an event or RGFW_FALSE if there is no event)*/
/*! pops the first event for the window from the event queue */
RGFWDEF RGFW_bool RGFW_window_checkQueuedEvent(RGFW_window* win, RGFW_event* event);
/*! checks only if the key is pressed while the window in focus. */
RGFWDEF RGFW_bool RGFW_window_isKeyPressed(RGFW_window* win, RGFW_key key); /*!< if key is pressed (key code)*/
RGFWDEF RGFW_bool RGFW_window_isKeyDown(RGFW_window* win, RGFW_key key); /*!< if key is held (key code) */
RGFWDEF RGFW_bool RGFW_window_isKeyReleased(RGFW_window* win, RGFW_key key); /*!< if key is released (key code) */
/*! if a mouse button is pressed */
RGFWDEF RGFW_bool RGFW_window_isMousePressed(RGFW_window* win, RGFW_mouseButton button /*!< mouse button code */ );
/*! if a mouse button is down */
RGFWDEF RGFW_bool RGFW_window_isMouseDown(RGFW_window* win, RGFW_mouseButton button /*!< mouse button code */ );
/*! if a mouse button was released */
RGFWDEF RGFW_bool RGFW_window_isMouseReleased(RGFW_window* win, RGFW_mouseButton button /*!< mouse button code */ );
/*! if the mouse left the window, only true for the first frame */
RGFWDEF RGFW_bool RGFW_window_didMouseLeave(RGFW_window* win);
/*! if the mouse enter the window, only true for the first frame */
RGFWDEF RGFW_bool RGFW_window_didMouseEnter(RGFW_window* win);
/*! if the mouse is within the window or not */
RGFWDEF RGFW_bool RGFW_window_isMouseInside(RGFW_window* win);
/*! if there is data being dragged to/in the window, only true for the first frame */
RGFWDEF RGFW_bool RGFW_window_isDataDragging(RGFW_window* win);
/*! gets the drag point, returns true if if there is data being dragged to/in the window, only true for the first frame */
RGFWDEF RGFW_bool RGFW_window_getDataDrag(RGFW_window* win, i32* x, i32* y);
/* true the first frame there was a data drop (drag and drop) to the window */
RGFWDEF RGFW_bool RGFW_window_didDataDrop(RGFW_window* win);
/* sets file pointer to the internal files pointer, fills count with the number of files, true the first frame there was a data drop (drag and drop) to the window */
RGFWDEF RGFW_bool RGFW_window_getDataDrop(RGFW_window* win, const char*** files, size_t* count);
/*! window managment functions */
RGFWDEF void RGFW_window_close(RGFW_window* win); /*!< close the window and free the window struct */
RGFWDEF void RGFW_window_closePtr(RGFW_window* win); /*!< close the window, don't free the window struct */
/*! move a window to a given point */
RGFWDEF void RGFW_window_move(RGFW_window* win,
i32 x, i32 y /*!< new pos */
);