Repository navigation
Expand file tree
/
Copy pathSDL_video.h
More file actions
3572 lines (3389 loc) · 142 KB
/
Copy pathSDL_video.h
File metadata and controls
3572 lines (3389 loc) · 142 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
/*
Simple DirectMedia Layer
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
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.
*/
/**
* # CategoryVideo
*
* SDL's video subsystem is largely interested in abstracting window
* management from the underlying operating system. You can create windows,
* manage them in various ways, set them fullscreen, and get events when
* interesting things happen with them, such as the mouse or keyboard
* interacting with a window.
*
* The video subsystem is also interested in abstracting away some
* platform-specific differences in OpenGL: context creation, swapping
* buffers, etc. This may be crucial to your app, but also you are not
* required to use OpenGL at all. In fact, SDL can provide rendering to those
* windows as well, either with an easy-to-use
* [2D API](https://wiki.libsdl.org/SDL3/CategoryRender)
* or with a more-powerful
* [GPU API](https://wiki.libsdl.org/SDL3/CategoryGPU)
* . Of course, it can simply get out of your way and give you the window
* handles you need to use Vulkan, Direct3D, Metal, or whatever else you like
* directly, too.
*
* The video subsystem covers a lot of functionality, out of necessity, so it
* is worth perusing the list of functions just to see what's available, but
* most apps can get by with simply creating a window and listening for
* events, so start with SDL_CreateWindow() and SDL_PollEvent().
*/
#ifndef SDL_video_h_
#define SDL_video_h_
#include <SDL3/SDL_stdinc.h>
#include <SDL3/SDL_error.h>
#include <SDL3/SDL_pixels.h>
#include <SDL3/SDL_properties.h>
#include <SDL3/SDL_rect.h>
#include <SDL3/SDL_surface.h>
#include <SDL3/SDL_begin_code.h>
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
extern "C" {
#endif
/**
* This is a unique ID for a display for the time it is connected to the
* system, and is never reused for the lifetime of the application.
*
* If the display is disconnected and reconnected, it will get a new ID.
*
* The value 0 is an invalid ID.
*
* \since This datatype is available since SDL 3.2.0.
*/
typedef Uint32 SDL_DisplayID;
/**
* This is a unique ID for a window.
*
* The value 0 is an invalid ID.
*
* \since This datatype is available since SDL 3.2.0.
*/
typedef Uint32 SDL_WindowID;
/* Global video properties... */
/**
* The pointer to the global `wl_display` object used by the Wayland video
* backend.
*
* Can be set before the video subsystem is initialized to import an external
* `wl_display` object from an application or toolkit for use in SDL, or read
* after initialization to export the `wl_display` used by the Wayland video
* backend. Setting this property after the video subsystem has been
* initialized has no effect, and reading it when the video subsystem is
* uninitialized will either return the user provided value, if one was set
* prior to initialization, or NULL. See docs/README-wayland.md for more
* information.
*
* \since This macro is available since SDL 3.2.0.
*/
#define SDL_PROP_GLOBAL_VIDEO_WAYLAND_WL_DISPLAY_POINTER "SDL.video.wayland.wl_display"
/**
* The session ID string used for saving and restoring window state across
* runs.
*
* This requires that the compositor supports the `xdg_session_management_v1`
* protocol.
*
* To save and restore the current state of Wayland toplevel windows, set this
* to a non-null value before creating a window, and serialize this value
* before shutting down. To restore the previous state on subsequent runs, set
* this property to the previously serialized value before window creation.
*
* This can be set at any time before the first call to a window creation
* function. Reading should be deferred until serialization time, as
* compositors may not set the session identifier string immediately, and the
* identifier string may change during runtime, so it should not be cached.
*
* Setting this to an empty string ("") before creating a window will cause a
* new session with an automatically generated identifier string to be
* created.
*
* Setting this to null or an empty string before shutting down the video
* subsystem will cause the existing session to be removed.
*
* Note that for windows to be saved/restored by the session, they also need a
* stable, unique identifier string set via the
* `SDL_PROP_WINDOW_CREATE_WAYLAND_WINDOW_ID_STRING` property at creation
* time.
*
* \since This property is available since SDL 3.6.0.
*
* \sa SDL_CreateWindowWithProperties
*/
#define SDL_PROP_GLOBAL_VIDEO_WAYLAND_SESSION_ID_STRING "SDL.video.wayland.session_id"
/**
* System theme.
*
* \since This enum is available since SDL 3.2.0.
*/
typedef enum SDL_SystemTheme
{
SDL_SYSTEM_THEME_UNKNOWN, /**< Unknown system theme */
SDL_SYSTEM_THEME_LIGHT, /**< Light colored system theme */
SDL_SYSTEM_THEME_DARK /**< Dark colored system theme */
} SDL_SystemTheme;
/**
* Internal display mode data.
*
* This lives as a field in SDL_DisplayMode, as opaque data.
*
* \since This struct is available since SDL 3.2.0.
*
* \sa SDL_DisplayMode
*/
typedef struct SDL_DisplayModeData SDL_DisplayModeData;
/**
* The structure that defines a display mode.
*
* \since This struct is available since SDL 3.2.0.
*
* \sa SDL_GetFullscreenDisplayModes
* \sa SDL_GetDesktopDisplayMode
* \sa SDL_GetCurrentDisplayMode
* \sa SDL_SetWindowFullscreenMode
* \sa SDL_GetWindowFullscreenMode
*/
typedef struct SDL_DisplayMode
{
SDL_DisplayID displayID; /**< the display this mode is associated with */
SDL_PixelFormat format; /**< pixel format */
int w; /**< width */
int h; /**< height */
float pixel_density; /**< scale converting size to pixels (e.g. a 1920x1080 mode with 2.0 scale would have 3840x2160 pixels) */
float refresh_rate; /**< refresh rate (or 0.0f for unspecified) */
int refresh_rate_numerator; /**< precise refresh rate numerator (or 0 for unspecified) */
int refresh_rate_denominator; /**< precise refresh rate denominator */
SDL_DisplayModeData *internal; /**< Private */
} SDL_DisplayMode;
/**
* Display orientation values; the way a display is rotated.
*
* \since This enum is available since SDL 3.2.0.
*/
typedef enum SDL_DisplayOrientation
{
SDL_ORIENTATION_UNKNOWN, /**< The display orientation can't be determined */
SDL_ORIENTATION_LANDSCAPE, /**< The display is in landscape mode, with the right side up, relative to portrait mode */
SDL_ORIENTATION_LANDSCAPE_FLIPPED, /**< The display is in landscape mode, with the left side up, relative to portrait mode */
SDL_ORIENTATION_PORTRAIT, /**< The display is in portrait mode */
SDL_ORIENTATION_PORTRAIT_FLIPPED /**< The display is in portrait mode, upside down */
} SDL_DisplayOrientation;
/**
* The struct used as an opaque handle to a window.
*
* \since This struct is available since SDL 3.2.0.
*
* \sa SDL_CreateWindow
*/
typedef struct SDL_Window SDL_Window;
/**
* The flags on a window.
*
* These cover a lot of true/false, or on/off, window state. Some of it is
* immutable after being set through SDL_CreateWindow(), some of it can be
* changed on existing windows by the app, and some of it might be altered by
* the user or system outside of the app's control.
*
* When creating windows with `SDL_WINDOW_RESIZABLE`, SDL will constrain
* resizable windows to the dimensions recommended by the compositor to fit it
* within the usable desktop space, although some compositors will do this
* automatically without intervention as well. Use `SDL_SetWindowResizable`
* after creation instead if you wish to create a window with a specific size.
*
* \since This datatype is available since SDL 3.2.0.
*
* \sa SDL_GetWindowFlags
*/
typedef Uint64 SDL_WindowFlags;
#define SDL_WINDOW_FULLSCREEN SDL_UINT64_C(0x0000000000000001) /**< window is in fullscreen mode */
#define SDL_WINDOW_OPENGL SDL_UINT64_C(0x0000000000000002) /**< window usable with OpenGL context */
#define SDL_WINDOW_OCCLUDED SDL_UINT64_C(0x0000000000000004) /**< window is occluded */
#define SDL_WINDOW_HIDDEN SDL_UINT64_C(0x0000000000000008) /**< window is neither mapped onto the desktop nor shown in the taskbar/dock/window list; SDL_ShowWindow() is required for it to become visible */
#define SDL_WINDOW_BORDERLESS SDL_UINT64_C(0x0000000000000010) /**< no window decoration */
#define SDL_WINDOW_RESIZABLE SDL_UINT64_C(0x0000000000000020) /**< window can be resized */
#define SDL_WINDOW_MINIMIZED SDL_UINT64_C(0x0000000000000040) /**< window is minimized */
#define SDL_WINDOW_MAXIMIZED SDL_UINT64_C(0x0000000000000080) /**< window is maximized */
#define SDL_WINDOW_MOUSE_GRABBED SDL_UINT64_C(0x0000000000000100) /**< window has grabbed mouse input */
#define SDL_WINDOW_INPUT_FOCUS SDL_UINT64_C(0x0000000000000200) /**< window has input focus */
#define SDL_WINDOW_MOUSE_FOCUS SDL_UINT64_C(0x0000000000000400) /**< window has mouse focus */
#define SDL_WINDOW_EXTERNAL SDL_UINT64_C(0x0000000000000800) /**< window not created by SDL */
#define SDL_WINDOW_MODAL SDL_UINT64_C(0x0000000000001000) /**< window is modal */
#define SDL_WINDOW_HIGH_PIXEL_DENSITY SDL_UINT64_C(0x0000000000002000) /**< window uses high pixel density back buffer if possible */
#define SDL_WINDOW_MOUSE_CAPTURE SDL_UINT64_C(0x0000000000004000) /**< window has mouse captured (unrelated to MOUSE_GRABBED) */
#define SDL_WINDOW_MOUSE_RELATIVE_MODE SDL_UINT64_C(0x0000000000008000) /**< window has relative mode enabled */
#define SDL_WINDOW_ALWAYS_ON_TOP SDL_UINT64_C(0x0000000000010000) /**< window should always be above others */
#define SDL_WINDOW_UTILITY SDL_UINT64_C(0x0000000000020000) /**< window should be treated as a utility window, not showing in the task bar and window list */
#define SDL_WINDOW_TOOLTIP SDL_UINT64_C(0x0000000000040000) /**< window should be treated as a tooltip and does not get mouse or keyboard focus, requires a parent window */
#define SDL_WINDOW_POPUP_MENU SDL_UINT64_C(0x0000000000080000) /**< window should be treated as a popup menu, requires a parent window */
#define SDL_WINDOW_KEYBOARD_GRABBED SDL_UINT64_C(0x0000000000100000) /**< window has grabbed keyboard input */
#define SDL_WINDOW_FILL_DOCUMENT SDL_UINT64_C(0x0000000000200000) /**< window is in fill-document mode (Emscripten only), since SDL 3.4.0 */
#define SDL_WINDOW_VULKAN SDL_UINT64_C(0x0000000010000000) /**< window usable for Vulkan surface */
#define SDL_WINDOW_METAL SDL_UINT64_C(0x0000000020000000) /**< window usable for Metal view */
#define SDL_WINDOW_TRANSPARENT SDL_UINT64_C(0x0000000040000000) /**< window with transparent buffer */
#define SDL_WINDOW_NOT_FOCUSABLE SDL_UINT64_C(0x0000000080000000) /**< window should not be focusable */
/**
* A magic value used with SDL_WINDOWPOS_UNDEFINED.
*
* Generally this macro isn't used directly, but rather through
* SDL_WINDOWPOS_UNDEFINED or SDL_WINDOWPOS_UNDEFINED_DISPLAY.
*
* \since This macro is available since SDL 3.2.0.
*
* \sa SDL_SetWindowPosition
*/
#define SDL_WINDOWPOS_UNDEFINED_MASK 0x1FFF0000u
/**
* Used to indicate that you don't care what the window position is.
*
* If you _really_ don't care, SDL_WINDOWPOS_UNDEFINED is the same, but always
* uses the primary display instead of specifying one.
*
* \param X the SDL_DisplayID of the display to use.
*
* \since This macro is available since SDL 3.2.0.
*
* \sa SDL_SetWindowPosition
*/
#define SDL_WINDOWPOS_UNDEFINED_DISPLAY(X) (SDL_WINDOWPOS_UNDEFINED_MASK|(X))
/**
* Used to indicate that you don't care what the window position/display is.
*
* This always uses the primary display.
*
* \since This macro is available since SDL 3.2.0.
*
* \sa SDL_SetWindowPosition
*/
#define SDL_WINDOWPOS_UNDEFINED SDL_WINDOWPOS_UNDEFINED_DISPLAY(0)
/**
* A macro to test if the window position is marked as "undefined."
*
* \param X the window position value.
*
* \since This macro is available since SDL 3.2.0.
*
* \sa SDL_SetWindowPosition
*/
#define SDL_WINDOWPOS_ISUNDEFINED(X) (((X)&0xFFFF0000) == SDL_WINDOWPOS_UNDEFINED_MASK)
/**
* A magic value used with SDL_WINDOWPOS_CENTERED.
*
* Generally this macro isn't used directly, but rather through
* SDL_WINDOWPOS_CENTERED or SDL_WINDOWPOS_CENTERED_DISPLAY.
*
* \since This macro is available since SDL 3.2.0.
*
* \sa SDL_SetWindowPosition
*/
#define SDL_WINDOWPOS_CENTERED_MASK 0x2FFF0000u
/**
* Used to indicate that the window position should be centered.
*
* SDL_WINDOWPOS_CENTERED is the same, but always uses the primary display
* instead of specifying one.
*
* \param X the SDL_DisplayID of the display to use.
*
* \since This macro is available since SDL 3.2.0.
*
* \sa SDL_SetWindowPosition
*/
#define SDL_WINDOWPOS_CENTERED_DISPLAY(X) (SDL_WINDOWPOS_CENTERED_MASK|(X))
/**
* Used to indicate that the window position should be centered.
*
* This always uses the primary display.
*
* \since This macro is available since SDL 3.2.0.
*
* \sa SDL_SetWindowPosition
*/
#define SDL_WINDOWPOS_CENTERED SDL_WINDOWPOS_CENTERED_DISPLAY(0)
/**
* A macro to test if the window position is marked as "centered."
*
* \param X the window position value.
*
* \since This macro is available since SDL 3.2.0.
*
* \sa SDL_GetWindowPosition
*/
#define SDL_WINDOWPOS_ISCENTERED(X) \
(((X)&0xFFFF0000) == SDL_WINDOWPOS_CENTERED_MASK)
/**
* Window flash operation.
*
* \since This enum is available since SDL 3.2.0.
*/
typedef enum SDL_FlashOperation
{
SDL_FLASH_CANCEL, /**< Cancel any window flash state */
SDL_FLASH_BRIEFLY, /**< Flash the window briefly to get attention */
SDL_FLASH_UNTIL_FOCUSED /**< Flash the window until it gets focus */
} SDL_FlashOperation;
/**
* Window progress state
*
* \since This enum is available since SDL 3.2.8.
*/
typedef enum SDL_ProgressState
{
SDL_PROGRESS_STATE_INVALID = -1, /**< An invalid progress state indicating an error; check SDL_GetError() */
SDL_PROGRESS_STATE_NONE, /**< No progress bar is shown */
SDL_PROGRESS_STATE_INDETERMINATE, /**< The progress bar is shown in a indeterminate state */
SDL_PROGRESS_STATE_NORMAL, /**< The progress bar is shown in a normal state */
SDL_PROGRESS_STATE_PAUSED, /**< The progress bar is shown in a paused state */
SDL_PROGRESS_STATE_ERROR /**< The progress bar is shown in a state indicating the application had an error */
} SDL_ProgressState;
/**
* An opaque handle to an OpenGL context.
*
* \since This datatype is available since SDL 3.2.0.
*
* \sa SDL_GL_CreateContext
* \sa SDL_GL_SetAttribute
* \sa SDL_GL_MakeCurrent
* \sa SDL_GL_DestroyContext
*/
typedef struct SDL_GLContextState *SDL_GLContext;
/**
* Opaque type for an EGL display.
*
* \since This datatype is available since SDL 3.2.0.
*/
typedef void *SDL_EGLDisplay;
/**
* Opaque type for an EGL config.
*
* \since This datatype is available since SDL 3.2.0.
*/
typedef void *SDL_EGLConfig;
/**
* Opaque type for an EGL surface.
*
* \since This datatype is available since SDL 3.2.0.
*/
typedef void *SDL_EGLSurface;
/**
* An EGL attribute, used when creating an EGL context.
*
* \since This datatype is available since SDL 3.2.0.
*/
typedef intptr_t SDL_EGLAttrib;
/**
* An EGL integer attribute, used when creating an EGL surface.
*
* \since This datatype is available since SDL 3.2.0.
*/
typedef int SDL_EGLint;
/**
* EGL platform attribute initialization callback.
*
* This is called when SDL is attempting to create an EGL context, to let the
* app add extra attributes to its eglGetPlatformDisplay() call.
*
* The callback should return a pointer to an EGL attribute array terminated
* with `EGL_NONE`. If this function returns NULL, the SDL_CreateWindow
* process will fail gracefully.
*
* The returned pointer should be allocated with SDL_malloc() and will be
* passed to SDL_free().
*
* The arrays returned by each callback will be appended to the existing
* attribute arrays defined by SDL.
*
* \param userdata an app-controlled pointer that is passed to the callback.
* \returns a newly-allocated array of attributes, terminated with `EGL_NONE`.
*
* \since This datatype is available since SDL 3.2.0.
*
* \sa SDL_EGL_SetAttributeCallbacks
*/
typedef SDL_EGLAttrib *(SDLCALL *SDL_EGLAttribArrayCallback)(void *userdata);
/**
* EGL surface/context attribute initialization callback types.
*
* This is called when SDL is attempting to create an EGL surface, to let the
* app add extra attributes to its eglCreateWindowSurface() or
* eglCreateContext calls.
*
* For convenience, the EGLDisplay and EGLConfig to use are provided to the
* callback.
*
* The callback should return a pointer to an EGL attribute array terminated
* with `EGL_NONE`. If this function returns NULL, the SDL_CreateWindow
* process will fail gracefully.
*
* The returned pointer should be allocated with SDL_malloc() and will be
* passed to SDL_free().
*
* The arrays returned by each callback will be appended to the existing
* attribute arrays defined by SDL.
*
* \param userdata an app-controlled pointer that is passed to the callback.
* \param display the EGL display to be used.
* \param config the EGL config to be used.
* \returns a newly-allocated array of attributes, terminated with `EGL_NONE`.
*
* \since This datatype is available since SDL 3.2.0.
*
* \sa SDL_EGL_SetAttributeCallbacks
*/
typedef SDL_EGLint *(SDLCALL *SDL_EGLIntArrayCallback)(void *userdata, SDL_EGLDisplay display, SDL_EGLConfig config);
/**
* An enumeration of OpenGL configuration attributes.
*
* While you can set most OpenGL attributes normally, they must be known
* before SDL creates the window that will be used with the OpenGL context.
* These attributes are set and read with SDL_GL_SetAttribute() and
* SDL_GL_GetAttribute().
*
* In some cases, these attributes are minimum requests; the GL does not
* promise to give you exactly what you asked for. It's possible to ask for a
* 16-bit depth buffer and get a 24-bit one instead, for example, or to ask
* for no stencil buffer and still have one available. Context creation should
* fail if the GL can't provide your requested attributes at a minimum, but
* you should check to see exactly what you got.
*
* \since This enum is available since SDL 3.2.0.
*/
typedef enum SDL_GLAttr
{
SDL_GL_RED_SIZE, /**< the minimum number of bits for the red channel of the color buffer; defaults to 8. */
SDL_GL_GREEN_SIZE, /**< the minimum number of bits for the green channel of the color buffer; defaults to 8. */
SDL_GL_BLUE_SIZE, /**< the minimum number of bits for the blue channel of the color buffer; defaults to 8. */
SDL_GL_ALPHA_SIZE, /**< the minimum number of bits for the alpha channel of the color buffer; defaults to 8. */
SDL_GL_BUFFER_SIZE, /**< the minimum number of bits for frame buffer size; defaults to 0. */
SDL_GL_DOUBLEBUFFER, /**< whether the output is single or double buffered; defaults to double buffering on. */
SDL_GL_DEPTH_SIZE, /**< the minimum number of bits in the depth buffer; defaults to 16. */
SDL_GL_STENCIL_SIZE, /**< the minimum number of bits in the stencil buffer; defaults to 0. */
SDL_GL_ACCUM_RED_SIZE, /**< the minimum number of bits for the red channel of the accumulation buffer; defaults to 0. */
SDL_GL_ACCUM_GREEN_SIZE, /**< the minimum number of bits for the green channel of the accumulation buffer; defaults to 0. */
SDL_GL_ACCUM_BLUE_SIZE, /**< the minimum number of bits for the blue channel of the accumulation buffer; defaults to 0. */
SDL_GL_ACCUM_ALPHA_SIZE, /**< the minimum number of bits for the alpha channel of the accumulation buffer; defaults to 0. */
SDL_GL_STEREO, /**< whether the output is stereo 3D; defaults to off. */
SDL_GL_MULTISAMPLEBUFFERS, /**< the number of buffers used for multisample anti-aliasing; defaults to 0. */
SDL_GL_MULTISAMPLESAMPLES, /**< the number of samples used around the current pixel used for multisample anti-aliasing. */
SDL_GL_ACCELERATED_VISUAL, /**< set to 1 to require hardware acceleration, set to 0 to force software rendering; defaults to allow either. */
SDL_GL_RETAINED_BACKING, /**< not used (deprecated). */
SDL_GL_CONTEXT_MAJOR_VERSION, /**< OpenGL context major version. */
SDL_GL_CONTEXT_MINOR_VERSION, /**< OpenGL context minor version. */
SDL_GL_CONTEXT_FLAGS, /**< some combination of 0 or more of elements of the SDL_GLContextFlag enumeration; defaults to 0. */
SDL_GL_CONTEXT_PROFILE_MASK, /**< type of GL context (Core, Compatibility, ES). See SDL_GLProfile; default value depends on platform. */
SDL_GL_SHARE_WITH_CURRENT_CONTEXT, /**< OpenGL context sharing; defaults to 0. */
SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, /**< requests sRGB capable visual; defaults to 0. */
SDL_GL_CONTEXT_RELEASE_BEHAVIOR, /**< sets context the release behavior. See SDL_GLContextReleaseFlag; defaults to FLUSH. */
SDL_GL_CONTEXT_RESET_NOTIFICATION, /**< set context reset notification. See SDL_GLContextResetNotification; defaults to NO_NOTIFICATION. */
SDL_GL_CONTEXT_NO_ERROR,
SDL_GL_FLOATBUFFERS,
SDL_GL_EGL_PLATFORM
} SDL_GLAttr;
/**
* Possible values to be set for the SDL_GL_CONTEXT_PROFILE_MASK attribute.
*
* \since This datatype is available since SDL 3.2.0.
*/
typedef Uint32 SDL_GLProfile;
#define SDL_GL_CONTEXT_PROFILE_CORE 0x0001 /**< OpenGL Core Profile context */
#define SDL_GL_CONTEXT_PROFILE_COMPATIBILITY 0x0002 /**< OpenGL Compatibility Profile context */
#define SDL_GL_CONTEXT_PROFILE_ES 0x0004 /**< GLX_CONTEXT_ES2_PROFILE_BIT_EXT */
/**
* Possible flags to be set for the SDL_GL_CONTEXT_FLAGS attribute.
*
* \since This datatype is available since SDL 3.2.0.
*/
typedef Uint32 SDL_GLContextFlag;
#define SDL_GL_CONTEXT_DEBUG_FLAG 0x0001
#define SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG 0x0002
#define SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG 0x0004
#define SDL_GL_CONTEXT_RESET_ISOLATION_FLAG 0x0008
/**
* Possible values to be set for the SDL_GL_CONTEXT_RELEASE_BEHAVIOR
* attribute.
*
* \since This datatype is available since SDL 3.2.0.
*/
typedef Uint32 SDL_GLContextReleaseFlag;
#define SDL_GL_CONTEXT_RELEASE_BEHAVIOR_NONE 0x0000
#define SDL_GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH 0x0001
/**
* Possible values to be set SDL_GL_CONTEXT_RESET_NOTIFICATION attribute.
*
* \since This datatype is available since SDL 3.2.0.
*/
typedef Uint32 SDL_GLContextResetNotification;
#define SDL_GL_CONTEXT_RESET_NO_NOTIFICATION 0x0000
#define SDL_GL_CONTEXT_RESET_LOSE_CONTEXT 0x0001
/* Function prototypes */
/**
* Get the number of video drivers compiled into SDL.
*
* \returns the number of built in video drivers.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.2.0.
*
* \sa SDL_GetVideoDriver
*/
extern SDL_DECLSPEC int SDLCALL SDL_GetNumVideoDrivers(void);
/**
* Get the name of a built in video driver.
*
* The video drivers are presented in the order in which they are normally
* checked during initialization.
*
* The names of drivers are all simple, low-ASCII identifiers, like "cocoa",
* "x11" or "windows". These never have Unicode characters, and are not meant
* to be proper names.
*
* \param index the index of a video driver.
* \returns the name of the video driver with the given **index**, or NULL if
* index is out of bounds.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.2.0.
*
* \sa SDL_GetNumVideoDrivers
*/
extern SDL_DECLSPEC const char * SDLCALL SDL_GetVideoDriver(int index);
/**
* Get the name of the currently initialized video driver.
*
* The names of drivers are all simple, low-ASCII identifiers, like "cocoa",
* "x11" or "windows". These never have Unicode characters, and are not meant
* to be proper names.
*
* \returns the name of the current video driver or NULL if no driver has been
* initialized.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.2.0.
*
* \sa SDL_GetNumVideoDrivers
* \sa SDL_GetVideoDriver
*/
extern SDL_DECLSPEC const char * SDLCALL SDL_GetCurrentVideoDriver(void);
/**
* Get the current system theme.
*
* \returns the current system theme, light, dark, or unknown.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.2.0.
*/
extern SDL_DECLSPEC SDL_SystemTheme SDLCALL SDL_GetSystemTheme(void);
/**
* Get a list of currently connected displays.
*
* \param count a pointer filled in with the number of displays returned, may
* be NULL.
* \returns a 0 terminated array of display instance IDs or NULL on failure;
* call SDL_GetError() for more information. This should be freed
* with SDL_free() when it is no longer needed.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.2.0.
*/
extern SDL_DECLSPEC SDL_DisplayID * SDLCALL SDL_GetDisplays(int *count);
/**
* Return the primary display.
*
* \returns the instance ID of the primary display on success or 0 on failure;
* call SDL_GetError() for more information.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.2.0.
*
* \sa SDL_GetDisplays
*/
extern SDL_DECLSPEC SDL_DisplayID SDLCALL SDL_GetPrimaryDisplay(void);
/**
* Get the properties associated with a display.
*
* The following read-only properties are provided by SDL:
*
* - `SDL_PROP_DISPLAY_HDR_ENABLED_BOOLEAN`: true if the display has HDR
* headroom above the SDR white point. This is for informational and
* diagnostic purposes only, as not all platforms provide this information
* at the display level.
*
* On KMS/DRM:
*
* - `SDL_PROP_DISPLAY_KMSDRM_PANEL_ORIENTATION_NUMBER`: the "panel
* orientation" property for the display in degrees of clockwise rotation.
* Note that this is provided only as a hint, and the application is
* responsible for any coordinate transformations needed to conform to the
* requested display orientation.
*
* On Wayland:
*
* - `SDL_PROP_DISPLAY_WAYLAND_WL_OUTPUT_POINTER`: the wl_output associated
* with the display
*
* On Windows:
*
* - `SDL_PROP_DISPLAY_WINDOWS_HMONITOR_POINTER`: the monitor handle
* (HMONITOR) associated with the display
*
* \param displayID the instance ID of the display to query.
* \returns a valid property ID on success or 0 on failure; call
* SDL_GetError() for more information.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.2.0.
*/
extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetDisplayProperties(SDL_DisplayID displayID);
#define SDL_PROP_DISPLAY_HDR_ENABLED_BOOLEAN "SDL.display.HDR_enabled"
#define SDL_PROP_DISPLAY_KMSDRM_PANEL_ORIENTATION_NUMBER "SDL.display.KMSDRM.panel_orientation"
#define SDL_PROP_DISPLAY_WAYLAND_WL_OUTPUT_POINTER "SDL.display.wayland.wl_output"
#define SDL_PROP_DISPLAY_WINDOWS_HMONITOR_POINTER "SDL.display.windows.hmonitor"
/**
* Get the name of a display in UTF-8 encoding.
*
* \param displayID the instance ID of the display to query.
* \returns the name of a display or NULL on failure; call SDL_GetError() for
* more information.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.2.0.
*
* \sa SDL_GetDisplays
*/
extern SDL_DECLSPEC const char * SDLCALL SDL_GetDisplayName(SDL_DisplayID displayID);
/**
* Get the desktop area represented by a display.
*
* The primary display is often located at (0,0), but may be placed at a
* different location depending on monitor layout.
*
* \param displayID the instance ID of the display to query.
* \param rect the SDL_Rect structure filled in with the display bounds.
* \returns true on success or false on failure; call SDL_GetError() for more
* information.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.2.0.
*
* \sa SDL_GetDisplayUsableBounds
* \sa SDL_GetDisplays
*/
extern SDL_DECLSPEC bool SDLCALL SDL_GetDisplayBounds(SDL_DisplayID displayID, SDL_Rect *rect);
/**
* Get the usable desktop area represented by a display, in screen
* coordinates.
*
* This is the same area as SDL_GetDisplayBounds() reports, but with portions
* reserved by the system removed. For example, on Apple's macOS, this
* subtracts the area occupied by the menu bar and dock.
*
* Setting a window to be fullscreen generally bypasses these unusable areas,
* so these are good guidelines for the maximum space available to a
* non-fullscreen window.
*
* \param displayID the instance ID of the display to query.
* \param rect the SDL_Rect structure filled in with the display bounds.
* \returns true on success or false on failure; call SDL_GetError() for more
* information.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.2.0.
*
* \sa SDL_GetDisplayBounds
* \sa SDL_GetDisplays
*/
extern SDL_DECLSPEC bool SDLCALL SDL_GetDisplayUsableBounds(SDL_DisplayID displayID, SDL_Rect *rect);
/**
* Get the orientation of a display when it is unrotated.
*
* \param displayID the instance ID of the display to query.
* \returns the SDL_DisplayOrientation enum value of the display, or
* `SDL_ORIENTATION_UNKNOWN` if it isn't available.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.2.0.
*
* \sa SDL_GetDisplays
*/
extern SDL_DECLSPEC SDL_DisplayOrientation SDLCALL SDL_GetNaturalDisplayOrientation(SDL_DisplayID displayID);
/**
* Get the orientation of a display.
*
* \param displayID the instance ID of the display to query.
* \returns the SDL_DisplayOrientation enum value of the display, or
* `SDL_ORIENTATION_UNKNOWN` if it isn't available.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.2.0.
*
* \sa SDL_GetDisplays
*/
extern SDL_DECLSPEC SDL_DisplayOrientation SDLCALL SDL_GetCurrentDisplayOrientation(SDL_DisplayID displayID);
/**
* Get the content scale of a display.
*
* The content scale is the expected scale for content based on the DPI
* settings of the display. For example, a 4K display might have a 2.0 (200%)
* display scale, which means that the user expects UI elements to be twice as
* big on this display, to aid in readability.
*
* After window creation, SDL_GetWindowDisplayScale() should be used to query
* the content scale factor for individual windows instead of querying the
* display for a window and calling this function, as the per-window content
* scale factor may differ from the base value of the display it is on,
* particularly on high-DPI and/or multi-monitor desktop configurations.
*
* \param displayID the instance ID of the display to query.
* \returns the content scale of the display, or 0.0f on failure; call
* SDL_GetError() for more information.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.2.0.
*
* \sa SDL_GetWindowDisplayScale
* \sa SDL_GetDisplays
*/
extern SDL_DECLSPEC float SDLCALL SDL_GetDisplayContentScale(SDL_DisplayID displayID);
/**
* Get a list of fullscreen display modes available on a display.
*
* The display modes are sorted in this priority:
*
* - w -> largest to smallest
* - h -> largest to smallest
* - bits per pixel -> more colors to fewer colors
* - packed pixel layout -> largest to smallest
* - refresh rate -> highest to lowest
* - pixel density -> lowest to highest
*
* \param displayID the instance ID of the display to query.
* \param count a pointer filled in with the number of display modes returned,
* may be NULL.
* \returns a NULL terminated array of display mode pointers or NULL on
* failure; call SDL_GetError() for more information. This is a
* single allocation that should be freed with SDL_free() when it is
* no longer needed.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.2.0.
*
* \sa SDL_GetDisplays
*/
extern SDL_DECLSPEC SDL_DisplayMode ** SDLCALL SDL_GetFullscreenDisplayModes(SDL_DisplayID displayID, int *count);
/**
* Get the closest match to the requested display mode.
*
* The available display modes are scanned and `closest` is filled in with the
* closest mode matching the requested mode and returned. The mode format and
* refresh rate default to the desktop mode if they are set to 0. The modes
* are scanned with size being first priority, format being second priority,
* and finally checking the refresh rate. If all the available modes are too
* small, then false is returned.
*
* \param displayID the instance ID of the display to query.
* \param w the width in pixels of the desired display mode.
* \param h the height in pixels of the desired display mode.
* \param refresh_rate the refresh rate of the desired display mode, or 0.0f
* for the desktop refresh rate.
* \param include_high_density_modes boolean to include high density modes in
* the search.
* \param closest a pointer filled in with the closest display mode equal to
* or larger than the desired mode.
* \returns true on success or false on failure; call SDL_GetError() for more
* information.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.2.0.
*
* \sa SDL_GetDisplays
* \sa SDL_GetFullscreenDisplayModes
*/
extern SDL_DECLSPEC bool SDLCALL SDL_GetClosestFullscreenDisplayMode(SDL_DisplayID displayID, int w, int h, float refresh_rate, bool include_high_density_modes, SDL_DisplayMode *closest);
/**
* Get information about the desktop's display mode.
*
* There's a difference between this function and SDL_GetCurrentDisplayMode()
* when SDL runs fullscreen and has changed the resolution. In that case this
* function will return the previous native display mode, and not the current
* display mode.
*
* \param displayID the instance ID of the display to query.
* \returns a pointer to the desktop display mode or NULL on failure; call
* SDL_GetError() for more information.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.2.0.
*
* \sa SDL_GetCurrentDisplayMode
* \sa SDL_GetDisplays
*/
extern SDL_DECLSPEC const SDL_DisplayMode * SDLCALL SDL_GetDesktopDisplayMode(SDL_DisplayID displayID);
/**
* Get information about the current display mode.
*
* There's a difference between this function and SDL_GetDesktopDisplayMode()
* when SDL runs fullscreen and has changed the resolution. In that case this
* function will return the current display mode, and not the previous native
* display mode.
*
* \param displayID the instance ID of the display to query.
* \returns a pointer to the desktop display mode or NULL on failure; call
* SDL_GetError() for more information.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.2.0.
*
* \sa SDL_GetDesktopDisplayMode
* \sa SDL_GetDisplays
*/
extern SDL_DECLSPEC const SDL_DisplayMode * SDLCALL SDL_GetCurrentDisplayMode(SDL_DisplayID displayID);
/**
* Get the display containing a point.
*
* \param point the point to query.
* \returns the instance ID of the display containing the point or 0 on
* failure; call SDL_GetError() for more information.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.2.0.
*
* \sa SDL_GetDisplayBounds
* \sa SDL_GetDisplays
*/
extern SDL_DECLSPEC SDL_DisplayID SDLCALL SDL_GetDisplayForPoint(const SDL_Point *point);
/**
* Get the display primarily containing a rect.
*
* \param rect the rect to query.
* \returns the instance ID of the display entirely containing the rect or
* closest to the center of the rect on success or 0 on failure; call
* SDL_GetError() for more information.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.2.0.
*
* \sa SDL_GetDisplayBounds
* \sa SDL_GetDisplays
*/
extern SDL_DECLSPEC SDL_DisplayID SDLCALL SDL_GetDisplayForRect(const SDL_Rect *rect);
/**
* Get the display associated with a window.
*
* \param window the window to query.
* \returns the instance ID of the display containing the center of the window
* on success or 0 on failure; call SDL_GetError() for more
* information.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 3.2.0.
*
* \sa SDL_GetDisplayBounds
* \sa SDL_GetDisplays
*/
extern SDL_DECLSPEC SDL_DisplayID SDLCALL SDL_GetDisplayForWindow(SDL_Window *window);
/**
* Get the pixel density of a window.
*
* This is a ratio of pixel size to window size. For example, if the window is
* 1920x1080 and it has a high density back buffer of 3840x2160 pixels, it
* would have a pixel density of 2.0.
*
* \param window the window to query.