summaryrefslogtreecommitdiff
path: root/rgfw.c3
blob: 80204dd79b1f110b03a8a1050f80e38e978e818a (plain)
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
/*
*
* Copyright (C) 2026 andromeda
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. 
*
*/

module rgfw;

alias Info       = void;
alias Window     = void;
alias Window_src = void;

constdef Format : char
{
  RGB8 = 0,
  BGR8,
  RGBA8,
  ARGB8,
  BGRA8,
  ABGR8,
  COUNT,
}

struct ColorLayout
{
  int r;
  int g;
  int b;
  int a;
  uint channels;
}

alias ConvertImageDataFunc = fn void(char*, char*, ColorLayout*, ColorLayout*, usz);

alias NativeImage = void;
alias Surface = void;

struct GammaRamp
{
  ushort* red;
  ushort* green;
  ushort* blue;
  usz     count;
}

struct MonitorMode
{
  int   w;
  int   h;
  float refreshRate;
  char  red;
  char  blue;
  char  green;
  void* src;
}

alias MonitorNode = void;

struct Monitor
{
  int          x;
  int          y;
  CChar*       name;
  float        scaleX;
  float        scaleY;
  float        pixelRatio;
  float        physW;
  float        physH;
  MonitorMode  mode;
  void*        userPtr;
  MonitorNode* node;
}

constdef ModeRequest : char
{
  SCALE   = 1 << 0,
  REFRESH = 1 << 1,
  RGB     = 1 << 2,
  ALL     = SCALE | REFRESH | RGB,
}

alias Mouse = void;

constdef Key
{
  KEY_NULL         = 0,
  KEY_ESCAPE       = 27,
  KEY_BACKTICK     = '`',
  KEY_0            = '0',
  KEY_1            = '1',
  KEY_2            = '2',
  KEY_3            = '3',
  KEY_4            = '4',
  KEY_5            = '5',
  KEY_6            = '6',
  KEY_7            = '7',
  KEY_8            = '8',
  KEY_9            = '9',
  KEY_MINUS        = '-',
  KEY_EQUAL        = '=',
  KEY_EQUALS       = KEY_EQUAL,
  KEY_BACKSPACE    = '\b',
  KEY_TAB          = '\t',
  KEY_SPACE        = ' ',
  KEY_A            = 'a',
  KEY_B            = 'b',
  KEY_C            = 'c',
  KEY_D            = 'd',
  KEY_E            = 'e',
  KEY_F            = 'f',
  KEY_G            = 'g',
  KEY_H            = 'h',
  KEY_I            = 'i',
  KEY_J            = 'j',
  KEY_K            = 'k',
  KEY_L            = 'l',
  KEY_M            = 'm',
  KEY_N            = 'n',
  KEY_O            = 'o',
  KEY_P            = 'p',
  KEY_Q            = 'q',
  KEY_R            = 'r',
  KEY_S            = 's',
  KEY_T            = 't',
  KEY_U            = 'u',
  KEY_V            = 'v',
  KEY_W            = 'w',
  KEY_X            = 'x',
  KEY_Y            = 'y',
  KEY_Z            = 'z',
  KEY_PERIOD       = '.',
  KEY_COMMA        = ',',
  KEY_SLASH        = '/',
  KEY_BRACKET      = '[',
  KEY_CLOSEBRACKET = ']',
  KEY_SEMICOLON    = ';',
  KEY_APOSTROPHE   = '\'',
  KEY_BACKSLASH    = '\\',
  KEY_RETURN       = '\n',
  KEY_ENTER        = KEY_RETURN,
  KEY_DELETE       = 127,
  KEY_F1,
  KEY_F2,
  KEY_F3,
  KEY_F4,
  KEY_F5,
  KEY_F6,
  KEY_F7,
  KEY_F8,
  KEY_F9,
  KEY_F10,
  KEY_F11,
  KEY_F12,
  KEY_F13,
  KEY_F14,
  KEY_F15,
  KEY_F16,
  KEY_F17,
  KEY_F18,
  KEY_F19,
  KEY_F20,
  KEY_F21,
  KEY_F22,
  KEY_F23,
  KEY_F24,
  KEY_F25,
  KEY_CAPSLOCK,
  KEY_SHIFTL,
  KEY_CONTROLL,
  KEY_ALTL,
  KEY_SUPERL,
  KEY_SHIFTR,
  KEY_CONTROLR,
  KEY_ALTR,
  KEY_SUPERR,
  KEY_UP,
  KEY_DOWN,
  KEY_LEFT,
  KEY_RIGHT,
  KEY_INSERT,
  KEY_MENU,
  KEY_END,
  KEY_HOME,
  KEY_PAGEUP,
  KEY_PAGEDOWN,
  KEY_NUMLOCK,
  KEY_PADSLASH,
  KEY_PADMULTIPLY,
  KEY_PADPLUS,
  KEY_PADMINUS,
  KEY_PADEQUAL,
  KEY_PADEQUALS    = KEY_PADEQUAL,
  KEY_KEY_PAD1,
  KEY_PAD2,
  KEY_PAD3,
  KEY_PAD4,
  KEY_PAD5,
  KEY_PAD6,
  KEY_PAD7,
  KEY_PAD8,
  KEY_PAD9,
  KEY_PAD0,
  KEY_PADPERIOD,
  KEY_PADRETURN,
  KEY_SCROLLLOCK,
  KEY_PRINTSCREEN,
  KEY_PAUSE,
  KEY_WORLD1,
  KEY_WORLD2,
  KEY_LAST         = 256,
}

