-
Notifications
You must be signed in to change notification settings - Fork 2k
/
Copy pathSDL_video.h
2228 lines (2096 loc) · 83.6 KB
/
SDL_video.h
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-2025 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
*
* Header file for SDL video functions.
*/
#ifndef SDL_video_h_
#define SDL_video_h_
#include "SDL_stdinc.h"
#include "SDL_pixels.h"
#include "SDL_rect.h"
#include "SDL_surface.h"
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
extern "C" {
#endif
/**
* The structure that defines a display mode
*
* \sa SDL_GetNumDisplayModes
* \sa SDL_GetDisplayMode
* \sa SDL_GetDesktopDisplayMode
* \sa SDL_GetCurrentDisplayMode
* \sa SDL_GetClosestDisplayMode
* \sa SDL_SetWindowDisplayMode
* \sa SDL_GetWindowDisplayMode
*/
typedef struct SDL_DisplayMode
{
Uint32 format; /**< pixel format */
int w; /**< width, in screen coordinates */
int h; /**< height, in screen coordinates */
int refresh_rate; /**< refresh rate (or zero for unspecified) */
void *driverdata; /**< driver-specific data, initialize to 0 */
} SDL_DisplayMode;
/**
* The opaque type used to identify a window.
*
* \sa SDL_CreateWindow
* \sa SDL_CreateWindowFrom
* \sa SDL_DestroyWindow
* \sa SDL_FlashWindow
* \sa SDL_GetWindowData
* \sa SDL_GetWindowFlags
* \sa SDL_GetWindowGrab
* \sa SDL_GetWindowKeyboardGrab
* \sa SDL_GetWindowMouseGrab
* \sa SDL_GetWindowPosition
* \sa SDL_GetWindowSize
* \sa SDL_GetWindowTitle
* \sa SDL_HideWindow
* \sa SDL_MaximizeWindow
* \sa SDL_MinimizeWindow
* \sa SDL_RaiseWindow
* \sa SDL_RestoreWindow
* \sa SDL_SetWindowData
* \sa SDL_SetWindowFullscreen
* \sa SDL_SetWindowGrab
* \sa SDL_SetWindowKeyboardGrab
* \sa SDL_SetWindowMouseGrab
* \sa SDL_SetWindowIcon
* \sa SDL_SetWindowPosition
* \sa SDL_SetWindowSize
* \sa SDL_SetWindowBordered
* \sa SDL_SetWindowResizable
* \sa SDL_SetWindowTitle
* \sa SDL_ShowWindow
*/
typedef struct SDL_Window SDL_Window;
/**
* The flags on a window
*
* \sa SDL_GetWindowFlags
*/
typedef enum SDL_WindowFlags
{
SDL_WINDOW_FULLSCREEN = 0x00000001, /**< fullscreen window */
SDL_WINDOW_OPENGL = 0x00000002, /**< window usable with OpenGL context */
SDL_WINDOW_SHOWN = 0x00000004, /**< window is visible */
SDL_WINDOW_HIDDEN = 0x00000008, /**< window is not visible */
SDL_WINDOW_BORDERLESS = 0x00000010, /**< no window decoration */
SDL_WINDOW_RESIZABLE = 0x00000020, /**< window can be resized */
SDL_WINDOW_MINIMIZED = 0x00000040, /**< window is minimized */
SDL_WINDOW_MAXIMIZED = 0x00000080, /**< window is maximized */
SDL_WINDOW_MOUSE_GRABBED = 0x00000100, /**< window has grabbed mouse input */
SDL_WINDOW_INPUT_FOCUS = 0x00000200, /**< window has input focus */
SDL_WINDOW_MOUSE_FOCUS = 0x00000400, /**< window has mouse focus */
SDL_WINDOW_FULLSCREEN_DESKTOP = ( SDL_WINDOW_FULLSCREEN | 0x00001000 ),
SDL_WINDOW_FOREIGN = 0x00000800, /**< window not created by SDL */
SDL_WINDOW_ALLOW_HIGHDPI = 0x00002000, /**< window should be created in high-DPI mode if supported.
On macOS NSHighResolutionCapable must be set true in the
application's Info.plist for this to have any effect. */
SDL_WINDOW_MOUSE_CAPTURE = 0x00004000, /**< window has mouse captured (unrelated to MOUSE_GRABBED) */
SDL_WINDOW_ALWAYS_ON_TOP = 0x00008000, /**< window should always be above others */
SDL_WINDOW_SKIP_TASKBAR = 0x00010000, /**< window should not be added to the taskbar */
SDL_WINDOW_UTILITY = 0x00020000, /**< window should be treated as a utility window */
SDL_WINDOW_TOOLTIP = 0x00040000, /**< window should be treated as a tooltip */
SDL_WINDOW_POPUP_MENU = 0x00080000, /**< window should be treated as a popup menu */
SDL_WINDOW_KEYBOARD_GRABBED = 0x00100000, /**< window has grabbed keyboard input */
SDL_WINDOW_VULKAN = 0x10000000, /**< window usable for Vulkan surface */
SDL_WINDOW_METAL = 0x20000000, /**< window usable for Metal view */
SDL_WINDOW_INPUT_GRABBED = SDL_WINDOW_MOUSE_GRABBED /**< equivalent to SDL_WINDOW_MOUSE_GRABBED for compatibility */
} SDL_WindowFlags;
/**
* Used to indicate that you don't care what the window position is.
*/
#define SDL_WINDOWPOS_UNDEFINED_MASK 0x1FFF0000u
#define SDL_WINDOWPOS_UNDEFINED_DISPLAY(X) (SDL_WINDOWPOS_UNDEFINED_MASK|(X))
#define SDL_WINDOWPOS_UNDEFINED SDL_WINDOWPOS_UNDEFINED_DISPLAY(0)
#define SDL_WINDOWPOS_ISUNDEFINED(X) \
(((X)&0xFFFF0000) == SDL_WINDOWPOS_UNDEFINED_MASK)
/**
* Used to indicate that the window position should be centered.
*/
#define SDL_WINDOWPOS_CENTERED_MASK 0x2FFF0000u
#define SDL_WINDOWPOS_CENTERED_DISPLAY(X) (SDL_WINDOWPOS_CENTERED_MASK|(X))
#define SDL_WINDOWPOS_CENTERED SDL_WINDOWPOS_CENTERED_DISPLAY(0)
#define SDL_WINDOWPOS_ISCENTERED(X) \
(((X)&0xFFFF0000) == SDL_WINDOWPOS_CENTERED_MASK)
/**
* Event subtype for window events
*/
typedef enum SDL_WindowEventID
{
SDL_WINDOWEVENT_NONE, /**< Never used */
SDL_WINDOWEVENT_SHOWN, /**< Window has been shown */
SDL_WINDOWEVENT_HIDDEN, /**< Window has been hidden */
SDL_WINDOWEVENT_EXPOSED, /**< Window has been exposed and should be
redrawn */
SDL_WINDOWEVENT_MOVED, /**< Window has been moved to data1, data2
*/
SDL_WINDOWEVENT_RESIZED, /**< Window has been resized to data1xdata2 */
SDL_WINDOWEVENT_SIZE_CHANGED, /**< The window size has changed, either as
a result of an API call or through the
system or user changing the window size. */
SDL_WINDOWEVENT_MINIMIZED, /**< Window has been minimized */
SDL_WINDOWEVENT_MAXIMIZED, /**< Window has been maximized */
SDL_WINDOWEVENT_RESTORED, /**< Window has been restored to normal size
and position */
SDL_WINDOWEVENT_ENTER, /**< Window has gained mouse focus */
SDL_WINDOWEVENT_LEAVE, /**< Window has lost mouse focus */
SDL_WINDOWEVENT_FOCUS_GAINED, /**< Window has gained keyboard focus */
SDL_WINDOWEVENT_FOCUS_LOST, /**< Window has lost keyboard focus */
SDL_WINDOWEVENT_CLOSE, /**< The window manager requests that the window be closed */
SDL_WINDOWEVENT_TAKE_FOCUS, /**< Window is being offered a focus (should SetWindowInputFocus() on itself or a subwindow, or ignore) */
SDL_WINDOWEVENT_HIT_TEST, /**< Window had a hit test that wasn't SDL_HITTEST_NORMAL. */
SDL_WINDOWEVENT_ICCPROF_CHANGED,/**< The ICC profile of the window's display has changed. */
SDL_WINDOWEVENT_DISPLAY_CHANGED /**< Window has been moved to display data1. */
} SDL_WindowEventID;
/**
* Event subtype for display events
*/
typedef enum SDL_DisplayEventID
{
SDL_DISPLAYEVENT_NONE, /**< Never used */
SDL_DISPLAYEVENT_ORIENTATION, /**< Display orientation has changed to data1 */
SDL_DISPLAYEVENT_CONNECTED, /**< Display has been added to the system */
SDL_DISPLAYEVENT_DISCONNECTED, /**< Display has been removed from the system */
SDL_DISPLAYEVENT_MOVED /**< Display has changed position */
} SDL_DisplayEventID;
/**
* Display orientation
*/
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;
/**
* Window flash operation
*/
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;
/**
* An opaque handle to an OpenGL context.
*
* \sa SDL_GL_CreateContext
*/
typedef void *SDL_GLContext;
/**
* OpenGL configuration attributes.
*
* While you can set most OpenGL attributes normally, the attributes listed
* above 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.
*
*
* [Multisample anti-aliasing](http://en.wikipedia.org/wiki/Multisample_anti-aliasing)
* is a type of full screen anti-aliasing. Multipsampling defaults to off but
* can be turned on by setting SDL_GL_MULTISAMPLEBUFFERS to 1 and
* SDL_GL_MULTISAMPLESAMPLES to a value greater than 0. Typical values are 2
* and 4.
*
* SDL_GL_CONTEXT_PROFILE_MASK determines the type of context created, while
* both SDL_GL_CONTEXT_MAJOR_VERSION and SDL_GL_CONTEXT_MINOR_VERSION
* determine which version. All three attributes must be set prior to creating
* the first window, and in general you can't change the value of
* SDL_GL_CONTEXT_PROFILE_MASK without first destroying all windows created
* with the previous setting.
*
* SDL_GL_CONTEXT_RELEASE_BEHAVIOR can be set to
* SDL_GL_CONTEXT_RELEASE_BEHAVIOR_NONE or
* SDL_GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH.
*/
typedef enum SDL_GLattr
{
SDL_GL_RED_SIZE, /**< the minimum number of bits for the red channel of the color buffer; defaults to 3. */
SDL_GL_GREEN_SIZE, /**< the minimum number of bits for the green channel of the color buffer; defaults to 3. */
SDL_GL_BLUE_SIZE, /**< the minimum number of bits for the blue channel of the color buffer; defaults to 2. */
SDL_GL_ALPHA_SIZE, /**< the minimum number of bits for the alpha channel of the color buffer; defaults to 0. */
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_EGL, /**< deprecated: set SDL_GL_CONTEXT_PROFILE_MASK to SDL_GL_CONTEXT_PROFILE_ES to enable instead. */
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 2.0.1) */
SDL_GL_CONTEXT_RELEASE_BEHAVIOR, /**< sets context the release behavior; defaults to 1. (>= SDL 2.0.4) */
SDL_GL_CONTEXT_RESET_NOTIFICATION,
SDL_GL_CONTEXT_NO_ERROR,
SDL_GL_FLOATBUFFERS
} SDL_GLattr;
typedef enum SDL_GLprofile
{
SDL_GL_CONTEXT_PROFILE_CORE = 0x0001,
SDL_GL_CONTEXT_PROFILE_COMPATIBILITY = 0x0002,
SDL_GL_CONTEXT_PROFILE_ES = 0x0004 /**< GLX_CONTEXT_ES2_PROFILE_BIT_EXT */
} SDL_GLprofile;
typedef enum SDL_GLcontextFlag
{
SDL_GL_CONTEXT_DEBUG_FLAG = 0x0001,
SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG = 0x0002,
SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG = 0x0004,
SDL_GL_CONTEXT_RESET_ISOLATION_FLAG = 0x0008
} SDL_GLcontextFlag;
typedef enum SDL_GLcontextReleaseFlag
{
SDL_GL_CONTEXT_RELEASE_BEHAVIOR_NONE = 0x0000,
SDL_GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH = 0x0001
} SDL_GLcontextReleaseFlag;
typedef enum SDL_GLContextResetNotification
{
SDL_GL_CONTEXT_RESET_NO_NOTIFICATION = 0x0000,
SDL_GL_CONTEXT_RESET_LOSE_CONTEXT = 0x0001
} SDL_GLContextResetNotification;
/* Function prototypes */
/**
* Get the number of video drivers compiled into SDL.
*
* \returns a number >= 1 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetVideoDriver
*/
extern 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.
*
* \param index the index of a video driver.
* \returns the name of the video driver with the given **index**.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetNumVideoDrivers
*/
extern DECLSPEC const char *SDLCALL SDL_GetVideoDriver(int index);
/**
* Initialize the video subsystem, optionally specifying a video driver.
*
* This function initializes the video subsystem, setting up a connection to
* the window manager, etc, and determines the available display modes and
* pixel formats, but does not initialize a window or graphics mode.
*
* If you use this function and you haven't used the SDL_INIT_VIDEO flag with
* either SDL_Init() or SDL_InitSubSystem(), you should call SDL_VideoQuit()
* before calling SDL_Quit().
*
* It is safe to call this function multiple times. SDL_VideoInit() will call
* SDL_VideoQuit() itself if the video subsystem has already been initialized.
*
* You can use SDL_GetNumVideoDrivers() and SDL_GetVideoDriver() to find a
* specific `driver_name`.
*
* \param driver_name the name of a video driver to initialize, or NULL for
* the default driver.
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetNumVideoDrivers
* \sa SDL_GetVideoDriver
* \sa SDL_InitSubSystem
* \sa SDL_VideoQuit
*/
extern DECLSPEC int SDLCALL SDL_VideoInit(const char *driver_name);
/**
* Shut down the video subsystem, if initialized with SDL_VideoInit().
*
* This function closes all windows, and restores the original video mode.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_VideoInit
*/
extern DECLSPEC void SDLCALL SDL_VideoQuit(void);
/**
* Get the name of the currently initialized video driver.
*
* \returns the name of the current video driver or NULL if no driver has been
* initialized.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetNumVideoDrivers
* \sa SDL_GetVideoDriver
*/
extern DECLSPEC const char *SDLCALL SDL_GetCurrentVideoDriver(void);
/**
* Get the number of available video displays.
*
* \returns a number >= 1 or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetDisplayBounds
*/
extern DECLSPEC int SDLCALL SDL_GetNumVideoDisplays(void);
/**
* Get the name of a display in UTF-8 encoding.
*
* \param displayIndex the index of display from which the name should be
* queried.
* \returns the name of a display or NULL for an invalid display index or
* failure; call SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetNumVideoDisplays
*/
extern DECLSPEC const char * SDLCALL SDL_GetDisplayName(int displayIndex);
/**
* Get the desktop area represented by a display.
*
* The primary display (`displayIndex` zero) is always located at 0,0.
*
* \param displayIndex the index of the display to query.
* \param rect the SDL_Rect structure filled in with the display bounds.
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetNumVideoDisplays
*/
extern DECLSPEC int SDLCALL SDL_GetDisplayBounds(int displayIndex, SDL_Rect * rect);
/**
* Get the usable desktop area represented by a display.
*
* The primary display (`displayIndex` zero) is always located at 0,0.
*
* 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.
*
* The parameter `rect` is ignored if it is NULL.
*
* This function also returns -1 if the parameter `displayIndex` is out of
* range.
*
* \param displayIndex the index of the display to query the usable bounds
* from.
* \param rect the SDL_Rect structure filled in with the display bounds.
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.5.
*
* \sa SDL_GetDisplayBounds
* \sa SDL_GetNumVideoDisplays
*/
extern DECLSPEC int SDLCALL SDL_GetDisplayUsableBounds(int displayIndex, SDL_Rect * rect);
/**
* Get the dots/pixels-per-inch for a display.
*
* Diagonal, horizontal and vertical DPI can all be optionally returned if the
* appropriate parameter is non-NULL.
*
* A failure of this function usually means that either no DPI information is
* available or the `displayIndex` is out of range.
*
* **WARNING**: This reports the DPI that the hardware reports, and it is not
* always reliable! It is almost always better to use SDL_GetWindowSize() to
* find the window size, which might be in logical points instead of pixels,
* and then SDL_GL_GetDrawableSize(), SDL_Vulkan_GetDrawableSize(),
* SDL_Metal_GetDrawableSize(), or SDL_GetRendererOutputSize(), and compare
* the two values to get an actual scaling value between the two. We will be
* rethinking how high-dpi details should be managed in SDL3 to make things
* more consistent, reliable, and clear.
*
* \param displayIndex the index of the display from which DPI information
* should be queried.
* \param ddpi a pointer filled in with the diagonal DPI of the display; may
* be NULL.
* \param hdpi a pointer filled in with the horizontal DPI of the display; may
* be NULL.
* \param vdpi a pointer filled in with the vertical DPI of the display; may
* be NULL.
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.4.
*
* \sa SDL_GetNumVideoDisplays
*/
extern DECLSPEC int SDLCALL SDL_GetDisplayDPI(int displayIndex, float * ddpi, float * hdpi, float * vdpi);
/**
* Get the orientation of a display.
*
* \param displayIndex the index of the display to query.
* \returns The SDL_DisplayOrientation enum value of the display, or
* `SDL_ORIENTATION_UNKNOWN` if it isn't available.
*
* \since This function is available since SDL 2.0.9.
*
* \sa SDL_GetNumVideoDisplays
*/
extern DECLSPEC SDL_DisplayOrientation SDLCALL SDL_GetDisplayOrientation(int displayIndex);
/**
* Get the number of available display modes.
*
* The `displayIndex` needs to be in the range from 0 to
* SDL_GetNumVideoDisplays() - 1.
*
* \param displayIndex the index of the display to query.
* \returns a number >= 1 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetDisplayMode
* \sa SDL_GetNumVideoDisplays
*/
extern DECLSPEC int SDLCALL SDL_GetNumDisplayModes(int displayIndex);
/**
* Get information about a specific display mode.
*
* The display modes are sorted in this priority:
*
* - width -> largest to smallest
* - height -> largest to smallest
* - bits per pixel -> more colors to fewer colors
* - packed pixel layout -> largest to smallest
* - refresh rate -> highest to lowest
*
* \param displayIndex the index of the display to query.
* \param modeIndex the index of the display mode to query.
* \param mode an SDL_DisplayMode structure filled in with the mode at
* `modeIndex`.
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetNumDisplayModes
*/
extern DECLSPEC int SDLCALL SDL_GetDisplayMode(int displayIndex, int modeIndex,
SDL_DisplayMode * mode);
/**
* 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 displayIndex the index of the display to query.
* \param mode an SDL_DisplayMode structure filled in with the current display
* mode.
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetCurrentDisplayMode
* \sa SDL_GetDisplayMode
* \sa SDL_SetWindowDisplayMode
*/
extern DECLSPEC int SDLCALL SDL_GetDesktopDisplayMode(int displayIndex, SDL_DisplayMode * mode);
/**
* 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 displayIndex the index of the display to query.
* \param mode an SDL_DisplayMode structure filled in with the current display
* mode.
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetDesktopDisplayMode
* \sa SDL_GetDisplayMode
* \sa SDL_GetNumVideoDisplays
* \sa SDL_SetWindowDisplayMode
*/
extern DECLSPEC int SDLCALL SDL_GetCurrentDisplayMode(int displayIndex, SDL_DisplayMode * mode);
/**
* 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 NULL is returned.
*
* \param displayIndex the index of the display to query.
* \param mode an SDL_DisplayMode structure containing the desired display
* mode.
* \param closest an SDL_DisplayMode structure filled in with the closest
* match of the available display modes.
* \returns the passed in value `closest` or NULL if no matching video mode
* was available; call SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetDisplayMode
* \sa SDL_GetNumDisplayModes
*/
extern DECLSPEC SDL_DisplayMode * SDLCALL SDL_GetClosestDisplayMode(int displayIndex, const SDL_DisplayMode * mode, SDL_DisplayMode * closest);
/**
* Get the index of the display containing a point
*
* \param point the point to query.
* \returns the index of the display containing the point or a negative error
* code on failure; call SDL_GetError() for more information.
*
* \since This function is available since SDL 2.24.0.
*
* \sa SDL_GetDisplayBounds
* \sa SDL_GetNumVideoDisplays
*/
extern DECLSPEC int SDLCALL SDL_GetPointDisplayIndex(const SDL_Point * point);
/**
* Get the index of the display primarily containing a rect
*
* \param rect the rect to query.
* \returns the index of the display entirely containing the rect or closest
* to the center of the rect on success or a negative error code on
* failure; call SDL_GetError() for more information.
*
* \since This function is available since SDL 2.24.0.
*
* \sa SDL_GetDisplayBounds
* \sa SDL_GetNumVideoDisplays
*/
extern DECLSPEC int SDLCALL SDL_GetRectDisplayIndex(const SDL_Rect * rect);
/**
* Get the index of the display associated with a window.
*
* \param window the window to query.
* \returns the index of the display containing the center of the window on
* success or a negative error code on failure; call SDL_GetError()
* for more information.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetDisplayBounds
* \sa SDL_GetNumVideoDisplays
*/
extern DECLSPEC int SDLCALL SDL_GetWindowDisplayIndex(SDL_Window * window);
/**
* Set the display mode to use when a window is visible at fullscreen.
*
* This only affects the display mode used when the window is fullscreen. To
* change the window size when the window is not fullscreen, use
* SDL_SetWindowSize().
*
* \param window the window to affect.
* \param mode the SDL_DisplayMode structure representing the mode to use, or
* NULL to use the window's dimensions and the desktop's format
* and refresh rate.
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetWindowDisplayMode
* \sa SDL_SetWindowFullscreen
*/
extern DECLSPEC int SDLCALL SDL_SetWindowDisplayMode(SDL_Window * window,
const SDL_DisplayMode * mode);
/**
* Query the display mode to use when a window is visible at fullscreen.
*
* \param window the window to query.
* \param mode an SDL_DisplayMode structure filled in with the fullscreen
* display mode.
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_SetWindowDisplayMode
* \sa SDL_SetWindowFullscreen
*/
extern DECLSPEC int SDLCALL SDL_GetWindowDisplayMode(SDL_Window * window,
SDL_DisplayMode * mode);
/**
* Get the raw ICC profile data for the screen the window is currently on.
*
* Data returned should be freed with SDL_free.
*
* \param window the window to query.
* \param size the size of the ICC profile.
* \returns the raw ICC profile data on success or NULL on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.18.
*/
extern DECLSPEC void* SDLCALL SDL_GetWindowICCProfile(SDL_Window * window, size_t* size);
/**
* Get the pixel format associated with the window.
*
* \param window the window to query.
* \returns the pixel format of the window on success or
* SDL_PIXELFORMAT_UNKNOWN on failure; call SDL_GetError() for more
* information.
*
* \since This function is available since SDL 2.0.0.
*/
extern DECLSPEC Uint32 SDLCALL SDL_GetWindowPixelFormat(SDL_Window * window);
/**
* Create a window with the specified position, dimensions, and flags.
*
* `flags` may be any of the following OR'd together:
*
* - `SDL_WINDOW_FULLSCREEN`: fullscreen window
* - `SDL_WINDOW_FULLSCREEN_DESKTOP`: fullscreen window at desktop resolution
* - `SDL_WINDOW_OPENGL`: window usable with an OpenGL context
* - `SDL_WINDOW_VULKAN`: window usable with a Vulkan instance
* - `SDL_WINDOW_METAL`: window usable with a Metal instance
* - `SDL_WINDOW_HIDDEN`: window is not visible
* - `SDL_WINDOW_BORDERLESS`: no window decoration
* - `SDL_WINDOW_RESIZABLE`: window can be resized
* - `SDL_WINDOW_MINIMIZED`: window is minimized
* - `SDL_WINDOW_MAXIMIZED`: window is maximized
* - `SDL_WINDOW_INPUT_GRABBED`: window has grabbed input focus
* - `SDL_WINDOW_ALLOW_HIGHDPI`: window should be created in high-DPI mode if
* supported (>= SDL 2.0.1)
*
* `SDL_WINDOW_SHOWN` is ignored by SDL_CreateWindow(). The SDL_Window is
* implicitly shown if SDL_WINDOW_HIDDEN is not set. `SDL_WINDOW_SHOWN` may be
* queried later using SDL_GetWindowFlags().
*
* On Apple's macOS, you **must** set the NSHighResolutionCapable Info.plist
* property to YES, otherwise you will not receive a High-DPI OpenGL canvas.
*
* If the window is created with the `SDL_WINDOW_ALLOW_HIGHDPI` flag, its size
* in pixels may differ from its size in screen coordinates on platforms with
* high-DPI support (e.g. iOS and macOS). Use SDL_GetWindowSize() to query the
* client area's size in screen coordinates, and SDL_GL_GetDrawableSize() or
* SDL_GetRendererOutputSize() to query the drawable size in pixels. Note that
* when this flag is set, the drawable size can vary after the window is
* created and should be queried after major window events such as when the
* window is resized or moved between displays.
*
* If the window is set fullscreen, the width and height parameters `w` and
* `h` will not be used. However, invalid size parameters (e.g. too large) may
* still fail. Window size is actually limited to 16384 x 16384 for all
* platforms at window creation.
*
* If the window is created with any of the SDL_WINDOW_OPENGL or
* SDL_WINDOW_VULKAN flags, then the corresponding LoadLibrary function
* (SDL_GL_LoadLibrary or SDL_Vulkan_LoadLibrary) is called and the
* corresponding UnloadLibrary function is called by SDL_DestroyWindow().
*
* If SDL_WINDOW_VULKAN is specified and there isn't a working Vulkan driver,
* SDL_CreateWindow() will fail because SDL_Vulkan_LoadLibrary() will fail.
*
* If SDL_WINDOW_METAL is specified on an OS that does not support Metal,
* SDL_CreateWindow() will fail.
*
* On non-Apple devices, SDL requires you to either not link to the Vulkan
* loader or link to a dynamic library version. This limitation may be removed
* in a future version of SDL.
*
* \param title the title of the window, in UTF-8 encoding.
* \param x the x position of the window, `SDL_WINDOWPOS_CENTERED`, or
* `SDL_WINDOWPOS_UNDEFINED`.
* \param y the y position of the window, `SDL_WINDOWPOS_CENTERED`, or
* `SDL_WINDOWPOS_UNDEFINED`.
* \param w the width of the window, in screen coordinates.
* \param h the height of the window, in screen coordinates.
* \param flags 0, or one or more SDL_WindowFlags OR'd together.
* \returns the `SDL_Window` that was created or NULL on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_CreateWindowFrom
* \sa SDL_DestroyWindow
*/
extern DECLSPEC SDL_Window * SDLCALL SDL_CreateWindow(const char *title,
int x, int y, int w,
int h, Uint32 flags);
/**
* Create an SDL window from an existing native window.
*
* In some cases (e.g. OpenGL) and on some platforms (e.g. Microsoft Windows)
* the hint `SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT` needs to be configured
* before using SDL_CreateWindowFrom().
*
* \param data a pointer to driver-dependent window creation data, typically
* your native window cast to a void*.
* \returns the window that was created or NULL on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_CreateWindow
* \sa SDL_DestroyWindow
*/
extern DECLSPEC SDL_Window * SDLCALL SDL_CreateWindowFrom(const void *data);
/**
* Get the numeric ID of a window.
*
* The numeric ID is what SDL_WindowEvent references, and is necessary to map
* these events to specific SDL_Window objects.
*
* \param window the window to query.
* \returns the ID of the window on success or 0 on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetWindowFromID
*/
extern DECLSPEC Uint32 SDLCALL SDL_GetWindowID(SDL_Window * window);
/**
* Get a window from a stored ID.
*
* The numeric ID is what SDL_WindowEvent references, and is necessary to map
* these events to specific SDL_Window objects.
*
* \param id the ID of the window.
* \returns the window associated with `id` or NULL if it doesn't exist; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetWindowID
*/
extern DECLSPEC SDL_Window * SDLCALL SDL_GetWindowFromID(Uint32 id);
/**
* Get the window flags.
*
* \param window the window to query.
* \returns a mask of the SDL_WindowFlags associated with `window`.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_CreateWindow
* \sa SDL_HideWindow
* \sa SDL_MaximizeWindow
* \sa SDL_MinimizeWindow
* \sa SDL_SetWindowFullscreen
* \sa SDL_SetWindowGrab
* \sa SDL_ShowWindow
*/
extern DECLSPEC Uint32 SDLCALL SDL_GetWindowFlags(SDL_Window * window);
/**
* Set the title of a window.
*
* This string is expected to be in UTF-8 encoding.
*
* \param window the window to change.
* \param title the desired window title in UTF-8 format.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetWindowTitle
*/
extern DECLSPEC void SDLCALL SDL_SetWindowTitle(SDL_Window * window,
const char *title);
/**
* Get the title of a window.
*
* \param window the window to query.
* \returns the title of the window in UTF-8 format or "" if there is no
* title.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_SetWindowTitle
*/
extern DECLSPEC const char *SDLCALL SDL_GetWindowTitle(SDL_Window * window);
/**
* Set the icon for a window.
*
* \param window the window to change.
* \param icon an SDL_Surface structure containing the icon for the window.
*
* \since This function is available since SDL 2.0.0.
*/
extern DECLSPEC void SDLCALL SDL_SetWindowIcon(SDL_Window * window,
SDL_Surface * icon);
/**
* Associate an arbitrary named pointer with a window.
*
* `name` is case-sensitive.
*
* \param window the window to associate with the pointer.
* \param name the name of the pointer.
* \param userdata the associated pointer.
* \returns the previous value associated with `name`.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetWindowData
*/
extern DECLSPEC void* SDLCALL SDL_SetWindowData(SDL_Window * window,
const char *name,
void *userdata);
/**
* Retrieve the data pointer associated with a window.
*
* \param window the window to query.
* \param name the name of the pointer.
* \returns the value associated with `name`.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_SetWindowData
*/
extern DECLSPEC void *SDLCALL SDL_GetWindowData(SDL_Window * window,
const char *name);
/**
* Set the position of a window.
*
* The window coordinate origin is the upper left of the display.
*
* \param window the window to reposition.
* \param x the x coordinate of the window in screen coordinates, or
* `SDL_WINDOWPOS_CENTERED` or `SDL_WINDOWPOS_UNDEFINED`.
* \param y the y coordinate of the window in screen coordinates, or
* `SDL_WINDOWPOS_CENTERED` or `SDL_WINDOWPOS_UNDEFINED`.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetWindowPosition
*/
extern DECLSPEC void SDLCALL SDL_SetWindowPosition(SDL_Window * window,
int x, int y);
/**
* Get the position of a window.
*
* If you do not need the value for one of the positions a NULL may be passed
* in the `x` or `y` parameter.
*
* \param window the window to query.
* \param x a pointer filled in with the x position of the window, in screen
* coordinates, may be NULL.
* \param y a pointer filled in with the y position of the window, in screen
* coordinates, may be NULL.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_SetWindowPosition
*/
extern DECLSPEC void SDLCALL SDL_GetWindowPosition(SDL_Window * window,
int *x, int *y);
/**
* Set the size of a window's client area.
*
* The window size in screen coordinates may differ from the size in pixels,
* if the window was created with `SDL_WINDOW_ALLOW_HIGHDPI` on a platform
* with high-dpi support (e.g. iOS or macOS). Use SDL_GL_GetDrawableSize() or
* SDL_GetRendererOutputSize() to get the real client area size in pixels.