constdef MouseButton : char
{
  LEFT = 0,
  MIDDLE,
  RIGHT,
  MISC1,
  MISC2,
  MISC3,
  MISC4,
  MISC5,
  FINAL,
}

constdef Keymod : char
{
  CAPSLOCK   = 1 << 0,
  NUMLOCK    = 1 << 1,
  CONTROL    = 1 << 2,
  ALT        = 1 << 3,
  SHIFT      = 1 << 4,
  SUPER      = 1 << 5,
  SCROLLLOCK = 1 << 6,
}

constdef DndActionType : char
{
  ACTION_NONE = 0,
  ACTION_ENTER,
  ACTION_MOVE,
  ACTION_EXIT,
}

constdef DataTransferType : char
{
  NONE = 0,
  TEXT,
  FILE,
  URL,
  IMAGE,
  UNKNOWN,
}

struct DataDropNode
{
  ZString          data;
  usz              size;
  DataTransferType type;
  DataDropNode*    next;
}

constdef EventType : char
{
  EVENT_NONE = 0,
  KEY_PRESSED,
  KEY_RELEASED,
  KEY_CHAR,
  MOUSE_BUTTON_PRESSED,
  MOUSE_BUTTON_RELEASED,
  MOUSE_SCROLL,
  MOUSE_POS_CHANGED,
  MOUSE_RAW_MOTION,
  MOUSE_ENTER,
  MOUSE_LEAVE,
  WINDOW_MOVED,
  WINDOW_RESIZED,
  WINDOW_FOCUS_IN,
  WINDOW_FOCUS_OUT,
  WINDOW_REFRESH,
  WINDOW_CLOSE,
  WINDOW_MAXIMIZED,
  WINDOW_MINIMIZED,
  WINDOW_RESTORED,
  DATA_DROP,
  DATA_DRAG,
  SCALE_UPDATED,
  MONITOR_CONNECTED,
  MONITOR_DISCONNECTED,
  EVENT_COUNT,
}

constdef EventFlag : uint
{
  KEY_PRESSED           = 1 << (char)EventType.KEY_PRESSED,
  KEY_RELEASED          = 1 << (char)EventType.KEY_RELEASED,
  KEY_CHAR              = 1 << (char)EventType.KEY_CHAR,
  MOUSE_BUTTON_PRESSED  = 1 << (char)EventType.MOUSE_BUTTON_PRESSED,
  MOUSE_BUTTON_RELEASED = 1 << (char)EventType.MOUSE_BUTTON_RELEASED,
  MOUSE_SCROLL          = 1 << (char)EventType.MOUSE_SCROLL,
  MOUSE_POS_CHANGED     = 1 << (char)EventType.MOUSE_POS_CHANGED,
  MOUSE_RAW_MOTION      = 1 << (char)EventType.MOUSE_RAW_MOTION,
  MOUSE_ENTER           = 1 << (char)EventType.MOUSE_ENTER,
  MOUSE_LEAVE           = 1 << (char)EventType.MOUSE_LEAVE,
  WINDOW_MOVED          = 1 << (char)EventType.WINDOW_MOVED,
  WINDOW_RESIZED        = 1 << (char)EventType.WINDOW_RESIZED,
  WINDOW_FOCUS_IN       = 1 << (char)EventType.WINDOW_FOCUS_IN,
  WINDOW_FOCUS_OUT      = 1 << (char)EventType.WINDOW_FOCUS_OUT,
  WINDOW_REFRESH        = 1 << (char)EventType.WINDOW_REFRESH,
  WINDOW_CLOSE          = 1 << (char)EventType.WINDOW_CLOSE,
  WINDOW_MAXIMIZED      = 1 << (char)EventType.WINDOW_MAXIMIZED,
  WINDOW_MINIMIZED      = 1 << (char)EventType.WINDOW_MINIMIZED,
  WINDOW_RESTORED       = 1 << (char)EventType.WINDOW_RESTORED,
  DATA_DROP             = 1 << (char)EventType.DATA_DROP,
  DATA_DRAG             = 1 << (char)EventType.DATA_DRAG,
  SCALE_UPDATED         = 1 << (char)EventType.SCALE_UPDATED,
  MONITOR_CONNECTED     = 1 << (char)EventType.MONITOR_CONNECTED,
  MONITOR_DISCONNECTED  = 1 << (char)EventType.MONITOR_DISCONNECTED,

  KEY_EVENTS            = KEY_PRESSED | KEY_RELEASED | KEY_CHAR,
  MOUSE_EVENTS          = MOUSE_BUTTON_PRESSED | MOUSE_BUTTON_RELEASED | MOUSE_SCROLL | MOUSE_POS_CHANGED | MOUSE_RAW_MOTION | MOUSE_ENTER | MOUSE_LEAVE,
  WINDOW_EVENTS         = WINDOW_MOVED | WINDOW_RESIZED | WINDOW_REFRESH | WINDOW_MAXIMIZED | WINDOW_MINIMIZED | WINDOW_RESTORED | SCALE_UPDATED,
  WINDOW_FOCUS_EVENTS   = WINDOW_FOCUS_IN | WINDOW_FOCUS_OUT,
  DATA_DRAG_DROP_EVENTS = DATA_DRAG | DATA_DROP,
  MONITOR_EVENTS        = MONITOR_CONNECTED | MONITOR_DISCONNECTED,
  ALL_EVENTS            = KEY_EVENTS | MOUSE_EVENTS | WINDOW_EVENTS | WINDOW_FOCUS_EVENTS | DATA_DRAG_DROP_EVENTS | MONITOR_EVENTS,
}

struct CommonEvent
{
  EventType type;
  Window*   win;
}

struct WindowFocusEvent
{
  EventType type;
  Window*   win;
  bool      state;
}

struct MouseButtonEvent
{
  EventType   type;
  Window*     win;
  MouseButton value;
  bool        state;
}

struct MouseDeltaEvent
{
  EventType type;
  Window*   win;
  float     x;
  float     y;
}

struct MousePosEvent
{
  EventType type;
  Window*   win;
  int       x;
  int       y;
  bool      inWindow;
}

struct KeyEvent
{
  EventType type;
  Window*   win;
  Key       value;
  bool      repeat;
  Keymod    mod;
  bool      state;
}

struct KeyCharEvent
{
  EventType type;
  Window*   win;
  Char32    value;
}

struct DataDropEvent
{
  EventType     type;
  Window*       win;
  DataDropNode* value;
}

struct DataDragEvent
{
  EventType        type;
  Window*          win;
  int              x;
  int              y;
  DndActionType    action;
  DataTransferType dataType;
}

struct ScaleUpdatedEvent
{
  EventType type;
  Window*   win;
  float     x;
  float     y;
}

struct MonitorEvent
{
  EventType type;
  Window*   win;
  Monitor*  monitor;
  bool      state;
}

struct WindowUpdateEvent
{
  EventType type;
  Window*   win;
  int       x;
  int       y;
  int       w;
  int       h;
}

union Event
{
  EventType         type;
  CommonEvent       common;
  WindowFocusEvent  focus;
  WindowUpdateEvent update;
  MouseButtonEvent  button;
  MouseDeltaEvent   delta;
  MousePosEvent     mouse;
  KeyEvent          key;
  KeyCharEvent      keyChar;
  DataDropEvent     drop;
  DataDragEvent     drag;
  ScaleUpdatedEvent scale;
  MonitorEvent      monitor;
}

constdef EventWait : int
{
  NO_WAIT   = 0,
  WAIT_NEXT = -1,
}

alias GenericFunc = fn void(Event*);

struct Callbacks { GenericFunc* arr; }

constdef WindowFlags : uint
{
  NO_BORDER           = 1 << 0,
  NO_RESIZE           = 1 << 1,
  ALLOW_DND           = 1 << 2,
  HIDE_MOUSE          = 1 << 3,
  FULLSCREEN          = 1 << 4,
  TRANSLUCENT         = 1 << 5,
  TRANSPARENT         = TRANSLUCENT,
  CENTER              = 1 << 6,
  RAW_MOUSE           = 1 << 7,
  SCALE_TO_MONITOR    = 1 << 8,
  HIDE                = 1 << 9,
  MAXIMIZE            = 1 << 10,
  CENTER_CURSOR       = 1 << 11,
  FLOATING            = 1 << 12,
  FOCUS_ON_SHOW       = 1 << 13,
  MINIMIZE            = 1 << 14,
  FOCUS               = 1 << 15,
  CAPTURE_MOUSE       = 1 << 16,
  OPENGL              = 1 << 17,
  EGL                 = 1 << 18,
  NO_DEINIT_ON_CLOSE  = 1 << 19,
  WINDOWED_FULLSCREEN = NO_BORDER | MAXIMIZE,
  CAPTURE_RAW_MOUSE   = CAPTURE_MOUSE | RAW_MOUSE,
}

constdef Icon : char
{
  TASKBAR = 1 << 0,
  WINDOW  = 1 << 1,
  BOTH    = TASKBAR | WINDOW,
}

constdef MouseIcon : char
{
  NORMAL        = 0,
  ARROW,
  IBEAM,
  TEXT          = IBEAM,
  CROSSHAIR,
  POINTING_HAND,
  RESIZE_EW,
  RESIZE_NS,
  RESIZE_NWSE,
  RESIZE_NESW,
  RESIZE_NW,
  RESIZE_N,
  RESIZE_NE,
  RESIZE_E,
  RESIZE_SE,
  RESIZE_S,
  RESIZE_SW,
  RESIZE_W,
  RESIZE_ALL,
  NOT_ALLOWED,
  WAIT,
  PROGRESS,
  ICON_COUNT,
  ICON_FINAL    = 16, // padding
}

constdef FlashRequest : char
{
  CANCEL = 0,
  BRIEFLY,
  UNTIL_FOCUSED,
}

constdef DebugType : char
{
  ERROR = 0,
  WARNING,
  INFO,
}

constdef ErrorCode : char
{
  NO_ERROR = 0,
  ERR_OUT_OF_MEMORY,
  ERR_OPENGL_CONTEXT,
  ERR_EGL_CONTEXT,
  ERR_WAYLAND,
  ERR_X11,
  ERR_DIRECTX_CONTEXT,
  ERR_IOKIT,
  ERR_CLIPBOARD,
  ERR_FAILED_FUNC_LOAD,
  ERR_BUFFER,
  ERR_METAL,
  ERR_PLATFORM,
  ERR_EVENT_QUEUE,
  INFO_WINDOW,
  INFO_BUFFER,
  INFO_GLOBAL,
  INFO_OPENGL,
  WARNING_WAYLAND,
  WARNING_OPENGL,
}

struct DebugInfo
{
  DebugType type;
  ErrorCode code;
  ZString   msg;
}

alias DebugFunc  = fn void(DebugInfo*);
alias Proc       @if($feature(OPENGL)) = fn void();
alias GlContext  @if($feature(OPENGL)) = void;
alias EglContext @if($feature(OPENGL)) = void;

constdef GlReleaseBehavior : int @if($feature(OPENGL))
{
  FLUSH = 0,
  NONE,
}

constdef GlProfile : int @if($feature(OPENGL))
{
  CORE = 0,
  FORWARD_COMPATIBILITY,
  COMPATIBILITY,
  ES,
}

constdef GlRenderer : int @if($feature(OPENGL))
{
  ACCELERATED = 0,
  SOFTWARE,
}

struct GlHints @if($feature(OPENGL))
{
  int               stencil;
  int               samples;
  int               stereo;
  int               auxBuffers;
  int               doubleBuffer;
  int               red;
  int               green;
  int               blue;
  int               alpha;
  int               depth;
  int               accumRed;
  int               accumGreen;
  int               accumBlue;
  int               accumAlpha;
  bool              sRGB;
  bool              robustness;
  bool              debug;
  bool              noError;
  GlReleaseBehavior releaseBehavior;
  GlProfile         profile;
  int               major;
  int               minor;
  GlContext*        share;
  EglContext*       shareEGL;
  GlRenderer        renderer;
}

extern fn void*         alloc(usz)                                                                  @cname("RGFW_alloc");
extern fn void          free(void*)                                                                 @cname("RGFW_free");
extern fn usz           sizeofWindow()                                                              @cname("RGFW_sizeofWindow");
extern fn usz           sizeofWindowSrc()                                                           @cname("RGFW_sizeofWindowSrc");
extern fn void          useWayland(bool)                                                            @cname("RGFW_useWayland");
extern fn bool          usingWayland()                                                              @cname("RGFW_usingWayland");
extern fn void*         getLayer_OSX()                                                              @cname("RGFW_getLayer_OSX");
extern fn void*         getDisplay_X11()                                                            @cname("RGFW_getDisplay_X11");
extern fn void*         getDisplay_Wayland()                                                        @cname("RGFW_getDisplay_Wayland"); // TODO return isn't void*
extern fn void          setClassName(ZString)                                                       @cname("RGFW_setClassName");
extern fn void          setXInstName(ZString)                                                       @cname("RGFW_setXInstName");
extern fn void          moveToMacOSResourceDir()                                                    @cname("RGFW_modeToMacOSResourceDir");
extern fn void          copyImageData(char*, int, int, Format, char*, Format, ConvertImageDataFunc) @cname("RGFW_copyImageData");
extern fn usz           sizeofNativeImage()                                                         @cname("RGFW_sizeofNativeImage");
extern fn usz           sizeofSurface()                                                             @cname("RGFW_sizeofSurface");
extern fn Format        nativeFormat()                                                              @cname("RGFW_nativeFormat");
extern fn Surface*      createSurface(char*, int, int, Format)                                      @cname("RGFW_createSurface");
extern fn bool          createSurfacePtr(char*, int, int, Format, Surface*)                         @cname("RGFW_createSurfacePtr");
extern fn NativeImage*  surface_getNativeImage(Surface*)                                            @cname("RGFW_surface_getNativeImage");
extern fn void          surface_free(Surface*)                                                      @cname("RGFW_surface_free");
extern fn void          surface_freePtr(Surface*)                                                   @cname("RGFW_surface_freePtr");
extern fn Mouse*        createMouse(char*, int, int, Format)                                        @cname("RGFW_createMouse");
extern fn Mouse*        createMouseStandard(MouseIcon)                                              @cname("RGFW_createMouseStandard");
extern fn void          freeMouse(Mouse*)                                                           @cname("RGFW_freeMouse");
extern fn MonitorMode*  monitor_getModes(Monitor*, usz*)                                            @cname("RGFW_monitor_getModes");
extern fn void          freeModes(MonitorMode*)                                                     @cname("RGFW_freeModes");
extern fn usz           monitor_getModesPtr(Monitor*, MonitorMode**)                                @cname("RGFW_monitor_getModesPtr");
extern fn bool          monitor_findClosestMode(Monitor*, MonitorMode*, MonitorMode*)               @cname("RGFW_monitor_findClosestMode");
extern fn GammaRamp*    monitor_getGammaRamp(Monitor*)                                              @cname("RGFW_monitor_getGammaRamp");
extern fn void          freeGammaRamp(GammaRamp*)                                                   @cname("RGFW_freeGammaRamp");
extern fn usz           monitor_getGammaRampPtr(Monitor*, GammaRamp*)                               @cname("RGFW_monitor_getGammaRampPtr");
extern fn bool          monitor_setGammaRamp(Monitor*, GammaRamp*)                                  @cname("RGFW_monitor_setGammaRamp");
extern fn bool          monitor_setGamma(Monitor*, float)                                           @cname("RGFW_monitor_setGamma");
extern fn bool          monitor_setGammaPtr(Monitor*, float, ushort*, usz)                          @cname("RGFW_monitor_setGammaPtr");
extern fn bool          monitor_getWorkarea(Monitor*, int*, int*, int*, int*)                       @cname("RGFW_monitor_getWorkarea");
extern fn bool          monitor_getPosition(Monitor*, int*, int*)                                   @cname("RGFW_monitor_getPosition");
extern fn ZString       monitor_getName(Monitor*)                                                   @cname("RGFW_monitor_getName");
extern fn bool          monitor_getScale(Monitor*, float*, float*)                                  @cname("RGFW_monitor_getScale");
extern fn bool          monitor_getPhysicalSize(Monitor*, float*, float*)                           @cname("RGFW_monitor_getPhysicalSize");
extern fn void          monitor_setUserPtr(Monitor*, void*)                                         @cname("RGFW_monitor_setUserPtr");
extern fn void*         monitor_getUserPtr(Monitor*)                                                @cname("RGFW_monitor_getUserPtr");
extern fn bool          monitor_getMode(Monitor*, MonitorMode*)                                     @cname("RGFW_monitor_getMode");
extern fn void          pollMonitors()                                                              @cname("RGFW_pollMonitors");
extern fn Monitor**     getMonitors(usz*)                                                           @cname("RGFW_getMonitors");
extern fn Monitor*      getPrimaryMonitor()                                                         @cname("RGFW_getPrimaryMonitor");
extern fn bool          monitor_requestMode(Monitor*, MonitorMode*, ModeRequest)                    @cname("RGFW_monitor_requestMode");
extern fn bool          monitor_setMode(Monitor*, MonitorMode*)                                     @cname("RGFW_monitor_setMode");
extern fn bool          monitorModeCompare(MonitorMode*, MonitorMode*, ModeRequest)                 @cname("RGFW_monitorModeCompare");
extern fn bool          monitor_scaleToWindow(Monitor*, Window*)                                    @cname("RGFW_monitor_scaleToWindow");
extern fn void          setRawMouseMode(bool)                                                       @cname("RGFW_setRawMouseMode");
extern fn void          setBuildDND(bool)                                                           @cname("RGFW_setbuildDND");
extern fn void          waitForEvent(int)                                                           @cname("RGFW_waitForEvent");
extern fn void          setQueueEvents(bool)                                                        @cname("RGFW_setQueueEvents");
extern fn GenericFunc*  setEventCallback(EventType, GenericFunc)                                    @cname("RGFW_setEventCallback");
extern fn void          setDualEventCallback(EventType, GenericFunc, GenericFunc*, GenericFunc*)    @cname("RGFW_setDualEventCallback");
extern fn void          setAllEventCallbacks(GenericFunc, Callbacks*)                               @cname("RGFW_setAllEventCallbacks");
extern fn void          pollEvents()                                                                @cname("RGFW_pollEvents");
extern fn void          stopCheckEvents()                                                           @cname("RGFW_stopCheckEvents");
extern fn bool          checkEvent(Event*)                                                          @cname("RGFW_checkEvent");
extern fn bool          checkQueuedEvent(Event*)                                                    @cname("RGFW_checkQueuedEvent");
extern fn bool          isKeyPressed(Key)                                                           @cname("RGFW_isKeyPressed");
extern fn bool          isKeyReleased(Key)                                                          @cname("RGFW_isKeyReleased");
extern fn bool          isKeyDown(Key)                                                              @cname("RGFW_isKeyDown");
extern fn bool          isMousePressed(MouseButton)                                                 @cname("RGFW_isMousePressed");
extern fn bool          isMouseReleased(MouseButton)                                                @cname("RGFW_isMouseReleased");
extern fn bool          isMouseDown(MouseButton)                                                    @cname("RGFW_isMouseDown");
extern fn void          getMouseScroll(float*, float*)                                              @cname("RGFW_getMouseScroll");
extern fn void          getMouseVector(float*, float*)                                              @cname("RGFW_getMouseVector");
extern fn Window*       createWindow(ZString, int, int, int, int, WindowFlags)                      @cname("RGFW_createWindow");
extern fn Window*       createWindowPtr(ZString, int, int, int, int, WindowFlags, Window*)          @cname("RGFW_createWindowPtr");
extern fn Surface*      window_createSurface(Window*, char*, int, int, Format)                      @cname("RGFW_window_createSurface");
extern fn Surface*      window_createSurfacePtr(Window*, char*, int, int, Format, Surface*)         @cname("RGFW_window_createSurfacePtr");
extern fn void          surface_setConvertFunc(Surface*, ConvertImageDataFunc)                      @cname("RGFW_surface_setConvertFunc");
extern fn void          window_blitSurface(Window*, Surface*)                                       @cname("RGFW_window_blitSurface");
extern fn bool          window_getPosition(Window*, int*, int*)                                     @cname("RGFW_window_getPosition");
extern fn bool          window_getSize(Window*, int*, int*)                                         @cname("RGFW_window_getSize");
extern fn bool          window_getSizeInPixels(Window*, int*, int*)                                 @cname("RGFW_window_getSizeInPixels");
extern fn uint          window_getFlags(Window*)                                                    @cname("RGFW_window_getFlags");
extern fn Key           window_getExitKey(Window*)                                                  @cname("RGFW_window_getExitKey");
extern fn void          window_setExitKey(Window*, Key)                                             @cname("RGFW_window_setExitKey");
extern fn void          window_setEnabledEvents(Window*, EventFlag)                                 @cname("RGFW_window_setEnabledEvents");
extern fn EventFlag     window_getEnabledEvents(Window*)                                            @cname("RGFW_window_getEnabledEvents");
extern fn void          window_setDisabledEvents(Window*, EventFlag)                                @cname("RGFW_window_setDisabledEvents");
extern fn void          window_setEventState(Window*, EventFlag, bool)                              @cname("RGFW_window_setEventState");
extern fn void*         window_getUserPtr(Window*)                                                  @cname("RGFW_window_getUserPtr");
extern fn void          window_setUserPtr(Window*, void*)                                           @cname("RGFW_window_setUserPtr");
extern fn Window_src*   window_getSrc(Window*)                                                      @cname("RGFW_window_getSrc");
extern fn void          window_setLayer_OSX(Window*, void*)                                         @cname("RGFW_window_setLayer_OSX");
extern fn void*         window_getView_OSX(Window*)                                                 @cname("RGFW_window_getView_OSX");
extern fn void*         window_getWindow_OSX(Window*)                                               @cname("RGFW_window_getWindow_OSX");
extern fn void*         window_getHWND(Window*)                                                     @cname("RGFW_window_getHWND");
extern fn void*         window_getHDC(Window*)                                                      @cname("RGFW_window_getHDC");
extern fn ulong         window_getWindow_X11(Window*)                                               @cname("RGFW_window_getWindow_X11");
extern fn void*         window_getWindow_Wayland(Window*)                                           @cname("RGFW_window_getWindow_Wayland"); // TODO return isn't *void
extern fn void          window_setFlags(Window*, WindowFlags)                                       @cname("RGFW_window_setFlags");
extern fn bool          window_checkEvent(Window*, Event*)                                          @cname("RGFW_window_checkEvent");
extern fn bool          window_checkQueuedEvent(Window*, Event*)                                    @cname("RGFW_window_checkQueuedEvent");
extern fn bool          window_isKeyPressed(Window*, Key)                                           @cname("RGFW_window_isKeyPressed");
extern fn bool          window_isKeyDown(Window*, Key)                                              @cname("RGFW_window_isKeyDown");
extern fn bool          window_isKeyReleased(Window*, Key)                                          @cname("RGFW_window_isKeyReleased");
extern fn bool          window_isMousePressed(Window*, MouseButton)                                 @cname("RGFW_window_isMousePressed");
extern fn bool          window_isMouseDown(Window*, MouseButton)                                    @cname("RGFW_window_isMouseDown");
extern fn bool          window_isMouseReleased(Window*, MouseButton)                                @cname("RGFW_window_isMouseReleased");
extern fn bool          window_didMouseLeave(Window*)                                               @cname("RGFW_window_didMouseLeave");
extern fn bool          window_didMouseEnter(Window*)                                               @cname("RGFW_window_didMouseEnter");
extern fn bool          window_isMouseInside(Window*)                                               @cname("RGFW_window_isMouseInside");
extern fn bool          window_isDataDragging(Window*)                                              @cname("RGFW_window_isDataDragging");
extern fn bool          window_getDataDrag(Window*, int*, int*)                                     @cname("RGFW_window_getDataDrag");
extern fn bool          window_didDataDrop(Window*)                                                 @cname("RGFW_window_didDataDrop");
extern fn DataDropNode* window_getDataDrop(Window*)                                                 @cname("RGFW_window_getDataDrop");
extern fn void          window_close(Window*)                                                       @cname("RGFW_window_close");
extern fn void          window_closePtr(Window*)                                                    @cname("RGFW_window_closePtr");
extern fn bool          window_fetchSize(Window*, int*, int*)                                       @cname("RGFW_window_fetchSize");
extern fn void          window_move(Window*, int, int)                                              @cname("RGFW_window_move");
extern fn void          window_moveToMonitor(Window*, Monitor*)                                     @cname("RGFW_window_moveToMonitor");
extern fn void          window_resize(Window*, int, int)                                            @cname("RGFW_window_resize");
extern fn void          window_setAspectRatio(Window*, int, int)                                    @cname("RGFW_window_setAspectRation");
extern fn void          window_setMinSize(Window*, int, int)                                        @cname("RGFW_window_setMinSize");
extern fn void          window_setMaxSize(Window*, int, int)                                        @cname("RGFW_window_setMaxSize");
extern fn void          window_focus(Window*)                                                       @cname("RGFW_window_focus");
extern fn bool          window_isInFocus(Window*)                                                   @cname("RGFW_window_isInFocus");
extern fn void          window_raise(Window*)                                                       @cname("RGFW_window_raise");
extern fn void          window_maximize(Window*)                                                    @cname("RGFW_window_maximize");
extern fn void          window_setFullscreen(Window*, bool)                                         @cname("RGFW_window_setFullscreen");
extern fn void          window_center(Window*)                                                      @cname("RGFW_window_center");
extern fn void          window_minimize(Window*)                                                    @cname("RGFW_window_minimize");
extern fn void          window_restore(Window*)                                                     @cname("RGFW_window_restore");
extern fn void          window_setFloating(Window*, bool)                                           @cname("RGFW_window_setFloating");
extern fn void          window_setOpacity(Window*, char)                                            @cname("RGFW_window_setOpacity");
extern fn void          window_setBorder(Window*, bool)                                             @cname("RGFW_window_setBorder");
extern fn bool          window_borderless(Window*)                                                  @cname("RGFW_window_borderless");
extern fn void          window_setDND(Window*, bool)                                                @cname("RGFW_window_setDND");
extern fn bool          window_allowsDND(Window*)                                                   @cname("RGFW_window_allowsDND");
extern fn void          window_setMousePassthrough(Window*, bool)                                   @cname("RGFW_window_setMousePassthrough");
extern fn void          window_setName(Window*, ZString)                                            @cname("RGFW_window_setName");
extern fn bool          window_setIcon(Window*, char*, int, int, Format)                            @cname("RGFW_window_seticon");
extern fn bool          window_setIconEx(Window*, char*, int, int, Format, Icon)                    @cname("RGFW_window_setIconEx");
extern fn bool          window_setMouse(Window*, Mouse*)                                            @cname("RGFW_window_setMouse");
extern fn bool          window_setMouseStandard(Window*, MouseIcon)                                 @cname("RGFW_window_setMouseStandard");
extern fn bool          window_setMouseDefault(Window*)                                             @cname("RGFW_window_setMouseDefault");
extern fn void          window_setRawMouseMode(Window*, bool)                                       @cname("RGFW_window_setRawMousemode");
extern fn void          window_captureMouse(Window*, bool)                                          @cname("RGFW_window_captureMouse");
extern fn void          window_captureRawMouse(Window*, bool)                                       @cname("RGFW_window_captureRawMouse");
extern fn bool          window_isRawMouseMode(Window*)                                              @cname("RGFW_window_isRawMouseMode");
extern fn bool          window_isCaptured(Window*)                                                  @cname("RGFW_window_isCaptured");
extern fn void          window_hide(Window*)                                                        @cname("RGFW_window_hide");
extern fn void          window_show(Window*)                                                        @cname("RGFW_window_show");
extern fn void          window_flash(Window*, FlashRequest)                                         @cname("RGFW_window_flash");
extern fn void          window_setShouldClose(Window*, bool)                                        @cname("RGFW_window_setShouldClose");
extern fn bool          window_getGlobalMouse(int*, int*)                                           @cname("RGFW_window_getGlobalMouse");
extern fn bool          window_getMouse(Window*, int*, int*)                                        @cname("RGFW_window_getMouse");
extern fn void          window_showMouse(Window*, bool)                                             @cname("RGFW_window_showMouse");
extern fn bool          window_isMouseHidden(Window*)                                               @cname("RGFW_window_isMouseHidden");
extern fn void          window_moveMouse(Window*, int, int)                                         @cname("RGFW_window_moveMouse");
extern fn bool          window_shouldClose(Window*)                                                 @cname("RGFW_window_shouldClose");
extern fn bool          window_isFullscreen(Window*)                                                @cname("RGFW_window_isFullscreen");
extern fn bool          window_isHidden(Window*)                                                    @cname("RGFW_window_isHidden");
extern fn bool          window_isMinimized(Window*)                                                 @cname("RGFW_window_isMinimized");
extern fn bool          window_isMaximized(Window*)                                                 @cname("RGFW_window_isMaximized");
extern fn bool          window_isFloating(Window*)                                                  @cname("RGFW_window_isFloating");
extern fn void          window_scaleToMonitor(Window*)                                              @cname("RGFW_window_scaleToMonitor");
extern fn Monitor*      window_getMonitor(Window*)                                                  @cname("RGFW_window_getMonitor");
extern fn ZString       readClipboard(usz*)                                                         @cname("RGFW_readClipboard");
extern fn sz            readClipboardPtr(CChar*, usz)                                               @cname("RGFW_readClipboardPtr");
extern fn void          writeClipboard(ZString, uint)                                               @cname("RGFW_writeClipboard");
extern fn DebugFunc     setDebugCallback(DebugFunc)                                                 @cname("RGFW_setDebugCallback");
extern fn void          debugCallback(DebugType, ErrorCode, ZString)                                @cname("RGFW_debugCallback");

// RGFW_OPENGL
extern fn void          setGlobalHints(GlHints*)                                                    @cname("RGFW_setGlobalHints_OpenGL")             @if($feature(OPENGL));
extern fn void          resetGlobalHints()                                                          @cname("RGFW_resetGlobalHints_OpenGL")           @if($feature(OPENGL));
extern fn GlHints*      getGlobalHints()                                                            @cname("RGFW_getGlobalHints_OpenGL")             @if($feature(OPENGL));
extern fn GlContext*    window_createContext(Window*, GlHints*)                                     @cname("RGFW_window_createContext_OpenGL")       @if($feature(OPENGL));
extern fn bool          window_createContextPtr(Window*, GlContext*, GlHints*)                      @cname("RGFW_window_createContextPtr_OpenGL")    @if($feature(OPENGL));
extern fn GlContext*    window_getContext(Window*)                                                  @cname("RGFW_window_getContext_OpenGL")          @if($feature(OPENGL));
extern fn void          window_deleteContext(Window*, GlContext*)                                   @cname("RGFW_window_deleteContext_OpenGL")       @if($feature(OPENGL));
extern fn void          window_deleteContextPtr(Window*, GlContext*)                                @cname("RGFW_window_deleteContextPtr_OpenGL")    @if($feature(OPENGL));
extern fn void*         glContext_getSourceContext(GlContext*)                                      @cname("RGFW_glContext_getSourceContext")        @if($feature(OPENGL));
extern fn void          window_makeCurrentWindow(Window*)                                           @cname("RGFW_window_makeCurrentWindow_OpenGL")   @if($feature(OPENGL));
extern fn void          window_makeCurrentContext(Window*)                                          @cname("RGFW_window_makeCurrentContext_OpenGL")  @if($feature(OPENGL));
extern fn void          window_swapBuffers(Window*)                                                 @cname("RGFW_window_swapBuffers_OpenGL")         @if($feature(OPENGL));
extern fn void*         getCurrentContext()                                                         @cname("RGFW_getCurrentContext_OpenGL")          @if($feature(OPENGL));
extern fn Window*       getCurrentWindow()                                                          @cname("RGFW_getCurrentWindow_OpenGL")           @if($feature(OPENGL));
extern fn void          window_swapInterval(Window*, int)                                           @cname("RGFW_window_swapInterval_OpenGL")        @if($feature(OPENGL));
extern fn Proc          getProcAddress(ZString)                                                     @cname("RGFW_getProcAddress_OpenGL")             @if($feature(OPENGL));
extern fn bool          extensionSupported(ZString, usz)                                            @cname("RGFW_extensionSupported_OpenGL")         @if($feature(OPENGL));
extern fn bool          extensionSupportedPlatform(ZString, usz)                                    @cname("RGFW_extensionSupportedPlatform_OpenGL") @if($feature(OPENGL));

// RGFW_EGL     2460..2596
// RGFW_VULKAN  2599..2626
// RGFW_DIRECTX 2630..2649
// RGFW_WEBGPU  2652..2661