SDL  2.0
SDL_video.c
Go to the documentation of this file.
1 /*
2  Simple DirectMedia Layer
3  Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
4 
5  This software is provided 'as-is', without any express or implied
6  warranty. In no event will the authors be held liable for any damages
7  arising from the use of this software.
8 
9  Permission is granted to anyone to use this software for any purpose,
10  including commercial applications, and to alter it and redistribute it
11  freely, subject to the following restrictions:
12 
13  1. The origin of this software must not be misrepresented; you must not
14  claim that you wrote the original software. If you use this software
15  in a product, an acknowledgment in the product documentation would be
16  appreciated but is not required.
17  2. Altered source versions must be plainly marked as such, and must not be
18  misrepresented as being the original software.
19  3. This notice may not be removed or altered from any source distribution.
20 */
21 #include "../SDL_internal.h"
22 
23 /* The high-level video driver subsystem */
24 
25 #include "SDL.h"
26 #include "SDL_video.h"
27 #include "SDL_sysvideo.h"
28 #include "SDL_blit.h"
29 #include "SDL_pixels_c.h"
30 #include "SDL_rect_c.h"
31 #include "../events/SDL_events_c.h"
32 #include "../timer/SDL_timer_c.h"
33 
34 #include "SDL_syswm.h"
35 
36 #if SDL_VIDEO_OPENGL
37 #include "SDL_opengl.h"
38 #endif /* SDL_VIDEO_OPENGL */
39 
40 #if SDL_VIDEO_OPENGL_ES
41 #include "SDL_opengles.h"
42 #endif /* SDL_VIDEO_OPENGL_ES */
43 
44 /* GL and GLES2 headers conflict on Linux 32 bits */
45 #if SDL_VIDEO_OPENGL_ES2 && !SDL_VIDEO_OPENGL
46 #include "SDL_opengles2.h"
47 #endif /* SDL_VIDEO_OPENGL_ES2 && !SDL_VIDEO_OPENGL */
48 
49 #if !SDL_VIDEO_OPENGL
50 #ifndef GL_CONTEXT_RELEASE_BEHAVIOR_KHR
51 #define GL_CONTEXT_RELEASE_BEHAVIOR_KHR 0x82FB
52 #endif
53 #endif
54 
55 #ifdef __EMSCRIPTEN__
56 #include <emscripten.h>
57 #endif
58 
59 /* Available video drivers */
61 #if SDL_VIDEO_DRIVER_COCOA
63 #endif
64 #if SDL_VIDEO_DRIVER_X11
66 #endif
67 #if SDL_VIDEO_DRIVER_MIR
69 #endif
70 #if SDL_VIDEO_DRIVER_WAYLAND
72 #endif
73 #if SDL_VIDEO_DRIVER_VIVANTE
75 #endif
76 #if SDL_VIDEO_DRIVER_DIRECTFB
78 #endif
79 #if SDL_VIDEO_DRIVER_WINDOWS
81 #endif
82 #if SDL_VIDEO_DRIVER_WINRT
84 #endif
85 #if SDL_VIDEO_DRIVER_HAIKU
87 #endif
88 #if SDL_VIDEO_DRIVER_PANDORA
90 #endif
91 #if SDL_VIDEO_DRIVER_UIKIT
93 #endif
94 #if SDL_VIDEO_DRIVER_ANDROID
96 #endif
97 #if SDL_VIDEO_DRIVER_PSP
99 #endif
100 #if SDL_VIDEO_DRIVER_KMSDRM
102 #endif
103 #if SDL_VIDEO_DRIVER_RPI
104  &RPI_bootstrap,
105 #endif
106 #if SDL_VIDEO_DRIVER_NACL
108 #endif
109 #if SDL_VIDEO_DRIVER_EMSCRIPTEN
111 #endif
112 #if SDL_VIDEO_DRIVER_QNX
113  &QNX_bootstrap,
114 #endif
115 #if SDL_VIDEO_DRIVER_DUMMY
117 #endif
118  NULL
119 };
120 
122 
123 #define CHECK_WINDOW_MAGIC(window, retval) \
124  if (!_this) { \
125  SDL_UninitializedVideo(); \
126  return retval; \
127  } \
128  SDL_assert(window && window->magic == &_this->window_magic); \
129  if (!window || window->magic != &_this->window_magic) { \
130  SDL_SetError("Invalid window"); \
131  return retval; \
132  }
133 
134 #define CHECK_DISPLAY_INDEX(displayIndex, retval) \
135  if (!_this) { \
136  SDL_UninitializedVideo(); \
137  return retval; \
138  } \
139  SDL_assert(_this->displays != NULL); \
140  SDL_assert(displayIndex >= 0 && displayIndex < _this->num_displays); \
141  if (displayIndex < 0 || displayIndex >= _this->num_displays) { \
142  SDL_SetError("displayIndex must be in the range 0 - %d", \
143  _this->num_displays - 1); \
144  return retval; \
145  }
146 
147 #define FULLSCREEN_MASK (SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_FULLSCREEN)
148 
149 #ifdef __MACOSX__
150 /* Support for Mac OS X fullscreen spaces */
151 extern SDL_bool Cocoa_IsWindowInFullscreenSpace(SDL_Window * window);
152 extern SDL_bool Cocoa_SetWindowFullscreenSpace(SDL_Window * window, SDL_bool state);
153 #endif
154 
155 
156 /* Support for framebuffer emulation using an accelerated renderer */
157 
158 #define SDL_WINDOWTEXTUREDATA "_SDL_WindowTextureData"
159 
160 typedef struct {
163  void *pixels;
164  int pitch;
167 
168 static SDL_bool
170 {
171  const char *hint;
172 
173  /* If there's no native framebuffer support then there's no option */
174  if (!_this->CreateWindowFramebuffer) {
175  return SDL_TRUE;
176  }
177 
178  /* If this is the dummy driver there is no texture support */
179  if (_this->is_dummy) {
180  return SDL_FALSE;
181  }
182 
183  /* If the user has specified a software renderer we can't use a
184  texture framebuffer, or renderer creation will go recursive.
185  */
187  if (hint && SDL_strcasecmp(hint, "software") == 0) {
188  return SDL_FALSE;
189  }
190 
191  /* See if the user or application wants a specific behavior */
193  if (hint) {
194  if (*hint == '0' || SDL_strcasecmp(hint, "false") == 0) {
195  return SDL_FALSE;
196  } else {
197  return SDL_TRUE;
198  }
199  }
200 
201  /* Each platform has different performance characteristics */
202 #if defined(__WIN32__)
203  /* GDI BitBlt() is way faster than Direct3D dynamic textures right now.
204  */
205  return SDL_FALSE;
206 
207 #elif defined(__MACOSX__)
208  /* Mac OS X uses OpenGL as the native fast path (for cocoa and X11) */
209  return SDL_TRUE;
210 
211 #elif defined(__LINUX__)
212  /* Properly configured OpenGL drivers are faster than MIT-SHM */
213 #if SDL_VIDEO_OPENGL
214  /* Ugh, find a way to cache this value! */
215  {
218  SDL_bool hasAcceleratedOpenGL = SDL_FALSE;
219 
220  window = SDL_CreateWindow("OpenGL test", -32, -32, 32, 32, SDL_WINDOW_OPENGL|SDL_WINDOW_HIDDEN);
221  if (window) {
222  context = SDL_GL_CreateContext(window);
223  if (context) {
224  const GLubyte *(APIENTRY * glGetStringFunc) (GLenum);
225  const char *vendor = NULL;
226 
227  glGetStringFunc = SDL_GL_GetProcAddress("glGetString");
228  if (glGetStringFunc) {
229  vendor = (const char *) glGetStringFunc(GL_VENDOR);
230  }
231  /* Add more vendors here at will... */
232  if (vendor &&
233  (SDL_strstr(vendor, "ATI Technologies") ||
234  SDL_strstr(vendor, "NVIDIA"))) {
235  hasAcceleratedOpenGL = SDL_TRUE;
236  }
237  SDL_GL_DeleteContext(context);
238  }
239  SDL_DestroyWindow(window);
240  }
241  return hasAcceleratedOpenGL;
242  }
243 #elif SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
244  /* Let's be optimistic about this! */
245  return SDL_TRUE;
246 #else
247  return SDL_FALSE;
248 #endif
249 
250 #else
251  /* Play it safe, assume that if there is a framebuffer driver that it's
252  optimized for the current platform.
253  */
254  return SDL_FALSE;
255 #endif
256 }
257 
258 static int
260 {
262 
264  if (!data) {
266  int i;
268 
269  /* Check to see if there's a specific driver requested */
270  if (hint && *hint != '0' && *hint != '1' &&
271  SDL_strcasecmp(hint, "true") != 0 &&
272  SDL_strcasecmp(hint, "false") != 0 &&
273  SDL_strcasecmp(hint, "software") != 0) {
274  for (i = 0; i < SDL_GetNumRenderDrivers(); ++i) {
275  SDL_RendererInfo info;
276  SDL_GetRenderDriverInfo(i, &info);
277  if (SDL_strcasecmp(info.name, hint) == 0) {
278  renderer = SDL_CreateRenderer(window, i, 0);
279  break;
280  }
281  }
282  }
283 
284  if (!renderer) {
285  for (i = 0; i < SDL_GetNumRenderDrivers(); ++i) {
286  SDL_RendererInfo info;
287  SDL_GetRenderDriverInfo(i, &info);
288  if (SDL_strcmp(info.name, "software") != 0) {
289  renderer = SDL_CreateRenderer(window, i, 0);
290  if (renderer) {
291  break;
292  }
293  }
294  }
295  }
296  if (!renderer) {
297  return SDL_SetError("No hardware accelerated renderers available");
298  }
299 
300  /* Create the data after we successfully create the renderer (bug #1116) */
301  data = (SDL_WindowTextureData *)SDL_calloc(1, sizeof(*data));
302  if (!data) {
303  SDL_DestroyRenderer(renderer);
304  return SDL_OutOfMemory();
305  }
307 
308  data->renderer = renderer;
309  }
310 
311  /* Free any old texture and pixel data */
312  if (data->texture) {
314  data->texture = NULL;
315  }
316  SDL_free(data->pixels);
317  data->pixels = NULL;
318 
319  {
320  SDL_RendererInfo info;
321  Uint32 i;
322 
323  if (SDL_GetRendererInfo(data->renderer, &info) < 0) {
324  return -1;
325  }
326 
327  /* Find the first format without an alpha channel */
328  *format = info.texture_formats[0];
329 
330  for (i = 0; i < info.num_texture_formats; ++i) {
333  *format = info.texture_formats[i];
334  break;
335  }
336  }
337  }
338 
339  data->texture = SDL_CreateTexture(data->renderer, *format,
341  window->w, window->h);
342  if (!data->texture) {
343  return -1;
344  }
345 
346  /* Create framebuffer data */
347  data->bytes_per_pixel = SDL_BYTESPERPIXEL(*format);
348  data->pitch = (((window->w * data->bytes_per_pixel) + 3) & ~3);
349 
350  {
351  /* Make static analysis happy about potential malloc(0) calls. */
352  const size_t allocsize = window->h * data->pitch;
353  data->pixels = SDL_malloc((allocsize > 0) ? allocsize : 1);
354  if (!data->pixels) {
355  return SDL_OutOfMemory();
356  }
357  }
358 
359  *pixels = data->pixels;
360  *pitch = data->pitch;
361 
362  /* Make sure we're not double-scaling the viewport */
364 
365  return 0;
366 }
367 
368 static int
370 {
372  SDL_Rect rect;
373  void *src;
374 
376  if (!data || !data->texture) {
377  return SDL_SetError("No window texture data");
378  }
379 
380  /* Update a single rect that contains subrects for best DMA performance */
381  if (SDL_GetSpanEnclosingRect(window->w, window->h, numrects, rects, &rect)) {
382  src = (void *)((Uint8 *)data->pixels +
383  rect.y * data->pitch +
384  rect.x * data->bytes_per_pixel);
385  if (SDL_UpdateTexture(data->texture, &rect, src, data->pitch) < 0) {
386  return -1;
387  }
388 
389  if (SDL_RenderCopy(data->renderer, data->texture, NULL, NULL) < 0) {
390  return -1;
391  }
392 
394  }
395  return 0;
396 }
397 
398 static void
400 {
402 
404  if (!data) {
405  return;
406  }
407  if (data->texture) {
409  }
410  if (data->renderer) {
412  }
413  SDL_free(data->pixels);
414  SDL_free(data);
415 }
416 
417 
418 static int
419 cmpmodes(const void *A, const void *B)
420 {
421  const SDL_DisplayMode *a = (const SDL_DisplayMode *) A;
422  const SDL_DisplayMode *b = (const SDL_DisplayMode *) B;
423  if (a == b) {
424  return 0;
425  } else if (a->w != b->w) {
426  return b->w - a->w;
427  } else if (a->h != b->h) {
428  return b->h - a->h;
429  } else if (SDL_BITSPERPIXEL(a->format) != SDL_BITSPERPIXEL(b->format)) {
431  } else if (SDL_PIXELLAYOUT(a->format) != SDL_PIXELLAYOUT(b->format)) {
432  return SDL_PIXELLAYOUT(b->format) - SDL_PIXELLAYOUT(a->format);
433  } else if (a->refresh_rate != b->refresh_rate) {
434  return b->refresh_rate - a->refresh_rate;
435  }
436  return 0;
437 }
438 
439 static int
441 {
442  return SDL_SetError("Video subsystem has not been initialized");
443 }
444 
445 int
447 {
448  return SDL_arraysize(bootstrap) - 1;
449 }
450 
451 const char *
453 {
454  if (index >= 0 && index < SDL_GetNumVideoDrivers()) {
455  return bootstrap[index]->name;
456  }
457  return NULL;
458 }
459 
460 /*
461  * Initialize the video and event subsystems -- determine native pixel format
462  */
463 int
464 SDL_VideoInit(const char *driver_name)
465 {
466  SDL_VideoDevice *video;
467  int index;
468  int i;
469 
470  /* Check to make sure we don't overwrite '_this' */
471  if (_this != NULL) {
472  SDL_VideoQuit();
473  }
474 
475 #if !SDL_TIMERS_DISABLED
476  SDL_TicksInit();
477 #endif
478 
479  /* Start the event loop */
481  SDL_KeyboardInit() < 0 ||
482  SDL_MouseInit() < 0 ||
483  SDL_TouchInit() < 0) {
484  return -1;
485  }
486 
487  /* Select the proper video driver */
488  index = 0;
489  video = NULL;
490  if (driver_name == NULL) {
491  driver_name = SDL_getenv("SDL_VIDEODRIVER");
492  }
493  if (driver_name != NULL) {
494  for (i = 0; bootstrap[i]; ++i) {
495  if (SDL_strncasecmp(bootstrap[i]->name, driver_name, SDL_strlen(driver_name)) == 0) {
496  if (bootstrap[i]->available()) {
497  video = bootstrap[i]->create(index);
498  break;
499  }
500  }
501  }
502  } else {
503  for (i = 0; bootstrap[i]; ++i) {
504  if (bootstrap[i]->available()) {
505  video = bootstrap[i]->create(index);
506  if (video != NULL) {
507  break;
508  }
509  }
510  }
511  }
512  if (video == NULL) {
513  if (driver_name) {
514  return SDL_SetError("%s not available", driver_name);
515  }
516  return SDL_SetError("No available video device");
517  }
518  _this = video;
519  _this->name = bootstrap[i]->name;
520  _this->next_object_id = 1;
521 
522 
523  /* Set some very sane GL defaults */
524  _this->gl_config.driver_loaded = 0;
525  _this->gl_config.dll_handle = NULL;
527 
528  _this->current_glwin_tls = SDL_TLSCreate();
529  _this->current_glctx_tls = SDL_TLSCreate();
530 
531  /* Initialize the video subsystem */
532  if (_this->VideoInit(_this) < 0) {
533  SDL_VideoQuit();
534  return -1;
535  }
536 
537  /* Make sure some displays were added */
538  if (_this->num_displays == 0) {
539  SDL_VideoQuit();
540  return SDL_SetError("The video driver did not add any displays");
541  }
542 
543  /* Add the renderer framebuffer emulation if desired */
548  }
549 
550  /* Disable the screen saver by default. This is a change from <= 2.0.1,
551  but most things using SDL are games or media players; you wouldn't
552  want a screensaver to trigger if you're playing exclusively with a
553  joystick, or passively watching a movie. Things that use SDL but
554  function more like a normal desktop app should explicitly reenable the
555  screensaver. */
558  }
559 
560  /* If we don't use a screen keyboard, turn on text input by default,
561  otherwise programs that expect to get text events without enabling
562  UNICODE input won't get any events.
563 
564  Actually, come to think of it, you needed to call SDL_EnableUNICODE(1)
565  in SDL 1.2 before you got text input events. Hmm...
566  */
569  }
570 
571  /* We're ready to go! */
572  return 0;
573 }
574 
575 const char *
577 {
578  if (!_this) {
580  return NULL;
581  }
582  return _this->name;
583 }
584 
587 {
588  return _this;
589 }
590 
591 int
593 {
594  SDL_VideoDisplay display;
595 
596  SDL_zero(display);
597  if (desktop_mode) {
598  display.desktop_mode = *desktop_mode;
599  }
600  display.current_mode = display.desktop_mode;
601 
602  return SDL_AddVideoDisplay(&display);
603 }
604 
605 int
607 {
608  SDL_VideoDisplay *displays;
609  int index = -1;
610 
611  displays =
612  SDL_realloc(_this->displays,
613  (_this->num_displays + 1) * sizeof(*displays));
614  if (displays) {
615  index = _this->num_displays++;
616  displays[index] = *display;
617  displays[index].device = _this;
618  _this->displays = displays;
619 
620  if (display->name) {
621  displays[index].name = SDL_strdup(display->name);
622  } else {
623  char name[32];
624 
625  SDL_itoa(index, name, 10);
626  displays[index].name = SDL_strdup(name);
627  }
628  } else {
629  SDL_OutOfMemory();
630  }
631  return index;
632 }
633 
634 int
636 {
637  if (!_this) {
639  return 0;
640  }
641  return _this->num_displays;
642 }
643 
644 int
646 {
647  int displayIndex;
648 
649  for (displayIndex = 0; displayIndex < _this->num_displays; ++displayIndex) {
650  if (display == &_this->displays[displayIndex]) {
651  return displayIndex;
652  }
653  }
654 
655  /* Couldn't find the display, just use index 0 */
656  return 0;
657 }
658 
659 void *
660 SDL_GetDisplayDriverData(int displayIndex)
661 {
662  CHECK_DISPLAY_INDEX(displayIndex, NULL);
663 
664  return _this->displays[displayIndex].driverdata;
665 }
666 
667 const char *
668 SDL_GetDisplayName(int displayIndex)
669 {
670  CHECK_DISPLAY_INDEX(displayIndex, NULL);
671 
672  return _this->displays[displayIndex].name;
673 }
674 
675 int
676 SDL_GetDisplayBounds(int displayIndex, SDL_Rect * rect)
677 {
678  CHECK_DISPLAY_INDEX(displayIndex, -1);
679 
680  if (rect) {
681  SDL_VideoDisplay *display = &_this->displays[displayIndex];
682 
683  if (_this->GetDisplayBounds) {
684  if (_this->GetDisplayBounds(_this, display, rect) == 0) {
685  return 0;
686  }
687  }
688 
689  /* Assume that the displays are left to right */
690  if (displayIndex == 0) {
691  rect->x = 0;
692  rect->y = 0;
693  } else {
694  SDL_GetDisplayBounds(displayIndex-1, rect);
695  rect->x += rect->w;
696  }
697  rect->w = display->current_mode.w;
698  rect->h = display->current_mode.h;
699  }
700  return 0; /* !!! FIXME: should this be an error if (rect==NULL) ? */
701 }
702 
703 int SDL_GetDisplayUsableBounds(int displayIndex, SDL_Rect * rect)
704 {
705  CHECK_DISPLAY_INDEX(displayIndex, -1);
706 
707  if (rect) {
708  SDL_VideoDisplay *display = &_this->displays[displayIndex];
709 
710  if (_this->GetDisplayUsableBounds) {
711  if (_this->GetDisplayUsableBounds(_this, display, rect) == 0) {
712  return 0;
713  }
714  }
715 
716  /* Oh well, just give the entire display bounds. */
717  return SDL_GetDisplayBounds(displayIndex, rect);
718  }
719  return 0; /* !!! FIXME: should this be an error if (rect==NULL) ? */
720 }
721 
722 int
723 SDL_GetDisplayDPI(int displayIndex, float * ddpi, float * hdpi, float * vdpi)
724 {
725  SDL_VideoDisplay *display;
726 
727  CHECK_DISPLAY_INDEX(displayIndex, -1);
728 
729  display = &_this->displays[displayIndex];
730 
731  if (_this->GetDisplayDPI) {
732  if (_this->GetDisplayDPI(_this, display, ddpi, hdpi, vdpi) == 0) {
733  return 0;
734  }
735  } else {
736  return SDL_Unsupported();
737  }
738 
739  return -1;
740 }
741 
743 SDL_GetDisplayOrientation(int displayIndex)
744 {
745  SDL_VideoDisplay *display;
746 
748 
749  display = &_this->displays[displayIndex];
750  return display->orientation;
751 }
752 
753 SDL_bool
755 {
756  SDL_DisplayMode *modes;
757  int i, nmodes;
758 
759  /* Make sure we don't already have the mode in the list */
760  modes = display->display_modes;
761  nmodes = display->num_display_modes;
762  for (i = 0; i < nmodes; ++i) {
763  if (cmpmodes(mode, &modes[i]) == 0) {
764  return SDL_FALSE;
765  }
766  }
767 
768  /* Go ahead and add the new mode */
769  if (nmodes == display->max_display_modes) {
770  modes =
771  SDL_realloc(modes,
772  (display->max_display_modes + 32) * sizeof(*modes));
773  if (!modes) {
774  return SDL_FALSE;
775  }
776  display->display_modes = modes;
777  display->max_display_modes += 32;
778  }
779  modes[nmodes] = *mode;
780  display->num_display_modes++;
781 
782  /* Re-sort video modes */
783  SDL_qsort(display->display_modes, display->num_display_modes,
784  sizeof(SDL_DisplayMode), cmpmodes);
785 
786  return SDL_TRUE;
787 }
788 
789 static int
791 {
792  if (!display->num_display_modes && _this->GetDisplayModes) {
793  _this->GetDisplayModes(_this, display);
794  SDL_qsort(display->display_modes, display->num_display_modes,
795  sizeof(SDL_DisplayMode), cmpmodes);
796  }
797  return display->num_display_modes;
798 }
799 
800 int
801 SDL_GetNumDisplayModes(int displayIndex)
802 {
803  CHECK_DISPLAY_INDEX(displayIndex, -1);
804 
805  return SDL_GetNumDisplayModesForDisplay(&_this->displays[displayIndex]);
806 }
807 
808 int
809 SDL_GetDisplayMode(int displayIndex, int index, SDL_DisplayMode * mode)
810 {
811  SDL_VideoDisplay *display;
812 
813  CHECK_DISPLAY_INDEX(displayIndex, -1);
814 
815  display = &_this->displays[displayIndex];
817  return SDL_SetError("index must be in the range of 0 - %d",
818  SDL_GetNumDisplayModesForDisplay(display) - 1);
819  }
820  if (mode) {
821  *mode = display->display_modes[index];
822  }
823  return 0;
824 }
825 
826 int
828 {
829  SDL_VideoDisplay *display;
830 
831  CHECK_DISPLAY_INDEX(displayIndex, -1);
832 
833  display = &_this->displays[displayIndex];
834  if (mode) {
835  *mode = display->desktop_mode;
836  }
837  return 0;
838 }
839 
840 int
842 {
843  SDL_VideoDisplay *display;
844 
845  CHECK_DISPLAY_INDEX(displayIndex, -1);
846 
847  display = &_this->displays[displayIndex];
848  if (mode) {
849  *mode = display->current_mode;
850  }
851  return 0;
852 }
853 
854 static SDL_DisplayMode *
856  const SDL_DisplayMode * mode,
857  SDL_DisplayMode * closest)
858 {
859  Uint32 target_format;
860  int target_refresh_rate;
861  int i;
862  SDL_DisplayMode *current, *match;
863 
864  if (!mode || !closest) {
865  SDL_SetError("Missing desired mode or closest mode parameter");
866  return NULL;
867  }
868 
869  /* Default to the desktop format */
870  if (mode->format) {
871  target_format = mode->format;
872  } else {
873  target_format = display->desktop_mode.format;
874  }
875 
876  /* Default to the desktop refresh rate */
877  if (mode->refresh_rate) {
878  target_refresh_rate = mode->refresh_rate;
879  } else {
880  target_refresh_rate = display->desktop_mode.refresh_rate;
881  }
882 
883  match = NULL;
884  for (i = 0; i < SDL_GetNumDisplayModesForDisplay(display); ++i) {
885  current = &display->display_modes[i];
886 
887  if (current->w && (current->w < mode->w)) {
888  /* Out of sorted modes large enough here */
889  break;
890  }
891  if (current->h && (current->h < mode->h)) {
892  if (current->w && (current->w == mode->w)) {
893  /* Out of sorted modes large enough here */
894  break;
895  }
896  /* Wider, but not tall enough, due to a different
897  aspect ratio. This mode must be skipped, but closer
898  modes may still follow. */
899  continue;
900  }
901  if (!match || current->w < match->w || current->h < match->h) {
902  match = current;
903  continue;
904  }
905  if (current->format != match->format) {
906  /* Sorted highest depth to lowest */
907  if (current->format == target_format ||
908  (SDL_BITSPERPIXEL(current->format) >=
909  SDL_BITSPERPIXEL(target_format)
910  && SDL_PIXELTYPE(current->format) ==
911  SDL_PIXELTYPE(target_format))) {
912  match = current;
913  }
914  continue;
915  }
916  if (current->refresh_rate != match->refresh_rate) {
917  /* Sorted highest refresh to lowest */
918  if (current->refresh_rate >= target_refresh_rate) {
919  match = current;
920  }
921  }
922  }
923  if (match) {
924  if (match->format) {
925  closest->format = match->format;
926  } else {
927  closest->format = mode->format;
928  }
929  if (match->w && match->h) {
930  closest->w = match->w;
931  closest->h = match->h;
932  } else {
933  closest->w = mode->w;
934  closest->h = mode->h;
935  }
936  if (match->refresh_rate) {
937  closest->refresh_rate = match->refresh_rate;
938  } else {
939  closest->refresh_rate = mode->refresh_rate;
940  }
941  closest->driverdata = match->driverdata;
942 
943  /*
944  * Pick some reasonable defaults if the app and driver don't
945  * care
946  */
947  if (!closest->format) {
948  closest->format = SDL_PIXELFORMAT_RGB888;
949  }
950  if (!closest->w) {
951  closest->w = 640;
952  }
953  if (!closest->h) {
954  closest->h = 480;
955  }
956  return closest;
957  }
958  return NULL;
959 }
960 
962 SDL_GetClosestDisplayMode(int displayIndex,
963  const SDL_DisplayMode * mode,
964  SDL_DisplayMode * closest)
965 {
966  SDL_VideoDisplay *display;
967 
968  CHECK_DISPLAY_INDEX(displayIndex, NULL);
969 
970  display = &_this->displays[displayIndex];
971  return SDL_GetClosestDisplayModeForDisplay(display, mode, closest);
972 }
973 
974 static int
976 {
977  SDL_DisplayMode display_mode;
978  SDL_DisplayMode current_mode;
979 
980  if (mode) {
981  display_mode = *mode;
982 
983  /* Default to the current mode */
984  if (!display_mode.format) {
985  display_mode.format = display->current_mode.format;
986  }
987  if (!display_mode.w) {
988  display_mode.w = display->current_mode.w;
989  }
990  if (!display_mode.h) {
991  display_mode.h = display->current_mode.h;
992  }
993  if (!display_mode.refresh_rate) {
994  display_mode.refresh_rate = display->current_mode.refresh_rate;
995  }
996 
997  /* Get a good video mode, the closest one possible */
998  if (!SDL_GetClosestDisplayModeForDisplay(display, &display_mode, &display_mode)) {
999  return SDL_SetError("No video mode large enough for %dx%d",
1000  display_mode.w, display_mode.h);
1001  }
1002  } else {
1003  display_mode = display->desktop_mode;
1004  }
1005 
1006  /* See if there's anything left to do */
1007  current_mode = display->current_mode;
1008  if (SDL_memcmp(&display_mode, &current_mode, sizeof(display_mode)) == 0) {
1009  return 0;
1010  }
1011 
1012  /* Actually change the display mode */
1013  if (!_this->SetDisplayMode) {
1014  return SDL_SetError("SDL video driver doesn't support changing display mode");
1015  }
1016  if (_this->SetDisplayMode(_this, display, &display_mode) < 0) {
1017  return -1;
1018  }
1019  display->current_mode = display_mode;
1020  return 0;
1021 }
1022 
1024 SDL_GetDisplay(int displayIndex)
1025 {
1026  CHECK_DISPLAY_INDEX(displayIndex, NULL);
1027 
1028  return &_this->displays[displayIndex];
1029 }
1030 
1031 int
1033 {
1034  int displayIndex;
1035  int i, dist;
1036  int closest = -1;
1037  int closest_dist = 0x7FFFFFFF;
1038  SDL_Point center;
1039  SDL_Point delta;
1040  SDL_Rect rect;
1041 
1042  CHECK_WINDOW_MAGIC(window, -1);
1043 
1044  if (SDL_WINDOWPOS_ISUNDEFINED(window->x) ||
1045  SDL_WINDOWPOS_ISCENTERED(window->x)) {
1046  displayIndex = (window->x & 0xFFFF);
1047  if (displayIndex >= _this->num_displays) {
1048  displayIndex = 0;
1049  }
1050  return displayIndex;
1051  }
1052  if (SDL_WINDOWPOS_ISUNDEFINED(window->y) ||
1053  SDL_WINDOWPOS_ISCENTERED(window->y)) {
1054  displayIndex = (window->y & 0xFFFF);
1055  if (displayIndex >= _this->num_displays) {
1056  displayIndex = 0;
1057  }
1058  return displayIndex;
1059  }
1060 
1061  /* Find the display containing the window */
1062  for (i = 0; i < _this->num_displays; ++i) {
1063  SDL_VideoDisplay *display = &_this->displays[i];
1064 
1065  if (display->fullscreen_window == window) {
1066  return i;
1067  }
1068  }
1069  center.x = window->x + window->w / 2;
1070  center.y = window->y + window->h / 2;
1071  for (i = 0; i < _this->num_displays; ++i) {
1072  SDL_GetDisplayBounds(i, &rect);
1073  if (SDL_EnclosePoints(&center, 1, &rect, NULL)) {
1074  return i;
1075  }
1076 
1077  delta.x = center.x - (rect.x + rect.w / 2);
1078  delta.y = center.y - (rect.y + rect.h / 2);
1079  dist = (delta.x*delta.x + delta.y*delta.y);
1080  if (dist < closest_dist) {
1081  closest = i;
1082  closest_dist = dist;
1083  }
1084  }
1085  if (closest < 0) {
1086  SDL_SetError("Couldn't find any displays");
1087  }
1088  return closest;
1089 }
1090 
1093 {
1094  int displayIndex = SDL_GetWindowDisplayIndex(window);
1095  if (displayIndex >= 0) {
1096  return &_this->displays[displayIndex];
1097  } else {
1098  return NULL;
1099  }
1100 }
1101 
1102 int
1104 {
1105  CHECK_WINDOW_MAGIC(window, -1);
1106 
1107  if (mode) {
1108  window->fullscreen_mode = *mode;
1109  } else {
1110  SDL_zero(window->fullscreen_mode);
1111  }
1112 
1114  SDL_DisplayMode fullscreen_mode;
1115  if (SDL_GetWindowDisplayMode(window, &fullscreen_mode) == 0) {
1116  SDL_SetDisplayModeForDisplay(SDL_GetDisplayForWindow(window), &fullscreen_mode);
1117  }
1118  }
1119  return 0;
1120 }
1121 
1122 int
1124 {
1125  SDL_DisplayMode fullscreen_mode;
1126  SDL_VideoDisplay *display;
1127 
1128  CHECK_WINDOW_MAGIC(window, -1);
1129 
1130  if (!mode) {
1131  return SDL_InvalidParamError("mode");
1132  }
1133 
1134  fullscreen_mode = window->fullscreen_mode;
1135  if (!fullscreen_mode.w) {
1136  fullscreen_mode.w = window->windowed.w;
1137  }
1138  if (!fullscreen_mode.h) {
1139  fullscreen_mode.h = window->windowed.h;
1140  }
1141 
1142  display = SDL_GetDisplayForWindow(window);
1143 
1144  /* if in desktop size mode, just return the size of the desktop */
1146  fullscreen_mode = display->desktop_mode;
1148  &fullscreen_mode,
1149  &fullscreen_mode)) {
1150  return SDL_SetError("Couldn't find display mode match");
1151  }
1152 
1153  if (mode) {
1154  *mode = fullscreen_mode;
1155  }
1156  return 0;
1157 }
1158 
1159 Uint32
1161 {
1162  SDL_VideoDisplay *display;
1163 
1165 
1166  display = SDL_GetDisplayForWindow(window);
1167  return display->current_mode.format;
1168 }
1169 
1170 static void
1172 {
1173  int x, y;
1174 
1175  if (window == SDL_GetMouseFocus()) {
1176  SDL_GetMouseState(&x, &y);
1177  SDL_WarpMouseInWindow(window, x, y);
1178  }
1179 }
1180 
1181 #if __WINRT__
1183 #endif
1184 
1185 static int
1187 {
1188  SDL_VideoDisplay *display;
1189  SDL_Window *other;
1190 
1191  CHECK_WINDOW_MAGIC(window,-1);
1192 
1193  /* if we are in the process of hiding don't go back to fullscreen */
1194  if (window->is_hiding && fullscreen) {
1195  return 0;
1196  }
1197 
1198 #ifdef __MACOSX__
1199  /* if the window is going away and no resolution change is necessary,
1200  do nothing, or else we may trigger an ugly double-transition
1201  */
1202  if (SDL_strcmp(_this->name, "cocoa") == 0) { /* don't do this for X11, etc */
1204  return 0;
1205 
1206  /* If we're switching between a fullscreen Space and "normal" fullscreen, we need to get back to normal first. */
1207  if (fullscreen && ((window->last_fullscreen_flags & FULLSCREEN_MASK) == SDL_WINDOW_FULLSCREEN_DESKTOP) && ((window->flags & FULLSCREEN_MASK) == SDL_WINDOW_FULLSCREEN)) {
1208  if (!Cocoa_SetWindowFullscreenSpace(window, SDL_FALSE)) {
1209  return -1;
1210  }
1211  } else if (fullscreen && ((window->last_fullscreen_flags & FULLSCREEN_MASK) == SDL_WINDOW_FULLSCREEN) && ((window->flags & FULLSCREEN_MASK) == SDL_WINDOW_FULLSCREEN_DESKTOP)) {
1212  display = SDL_GetDisplayForWindow(window);
1214  if (_this->SetWindowFullscreen) {
1215  _this->SetWindowFullscreen(_this, window, display, SDL_FALSE);
1216  }
1217  }
1218 
1219  if (Cocoa_SetWindowFullscreenSpace(window, fullscreen)) {
1220  if (Cocoa_IsWindowInFullscreenSpace(window) != fullscreen) {
1221  return -1;
1222  }
1223  window->last_fullscreen_flags = window->flags;
1224  return 0;
1225  }
1226  }
1227 #elif __WINRT__ && (NTDDI_VERSION < NTDDI_WIN10)
1228  /* HACK: WinRT 8.x apps can't choose whether or not they are fullscreen
1229  or not. The user can choose this, via OS-provided UI, but this can't
1230  be set programmatically.
1231 
1232  Just look at what SDL's WinRT video backend code detected with regards
1233  to fullscreen (being active, or not), and figure out a return/error code
1234  from that.
1235  */
1236  if (fullscreen == !(WINRT_DetectWindowFlags(window) & FULLSCREEN_MASK)) {
1237  /* Uh oh, either:
1238  1. fullscreen was requested, and we're already windowed
1239  2. windowed-mode was requested, and we're already fullscreen
1240 
1241  WinRT 8.x can't resolve either programmatically, so we're
1242  giving up.
1243  */
1244  return -1;
1245  } else {
1246  /* Whatever was requested, fullscreen or windowed mode, is already
1247  in-place.
1248  */
1249  return 0;
1250  }
1251 #endif
1252 
1253  display = SDL_GetDisplayForWindow(window);
1254 
1255  if (fullscreen) {
1256  /* Hide any other fullscreen windows */
1257  if (display->fullscreen_window &&
1258  display->fullscreen_window != window) {
1260  }
1261  }
1262 
1263  /* See if anything needs to be done now */
1264  if ((display->fullscreen_window == window) == fullscreen) {
1265  if ((window->last_fullscreen_flags & FULLSCREEN_MASK) == (window->flags & FULLSCREEN_MASK)) {
1266  return 0;
1267  }
1268  }
1269 
1270  /* See if there are any fullscreen windows */
1271  for (other = _this->windows; other; other = other->next) {
1272  SDL_bool setDisplayMode = SDL_FALSE;
1273 
1274  if (other == window) {
1275  setDisplayMode = fullscreen;
1276  } else if (FULLSCREEN_VISIBLE(other) &&
1277  SDL_GetDisplayForWindow(other) == display) {
1278  setDisplayMode = SDL_TRUE;
1279  }
1280 
1281  if (setDisplayMode) {
1282  SDL_DisplayMode fullscreen_mode;
1283 
1284  SDL_zero(fullscreen_mode);
1285 
1286  if (SDL_GetWindowDisplayMode(other, &fullscreen_mode) == 0) {
1287  SDL_bool resized = SDL_TRUE;
1288 
1289  if (other->w == fullscreen_mode.w && other->h == fullscreen_mode.h) {
1290  resized = SDL_FALSE;
1291  }
1292 
1293  /* only do the mode change if we want exclusive fullscreen */
1295  if (SDL_SetDisplayModeForDisplay(display, &fullscreen_mode) < 0) {
1296  return -1;
1297  }
1298  } else {
1299  if (SDL_SetDisplayModeForDisplay(display, NULL) < 0) {
1300  return -1;
1301  }
1302  }
1303 
1304  if (_this->SetWindowFullscreen) {
1305  _this->SetWindowFullscreen(_this, other, display, SDL_TRUE);
1306  }
1307  display->fullscreen_window = other;
1308 
1309  /* Generate a mode change event here */
1310  if (resized) {
1311 #ifndef ANDROID
1312  // Android may not resize the window to exactly what our fullscreen mode is, especially on
1313  // windowed Android environments like the Chromebook or Samsung DeX. Given this, we shouldn't
1314  // use fullscreen_mode.w and fullscreen_mode.h, but rather get our current native size. As such,
1315  // Android's SetWindowFullscreen will generate the window event for us with the proper final size.
1316 
1318  fullscreen_mode.w, fullscreen_mode.h);
1319 #endif
1320  } else {
1321  SDL_OnWindowResized(other);
1322  }
1323 
1324  SDL_RestoreMousePosition(other);
1325 
1326  window->last_fullscreen_flags = window->flags;
1327  return 0;
1328  }
1329  }
1330  }
1331 
1332  /* Nope, restore the desktop mode */
1334 
1335  if (_this->SetWindowFullscreen) {
1336  _this->SetWindowFullscreen(_this, window, display, SDL_FALSE);
1337  }
1338  display->fullscreen_window = NULL;
1339 
1340  /* Generate a mode change event here */
1341  SDL_OnWindowResized(window);
1342 
1343  /* Restore the cursor position */
1344  SDL_RestoreMousePosition(window);
1345 
1346  window->last_fullscreen_flags = window->flags;
1347  return 0;
1348 }
1349 
1350 #define CREATE_FLAGS \
1351  (SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_ALWAYS_ON_TOP | SDL_WINDOW_SKIP_TASKBAR | SDL_WINDOW_POPUP_MENU | SDL_WINDOW_UTILITY | SDL_WINDOW_TOOLTIP | SDL_WINDOW_VULKAN | SDL_WINDOW_MINIMIZED)
1352 
1353 static SDL_INLINE SDL_bool
1355 {
1358  return SDL_TRUE;
1359  }
1360  return SDL_FALSE;
1361 }
1362 
1363 /* prepare a newly-created window */
1364 static SDL_INLINE void
1366 {
1367  if (_this->AcceptDragAndDrop) {
1368  _this->AcceptDragAndDrop(window, IsAcceptingDragAndDrop());
1369  }
1370 }
1371 
1372 /* toggle d'n'd for all existing windows. */
1373 void
1375 {
1376  if (_this && _this->AcceptDragAndDrop) {
1378  SDL_Window *window;
1379  for (window = _this->windows; window; window = window->next) {
1380  _this->AcceptDragAndDrop(window, enable);
1381  }
1382  }
1383 }
1384 
1385 static void
1387 {
1388  PrepareDragAndDropSupport(window);
1389 
1390  if (flags & SDL_WINDOW_MAXIMIZED) {
1391  SDL_MaximizeWindow(window);
1392  }
1393  if (flags & SDL_WINDOW_MINIMIZED) {
1394  SDL_MinimizeWindow(window);
1395  }
1396  if (flags & SDL_WINDOW_FULLSCREEN) {
1397  SDL_SetWindowFullscreen(window, flags);
1398  }
1399  if (flags & SDL_WINDOW_INPUT_GRABBED) {
1400  SDL_SetWindowGrab(window, SDL_TRUE);
1401  }
1402  if (!(flags & SDL_WINDOW_HIDDEN)) {
1403  SDL_ShowWindow(window);
1404  }
1405 }
1406 
1407 SDL_Window *
1408 SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
1409 {
1410  SDL_Window *window;
1411 
1412  if (!_this) {
1413  /* Initialize the video system if needed */
1414  if (SDL_VideoInit(NULL) < 0) {
1415  return NULL;
1416  }
1417  }
1418 
1419  if ((((flags & SDL_WINDOW_UTILITY) != 0) + ((flags & SDL_WINDOW_TOOLTIP) != 0) + ((flags & SDL_WINDOW_POPUP_MENU) != 0)) > 1) {
1420  SDL_SetError("Conflicting window flags specified");
1421  return NULL;
1422  }
1423 
1424  /* Some platforms can't create zero-sized windows */
1425  if (w < 1) {
1426  w = 1;
1427  }
1428  if (h < 1) {
1429  h = 1;
1430  }
1431 
1432  /* Some platforms blow up if the windows are too large. Raise it later? */
1433  if ((w > 16384) || (h > 16384)) {
1434  SDL_SetError("Window is too large.");
1435  return NULL;
1436  }
1437 
1438  /* Some platforms have OpenGL enabled by default */
1439 #if (SDL_VIDEO_OPENGL && __MACOSX__) || __IPHONEOS__ || __ANDROID__ || __NACL__
1440  if (!_this->is_dummy && !(flags & SDL_WINDOW_VULKAN)) {
1441  flags |= SDL_WINDOW_OPENGL;
1442  }
1443 #endif
1444  if (flags & SDL_WINDOW_OPENGL) {
1445  if (!_this->GL_CreateContext) {
1446  SDL_SetError("OpenGL support is either not configured in SDL "
1447  "or not available in current SDL video driver "
1448  "(%s) or platform", _this->name);
1449  return NULL;
1450  }
1451  if (SDL_GL_LoadLibrary(NULL) < 0) {
1452  return NULL;
1453  }
1454  }
1455 
1456  if (flags & SDL_WINDOW_VULKAN) {
1457  if (!_this->Vulkan_CreateSurface) {
1458  SDL_SetError("Vulkan support is either not configured in SDL "
1459  "or not available in current SDL video driver "
1460  "(%s) or platform", _this->name);
1461  return NULL;
1462  }
1463  if (flags & SDL_WINDOW_OPENGL) {
1464  SDL_SetError("Vulkan and OpenGL not supported on same window");
1465  return NULL;
1466  }
1467  if (SDL_Vulkan_LoadLibrary(NULL) < 0) {
1468  return NULL;
1469  }
1470  }
1471 
1472  /* Unless the user has specified the high-DPI disabling hint, respect the
1473  * SDL_WINDOW_ALLOW_HIGHDPI flag.
1474  */
1475  if (flags & SDL_WINDOW_ALLOW_HIGHDPI) {
1477  flags &= ~SDL_WINDOW_ALLOW_HIGHDPI;
1478  }
1479  }
1480 
1481  window = (SDL_Window *)SDL_calloc(1, sizeof(*window));
1482  if (!window) {
1483  SDL_OutOfMemory();
1484  return NULL;
1485  }
1486  window->magic = &_this->window_magic;
1487  window->id = _this->next_object_id++;
1488  window->x = x;
1489  window->y = y;
1490  window->w = w;
1491  window->h = h;
1494  SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
1495  int displayIndex;
1496  SDL_Rect bounds;
1497 
1498  displayIndex = SDL_GetIndexOfDisplay(display);
1499  SDL_GetDisplayBounds(displayIndex, &bounds);
1501  window->x = bounds.x + (bounds.w - w) / 2;
1502  }
1504  window->y = bounds.y + (bounds.h - h) / 2;
1505  }
1506  }
1507  window->windowed.x = window->x;
1508  window->windowed.y = window->y;
1509  window->windowed.w = window->w;
1510  window->windowed.h = window->h;
1511 
1512  if (flags & SDL_WINDOW_FULLSCREEN) {
1513  SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
1514  int displayIndex;
1515  SDL_Rect bounds;
1516 
1517  displayIndex = SDL_GetIndexOfDisplay(display);
1518  SDL_GetDisplayBounds(displayIndex, &bounds);
1519 
1520  window->x = bounds.x;
1521  window->y = bounds.y;
1522  window->w = bounds.w;
1523  window->h = bounds.h;
1524  }
1525 
1526  window->flags = ((flags & CREATE_FLAGS) | SDL_WINDOW_HIDDEN);
1527  window->last_fullscreen_flags = window->flags;
1528  window->opacity = 1.0f;
1529  window->brightness = 1.0f;
1530  window->next = _this->windows;
1531  window->is_destroying = SDL_FALSE;
1532 
1533  if (_this->windows) {
1534  _this->windows->prev = window;
1535  }
1536  _this->windows = window;
1537 
1538  if (_this->CreateSDLWindow && _this->CreateSDLWindow(_this, window) < 0) {
1539  SDL_DestroyWindow(window);
1540  return NULL;
1541  }
1542 
1543  /* Clear minimized if not on windows, only windows handles it at create rather than FinishWindowCreation,
1544  * but it's important or window focus will get broken on windows!
1545  */
1546 #if !defined(__WIN32__)
1547  if (window->flags & SDL_WINDOW_MINIMIZED) {
1548  window->flags &= ~SDL_WINDOW_MINIMIZED;
1549  }
1550 #endif
1551 
1552 #if __WINRT__ && (NTDDI_VERSION < NTDDI_WIN10)
1553  /* HACK: WinRT 8.x apps can't choose whether or not they are fullscreen
1554  or not. The user can choose this, via OS-provided UI, but this can't
1555  be set programmatically.
1556 
1557  Just look at what SDL's WinRT video backend code detected with regards
1558  to fullscreen (being active, or not), and figure out a return/error code
1559  from that.
1560  */
1561  flags = window->flags;
1562 #endif
1563 
1564  if (title) {
1565  SDL_SetWindowTitle(window, title);
1566  }
1567  SDL_FinishWindowCreation(window, flags);
1568 
1569  /* If the window was created fullscreen, make sure the mode code matches */
1571 
1572  return window;
1573 }
1574 
1575 SDL_Window *
1577 {
1578  SDL_Window *window;
1579 
1580  if (!_this) {
1582  return NULL;
1583  }
1584  if (!_this->CreateSDLWindowFrom) {
1585  SDL_Unsupported();
1586  return NULL;
1587  }
1588  window = (SDL_Window *)SDL_calloc(1, sizeof(*window));
1589  if (!window) {
1590  SDL_OutOfMemory();
1591  return NULL;
1592  }
1593  window->magic = &_this->window_magic;
1594  window->id = _this->next_object_id++;
1595  window->flags = SDL_WINDOW_FOREIGN;
1596  window->last_fullscreen_flags = window->flags;
1597  window->is_destroying = SDL_FALSE;
1598  window->opacity = 1.0f;
1599  window->brightness = 1.0f;
1600  window->next = _this->windows;
1601  if (_this->windows) {
1602  _this->windows->prev = window;
1603  }
1604  _this->windows = window;
1605 
1606  if (_this->CreateSDLWindowFrom(_this, window, data) < 0) {
1607  SDL_DestroyWindow(window);
1608  return NULL;
1609  }
1610 
1611  PrepareDragAndDropSupport(window);
1612 
1613  return window;
1614 }
1615 
1616 int
1618 {
1619  SDL_bool loaded_opengl = SDL_FALSE;
1620 
1621  if ((flags & SDL_WINDOW_OPENGL) && !_this->GL_CreateContext) {
1622  return SDL_SetError("OpenGL support is either not configured in SDL "
1623  "or not available in current SDL video driver "
1624  "(%s) or platform", _this->name);
1625  }
1626 
1627  if (window->flags & SDL_WINDOW_FOREIGN) {
1628  /* Can't destroy and re-create foreign windows, hrm */
1629  flags |= SDL_WINDOW_FOREIGN;
1630  } else {
1631  flags &= ~SDL_WINDOW_FOREIGN;
1632  }
1633 
1634  /* Restore video mode, etc. */
1635  SDL_HideWindow(window);
1636 
1637  /* Tear down the old native window */
1638  if (window->surface) {
1639  window->surface->flags &= ~SDL_DONTFREE;
1640  SDL_FreeSurface(window->surface);
1641  window->surface = NULL;
1642  }
1643  if (_this->DestroyWindowFramebuffer) {
1644  _this->DestroyWindowFramebuffer(_this, window);
1645  }
1646  if (_this->DestroyWindow && !(flags & SDL_WINDOW_FOREIGN)) {
1647  _this->DestroyWindow(_this, window);
1648  }
1649 
1650  if ((window->flags & SDL_WINDOW_OPENGL) != (flags & SDL_WINDOW_OPENGL)) {
1651  if (flags & SDL_WINDOW_OPENGL) {
1652  if (SDL_GL_LoadLibrary(NULL) < 0) {
1653  return -1;
1654  }
1655  loaded_opengl = SDL_TRUE;
1656  } else {
1658  }
1659  }
1660 
1661  if ((window->flags & SDL_WINDOW_VULKAN) != (flags & SDL_WINDOW_VULKAN)) {
1662  SDL_SetError("Can't change SDL_WINDOW_VULKAN window flag");
1663  return -1;
1664  }
1665 
1666  if ((window->flags & SDL_WINDOW_VULKAN) && (flags & SDL_WINDOW_OPENGL)) {
1667  SDL_SetError("Vulkan and OpenGL not supported on same window");
1668  return -1;
1669  }
1670 
1671  window->flags = ((flags & CREATE_FLAGS) | SDL_WINDOW_HIDDEN);
1672  window->last_fullscreen_flags = window->flags;
1673  window->is_destroying = SDL_FALSE;
1674 
1675  if (_this->CreateSDLWindow && !(flags & SDL_WINDOW_FOREIGN)) {
1676  if (_this->CreateSDLWindow(_this, window) < 0) {
1677  if (loaded_opengl) {
1679  window->flags &= ~SDL_WINDOW_OPENGL;
1680  }
1681  return -1;
1682  }
1683  }
1684 
1685  if (flags & SDL_WINDOW_FOREIGN) {
1686  window->flags |= SDL_WINDOW_FOREIGN;
1687  }
1688 
1689  if (_this->SetWindowTitle && window->title) {
1690  _this->SetWindowTitle(_this, window);
1691  }
1692 
1693  if (_this->SetWindowIcon && window->icon) {
1694  _this->SetWindowIcon(_this, window, window->icon);
1695  }
1696 
1697  if (window->hit_test) {
1698  _this->SetWindowHitTest(window, SDL_TRUE);
1699  }
1700 
1701  SDL_FinishWindowCreation(window, flags);
1702 
1703  return 0;
1704 }
1705 
1706 SDL_bool
1708 {
1709  return (_this && _this->windows != NULL);
1710 }
1711 
1712 Uint32
1714 {
1715  CHECK_WINDOW_MAGIC(window, 0);
1716 
1717  return window->id;
1718 }
1719 
1720 SDL_Window *
1722 {
1723  SDL_Window *window;
1724 
1725  if (!_this) {
1726  return NULL;
1727  }
1728  for (window = _this->windows; window; window = window->next) {
1729  if (window->id == id) {
1730  return window;
1731  }
1732  }
1733  return NULL;
1734 }
1735 
1736 Uint32
1738 {
1739  CHECK_WINDOW_MAGIC(window, 0);
1740 
1741  return window->flags;
1742 }
1743 
1744 void
1745 SDL_SetWindowTitle(SDL_Window * window, const char *title)
1746 {
1747  CHECK_WINDOW_MAGIC(window,);
1748 
1749  if (title == window->title) {
1750  return;
1751  }
1752  SDL_free(window->title);
1753 
1754  window->title = SDL_strdup(title ? title : "");
1755 
1756  if (_this->SetWindowTitle) {
1757  _this->SetWindowTitle(_this, window);
1758  }
1759 }
1760 
1761 const char *
1763 {
1764  CHECK_WINDOW_MAGIC(window, "");
1765 
1766  return window->title ? window->title : "";
1767 }
1768 
1769 void
1771 {
1772  CHECK_WINDOW_MAGIC(window,);
1773 
1774  if (!icon) {
1775  return;
1776  }
1777 
1778  SDL_FreeSurface(window->icon);
1779 
1780  /* Convert the icon into ARGB8888 */
1782  if (!window->icon) {
1783  return;
1784  }
1785 
1786  if (_this->SetWindowIcon) {
1787  _this->SetWindowIcon(_this, window, window->icon);
1788  }
1789 }
1790 
1791 void*
1792 SDL_SetWindowData(SDL_Window * window, const char *name, void *userdata)
1793 {
1794  SDL_WindowUserData *prev, *data;
1795 
1796  CHECK_WINDOW_MAGIC(window, NULL);
1797 
1798  /* Input validation */
1799  if (name == NULL || name[0] == '\0') {
1800  SDL_InvalidParamError("name");
1801  return NULL;
1802  }
1803 
1804  /* See if the named data already exists */
1805  prev = NULL;
1806  for (data = window->data; data; prev = data, data = data->next) {
1807  if (data->name && SDL_strcmp(data->name, name) == 0) {
1808  void *last_value = data->data;
1809 
1810  if (userdata) {
1811  /* Set the new value */
1812  data->data = userdata;
1813  } else {
1814  /* Delete this value */
1815  if (prev) {
1816  prev->next = data->next;
1817  } else {
1818  window->data = data->next;
1819  }
1820  SDL_free(data->name);
1821  SDL_free(data);
1822  }
1823  return last_value;
1824  }
1825  }
1826 
1827  /* Add new data to the window */
1828  if (userdata) {
1829  data = (SDL_WindowUserData *)SDL_malloc(sizeof(*data));
1830  data->name = SDL_strdup(name);
1831  data->data = userdata;
1832  data->next = window->data;
1833  window->data = data;
1834  }
1835  return NULL;
1836 }
1837 
1838 void *
1839 SDL_GetWindowData(SDL_Window * window, const char *name)
1840 {
1842 
1843  CHECK_WINDOW_MAGIC(window, NULL);
1844 
1845  /* Input validation */
1846  if (name == NULL || name[0] == '\0') {
1847  SDL_InvalidParamError("name");
1848  return NULL;
1849  }
1850 
1851  for (data = window->data; data; data = data->next) {
1852  if (data->name && SDL_strcmp(data->name, name) == 0) {
1853  return data->data;
1854  }
1855  }
1856  return NULL;
1857 }
1858 
1859 void
1861 {
1862  CHECK_WINDOW_MAGIC(window,);
1863 
1865  int displayIndex = (x & 0xFFFF);
1866  SDL_Rect bounds;
1867  if (displayIndex >= _this->num_displays) {
1868  displayIndex = 0;
1869  }
1870 
1871  SDL_zero(bounds);
1872 
1873  SDL_GetDisplayBounds(displayIndex, &bounds);
1874  if (SDL_WINDOWPOS_ISCENTERED(x)) {
1875  x = bounds.x + (bounds.w - window->w) / 2;
1876  }
1877  if (SDL_WINDOWPOS_ISCENTERED(y)) {
1878  y = bounds.y + (bounds.h - window->h) / 2;
1879  }
1880  }
1881 
1882  if ((window->flags & SDL_WINDOW_FULLSCREEN)) {
1883  if (!SDL_WINDOWPOS_ISUNDEFINED(x)) {
1884  window->windowed.x = x;
1885  }
1886  if (!SDL_WINDOWPOS_ISUNDEFINED(y)) {
1887  window->windowed.y = y;
1888  }
1889  } else {
1890  if (!SDL_WINDOWPOS_ISUNDEFINED(x)) {
1891  window->x = x;
1892  }
1893  if (!SDL_WINDOWPOS_ISUNDEFINED(y)) {
1894  window->y = y;
1895  }
1896 
1897  if (_this->SetWindowPosition) {
1898  _this->SetWindowPosition(_this, window);
1899  }
1901  }
1902 }
1903 
1904 void
1905 SDL_GetWindowPosition(SDL_Window * window, int *x, int *y)
1906 {
1907  CHECK_WINDOW_MAGIC(window,);
1908 
1909  /* Fullscreen windows are always at their display's origin */
1910  if (window->flags & SDL_WINDOW_FULLSCREEN) {
1911  int displayIndex;
1912 
1913  if (x) {
1914  *x = 0;
1915  }
1916  if (y) {
1917  *y = 0;
1918  }
1919 
1920  /* Find the window's monitor and update to the
1921  monitor offset. */
1922  displayIndex = SDL_GetWindowDisplayIndex(window);
1923  if (displayIndex >= 0) {
1924  SDL_Rect bounds;
1925 
1926  SDL_zero(bounds);
1927 
1928  SDL_GetDisplayBounds(displayIndex, &bounds);
1929  if (x) {
1930  *x = bounds.x;
1931  }
1932  if (y) {
1933  *y = bounds.y;
1934  }
1935  }
1936  } else {
1937  if (x) {
1938  *x = window->x;
1939  }
1940  if (y) {
1941  *y = window->y;
1942  }
1943  }
1944 }
1945 
1946 void
1948 {
1949  CHECK_WINDOW_MAGIC(window,);
1950  if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
1951  const int want = (bordered != SDL_FALSE); /* normalize the flag. */
1952  const int have = ((window->flags & SDL_WINDOW_BORDERLESS) == 0);
1953  if ((want != have) && (_this->SetWindowBordered)) {
1954  if (want) {
1955  window->flags &= ~SDL_WINDOW_BORDERLESS;
1956  } else {
1957  window->flags |= SDL_WINDOW_BORDERLESS;
1958  }
1959  _this->SetWindowBordered(_this, window, (SDL_bool) want);
1960  }
1961  }
1962 }
1963 
1964 void
1966 {
1967  CHECK_WINDOW_MAGIC(window,);
1968  if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
1969  const int want = (resizable != SDL_FALSE); /* normalize the flag. */
1970  const int have = ((window->flags & SDL_WINDOW_RESIZABLE) != 0);
1971  if ((want != have) && (_this->SetWindowResizable)) {
1972  if (want) {
1973  window->flags |= SDL_WINDOW_RESIZABLE;
1974  } else {
1975  window->flags &= ~SDL_WINDOW_RESIZABLE;
1976  }
1977  _this->SetWindowResizable(_this, window, (SDL_bool) want);
1978  }
1979  }
1980 }
1981 
1982 void
1983 SDL_SetWindowSize(SDL_Window * window, int w, int h)
1984 {
1985  CHECK_WINDOW_MAGIC(window,);
1986  if (w <= 0) {
1987  SDL_InvalidParamError("w");
1988  return;
1989  }
1990  if (h <= 0) {
1991  SDL_InvalidParamError("h");
1992  return;
1993  }
1994 
1995  /* Make sure we don't exceed any window size limits */
1996  if (window->min_w && w < window->min_w) {
1997  w = window->min_w;
1998  }
1999  if (window->max_w && w > window->max_w) {
2000  w = window->max_w;
2001  }
2002  if (window->min_h && h < window->min_h) {
2003  h = window->min_h;
2004  }
2005  if (window->max_h && h > window->max_h) {
2006  h = window->max_h;
2007  }
2008 
2009  window->windowed.w = w;
2010  window->windowed.h = h;
2011 
2012  if (window->flags & SDL_WINDOW_FULLSCREEN) {
2014  window->last_fullscreen_flags = 0;
2016  }
2017  } else {
2018  window->w = w;
2019  window->h = h;
2020  if (_this->SetWindowSize) {
2021  _this->SetWindowSize(_this, window);
2022  }
2023  if (window->w == w && window->h == h) {
2024  /* We didn't get a SDL_WINDOWEVENT_RESIZED event (by design) */
2025  SDL_OnWindowResized(window);
2026  }
2027  }
2028 }
2029 
2030 void
2031 SDL_GetWindowSize(SDL_Window * window, int *w, int *h)
2032 {
2033  CHECK_WINDOW_MAGIC(window,);
2034  if (w) {
2035  *w = window->w;
2036  }
2037  if (h) {
2038  *h = window->h;
2039  }
2040 }
2041 
2042 int
2043 SDL_GetWindowBordersSize(SDL_Window * window, int *top, int *left, int *bottom, int *right)
2044 {
2045  int dummy = 0;
2046 
2047  if (!top) { top = &dummy; }
2048  if (!left) { left = &dummy; }
2049  if (!right) { right = &dummy; }
2050  if (!bottom) { bottom = &dummy; }
2051 
2052  /* Always initialize, so applications don't have to care */
2053  *top = *left = *bottom = *right = 0;
2054 
2055  CHECK_WINDOW_MAGIC(window, -1);
2056 
2057  if (!_this->GetWindowBordersSize) {
2058  return SDL_Unsupported();
2059  }
2060 
2061  return _this->GetWindowBordersSize(_this, window, top, left, bottom, right);
2062 }
2063 
2064 void
2065 SDL_SetWindowMinimumSize(SDL_Window * window, int min_w, int min_h)
2066 {
2067  CHECK_WINDOW_MAGIC(window,);
2068  if (min_w <= 0) {
2069  SDL_InvalidParamError("min_w");
2070  return;
2071  }
2072  if (min_h <= 0) {
2073  SDL_InvalidParamError("min_h");
2074  return;
2075  }
2076 
2077  if ((window->max_w && min_w >= window->max_w) ||
2078  (window->max_h && min_h >= window->max_h)) {
2079  SDL_SetError("SDL_SetWindowMinimumSize(): Tried to set minimum size larger than maximum size");
2080  return;
2081  }
2082 
2083  window->min_w = min_w;
2084  window->min_h = min_h;
2085 
2086  if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
2087  if (_this->SetWindowMinimumSize) {
2088  _this->SetWindowMinimumSize(_this, window);
2089  }
2090  /* Ensure that window is not smaller than minimal size */
2091  SDL_SetWindowSize(window, SDL_max(window->w, window->min_w), SDL_max(window->h, window->min_h));
2092  }
2093 }
2094 
2095 void
2096 SDL_GetWindowMinimumSize(SDL_Window * window, int *min_w, int *min_h)
2097 {
2098  CHECK_WINDOW_MAGIC(window,);
2099  if (min_w) {
2100  *min_w = window->min_w;
2101  }
2102  if (min_h) {
2103  *min_h = window->min_h;
2104  }
2105 }
2106 
2107 void
2108 SDL_SetWindowMaximumSize(SDL_Window * window, int max_w, int max_h)
2109 {
2110  CHECK_WINDOW_MAGIC(window,);
2111  if (max_w <= 0) {
2112  SDL_InvalidParamError("max_w");
2113  return;
2114  }
2115  if (max_h <= 0) {
2116  SDL_InvalidParamError("max_h");
2117  return;
2118  }
2119 
2120  if (max_w <= window->min_w || max_h <= window->min_h) {
2121  SDL_SetError("SDL_SetWindowMaximumSize(): Tried to set maximum size smaller than minimum size");
2122  return;
2123  }
2124 
2125  window->max_w = max_w;
2126  window->max_h = max_h;
2127 
2128  if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
2129  if (_this->SetWindowMaximumSize) {
2130  _this->SetWindowMaximumSize(_this, window);
2131  }
2132  /* Ensure that window is not larger than maximal size */
2133  SDL_SetWindowSize(window, SDL_min(window->w, window->max_w), SDL_min(window->h, window->max_h));
2134  }
2135 }
2136 
2137 void
2138 SDL_GetWindowMaximumSize(SDL_Window * window, int *max_w, int *max_h)
2139 {
2140  CHECK_WINDOW_MAGIC(window,);
2141  if (max_w) {
2142  *max_w = window->max_w;
2143  }
2144  if (max_h) {
2145  *max_h = window->max_h;
2146  }
2147 }
2148 
2149 void
2151 {
2152  CHECK_WINDOW_MAGIC(window,);
2153 
2154  if (window->flags & SDL_WINDOW_SHOWN) {
2155  return;
2156  }
2157 
2158  if (_this->ShowWindow) {
2159  _this->ShowWindow(_this, window);
2160  }
2162 }
2163 
2164 void
2166 {
2167  CHECK_WINDOW_MAGIC(window,);
2168 
2169  if (!(window->flags & SDL_WINDOW_SHOWN)) {
2170  return;
2171  }
2172 
2173  window->is_hiding = SDL_TRUE;
2175 
2176  if (_this->HideWindow) {
2177  _this->HideWindow(_this, window);
2178  }
2179  window->is_hiding = SDL_FALSE;
2181 }
2182 
2183 void
2185 {
2186  CHECK_WINDOW_MAGIC(window,);
2187 
2188  if (!(window->flags & SDL_WINDOW_SHOWN)) {
2189  return;
2190  }
2191  if (_this->RaiseWindow) {
2192  _this->RaiseWindow(_this, window);
2193  }
2194 }
2195 
2196 void
2198 {
2199  CHECK_WINDOW_MAGIC(window,);
2200 
2201  if (window->flags & SDL_WINDOW_MAXIMIZED) {
2202  return;
2203  }
2204 
2205  /* !!! FIXME: should this check if the window is resizable? */
2206 
2207  if (_this->MaximizeWindow) {
2208  _this->MaximizeWindow(_this, window);
2209  }
2210 }
2211 
2212 void
2214 {
2215  CHECK_WINDOW_MAGIC(window,);
2216 
2217  if (window->flags & SDL_WINDOW_MINIMIZED) {
2218  return;
2219  }
2220 
2222 
2223  if (_this->MinimizeWindow) {
2224  _this->MinimizeWindow(_this, window);
2225  }
2226 }
2227 
2228 void
2230 {
2231  CHECK_WINDOW_MAGIC(window,);
2232 
2233  if (!(window->flags & (SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED))) {
2234  return;
2235  }
2236 
2237  if (_this->RestoreWindow) {
2238  _this->RestoreWindow(_this, window);
2239  }
2240 }
2241 
2242 int
2244 {
2245  Uint32 oldflags;
2246  CHECK_WINDOW_MAGIC(window, -1);
2247 
2248  flags &= FULLSCREEN_MASK;
2249 
2250  if (flags == (window->flags & FULLSCREEN_MASK)) {
2251  return 0;
2252  }
2253 
2254  /* clear the previous flags and OR in the new ones */
2255  oldflags = window->flags & FULLSCREEN_MASK;
2256  window->flags &= ~FULLSCREEN_MASK;
2257  window->flags |= flags;
2258 
2259  if (SDL_UpdateFullscreenMode(window, FULLSCREEN_VISIBLE(window)) == 0) {
2260  return 0;
2261  }
2262 
2263  window->flags &= ~FULLSCREEN_MASK;
2264  window->flags |= oldflags;
2265  return -1;
2266 }
2267 
2268 static SDL_Surface *
2270 {
2271  Uint32 format;
2272  void *pixels;
2273  int pitch;
2274  int bpp;
2275  Uint32 Rmask, Gmask, Bmask, Amask;
2276 
2277  if (!_this->CreateWindowFramebuffer || !_this->UpdateWindowFramebuffer) {
2278  return NULL;
2279  }
2280 
2281  if (_this->CreateWindowFramebuffer(_this, window, &format, &pixels, &pitch) < 0) {
2282  return NULL;
2283  }
2284 
2285  if (!SDL_PixelFormatEnumToMasks(format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
2286  return NULL;
2287  }
2288 
2289  return SDL_CreateRGBSurfaceFrom(pixels, window->w, window->h, bpp, pitch, Rmask, Gmask, Bmask, Amask);
2290 }
2291 
2292 SDL_Surface *
2294 {
2295  CHECK_WINDOW_MAGIC(window, NULL);
2296 
2297  if (!window->surface_valid) {
2298  if (window->surface) {
2299  window->surface->flags &= ~SDL_DONTFREE;
2300  SDL_FreeSurface(window->surface);
2301  }
2302  window->surface = SDL_CreateWindowFramebuffer(window);
2303  if (window->surface) {
2304  window->surface_valid = SDL_TRUE;
2305  window->surface->flags |= SDL_DONTFREE;
2306  }
2307  }
2308  return window->surface;
2309 }
2310 
2311 int
2313 {
2314  SDL_Rect full_rect;
2315 
2316  CHECK_WINDOW_MAGIC(window, -1);
2317 
2318  full_rect.x = 0;
2319  full_rect.y = 0;
2320  full_rect.w = window->w;
2321  full_rect.h = window->h;
2322  return SDL_UpdateWindowSurfaceRects(window, &full_rect, 1);
2323 }
2324 
2325 int
2327  int numrects)
2328 {
2329  CHECK_WINDOW_MAGIC(window, -1);
2330 
2331  if (!window->surface_valid) {
2332  return SDL_SetError("Window surface is invalid, please call SDL_GetWindowSurface() to get a new surface");
2333  }
2334 
2335  return _this->UpdateWindowFramebuffer(_this, window, rects, numrects);
2336 }
2337 
2338 int
2339 SDL_SetWindowBrightness(SDL_Window * window, float brightness)
2340 {
2341  Uint16 ramp[256];
2342  int status;
2343 
2344  CHECK_WINDOW_MAGIC(window, -1);
2345 
2346  SDL_CalculateGammaRamp(brightness, ramp);
2347  status = SDL_SetWindowGammaRamp(window, ramp, ramp, ramp);
2348  if (status == 0) {
2349  window->brightness = brightness;
2350  }
2351  return status;
2352 }
2353 
2354 float
2356 {
2357  CHECK_WINDOW_MAGIC(window, 1.0f);
2358 
2359  return window->brightness;
2360 }
2361 
2362 int
2363 SDL_SetWindowOpacity(SDL_Window * window, float opacity)
2364 {
2365  int retval;
2366  CHECK_WINDOW_MAGIC(window, -1);
2367 
2368  if (!_this->SetWindowOpacity) {
2369  return SDL_Unsupported();
2370  }
2371 
2372  if (opacity < 0.0f) {
2373  opacity = 0.0f;
2374  } else if (opacity > 1.0f) {
2375  opacity = 1.0f;
2376  }
2377 
2378  retval = _this->SetWindowOpacity(_this, window, opacity);
2379  if (retval == 0) {
2380  window->opacity = opacity;
2381  }
2382 
2383  return retval;
2384 }
2385 
2386 int
2387 SDL_GetWindowOpacity(SDL_Window * window, float * out_opacity)
2388 {
2389  CHECK_WINDOW_MAGIC(window, -1);
2390 
2391  if (out_opacity) {
2392  *out_opacity = window->opacity;
2393  }
2394 
2395  return 0;
2396 }
2397 
2398 int
2399 SDL_SetWindowModalFor(SDL_Window * modal_window, SDL_Window * parent_window)
2400 {
2401  CHECK_WINDOW_MAGIC(modal_window, -1);
2402  CHECK_WINDOW_MAGIC(parent_window, -1);
2403 
2404  if (!_this->SetWindowModalFor) {
2405  return SDL_Unsupported();
2406  }
2407 
2408  return _this->SetWindowModalFor(_this, modal_window, parent_window);
2409 }
2410 
2411 int
2413 {
2414  CHECK_WINDOW_MAGIC(window, -1);
2415 
2416  if (!_this->SetWindowInputFocus) {
2417  return SDL_Unsupported();
2418  }
2419 
2420  return _this->SetWindowInputFocus(_this, window);
2421 }
2422 
2423 
2424 int
2426  const Uint16 * green,
2427  const Uint16 * blue)
2428 {
2429  CHECK_WINDOW_MAGIC(window, -1);
2430 
2431  if (!_this->SetWindowGammaRamp) {
2432  return SDL_Unsupported();
2433  }
2434 
2435  if (!window->gamma) {
2436  if (SDL_GetWindowGammaRamp(window, NULL, NULL, NULL) < 0) {
2437  return -1;
2438  }
2439  SDL_assert(window->gamma != NULL);
2440  }
2441 
2442  if (red) {
2443  SDL_memcpy(&window->gamma[0*256], red, 256*sizeof(Uint16));
2444  }
2445  if (green) {
2446  SDL_memcpy(&window->gamma[1*256], green, 256*sizeof(Uint16));
2447  }
2448  if (blue) {
2449  SDL_memcpy(&window->gamma[2*256], blue, 256*sizeof(Uint16));
2450  }
2451  if (window->flags & SDL_WINDOW_INPUT_FOCUS) {
2452  return _this->SetWindowGammaRamp(_this, window, window->gamma);
2453  } else {
2454  return 0;
2455  }
2456 }
2457 
2458 int
2460  Uint16 * green,
2461  Uint16 * blue)
2462 {
2463  CHECK_WINDOW_MAGIC(window, -1);
2464 
2465  if (!window->gamma) {
2466  int i;
2467 
2468  window->gamma = (Uint16 *)SDL_malloc(256*6*sizeof(Uint16));
2469  if (!window->gamma) {
2470  return SDL_OutOfMemory();
2471  }
2472  window->saved_gamma = window->gamma + 3*256;
2473 
2474  if (_this->GetWindowGammaRamp) {
2475  if (_this->GetWindowGammaRamp(_this, window, window->gamma) < 0) {
2476  return -1;
2477  }
2478  } else {
2479  /* Create an identity gamma ramp */
2480  for (i = 0; i < 256; ++i) {
2481  Uint16 value = (Uint16)((i << 8) | i);
2482 
2483  window->gamma[0*256+i] = value;
2484  window->gamma[1*256+i] = value;
2485  window->gamma[2*256+i] = value;
2486  }
2487  }
2488  SDL_memcpy(window->saved_gamma, window->gamma, 3*256*sizeof(Uint16));
2489  }
2490 
2491  if (red) {
2492  SDL_memcpy(red, &window->gamma[0*256], 256*sizeof(Uint16));
2493  }
2494  if (green) {
2495  SDL_memcpy(green, &window->gamma[1*256], 256*sizeof(Uint16));
2496  }
2497  if (blue) {
2498  SDL_memcpy(blue, &window->gamma[2*256], 256*sizeof(Uint16));
2499  }
2500  return 0;
2501 }
2502 
2503 void
2505 {
2506  SDL_Window *grabbed_window;
2507  SDL_bool grabbed;
2508  if ((SDL_GetMouse()->relative_mode || (window->flags & SDL_WINDOW_INPUT_GRABBED)) &&
2509  (window->flags & SDL_WINDOW_INPUT_FOCUS)) {
2510  grabbed = SDL_TRUE;
2511  } else {
2512  grabbed = SDL_FALSE;
2513  }
2514 
2515  grabbed_window = _this->grabbed_window;
2516  if (grabbed) {
2517  if (grabbed_window && (grabbed_window != window)) {
2518  /* stealing a grab from another window! */
2519  grabbed_window->flags &= ~SDL_WINDOW_INPUT_GRABBED;
2520  if (_this->SetWindowGrab) {
2521  _this->SetWindowGrab(_this, grabbed_window, SDL_FALSE);
2522  }
2523  }
2524  _this->grabbed_window = window;
2525  } else if (grabbed_window == window) {
2526  _this->grabbed_window = NULL; /* ungrabbing. */
2527  }
2528 
2529  if (_this->SetWindowGrab) {
2530  _this->SetWindowGrab(_this, window, grabbed);
2531  }
2532 }
2533 
2534 void
2536 {
2537  CHECK_WINDOW_MAGIC(window,);
2538 
2539  if (!!grabbed == !!(window->flags & SDL_WINDOW_INPUT_GRABBED)) {
2540  return;
2541  }
2542  if (grabbed) {
2543  window->flags |= SDL_WINDOW_INPUT_GRABBED;
2544  } else {
2545  window->flags &= ~SDL_WINDOW_INPUT_GRABBED;
2546  }
2547  SDL_UpdateWindowGrab(window);
2548 }
2549 
2550 SDL_bool
2552 {
2553  CHECK_WINDOW_MAGIC(window, SDL_FALSE);
2555  return window == _this->grabbed_window;
2556 }
2557 
2558 SDL_Window *
2560 {
2562  return _this->grabbed_window;
2563 }
2564 
2565 void
2567 {
2568  SDL_OnWindowRestored(window);
2569 }
2570 
2571 void
2573 {
2575 }
2576 
2577 void
2579 {
2580  window->surface_valid = SDL_FALSE;
2581  SDL_SendWindowEvent(window, SDL_WINDOWEVENT_SIZE_CHANGED, window->w, window->h);
2582 }
2583 
2584 void
2586 {
2588 }
2589 
2590 void
2592 {
2593  /*
2594  * FIXME: Is this fine to just remove this, or should it be preserved just
2595  * for the fullscreen case? In principle it seems like just hiding/showing
2596  * windows shouldn't affect the stacking order; maybe the right fix is to
2597  * re-decouple OnWindowShown and OnWindowRestored.
2598  */
2599  /*SDL_RaiseWindow(window);*/
2600 
2601  if (FULLSCREEN_VISIBLE(window)) {
2603  }
2604 }
2605 
2606 void
2608 {
2609  if (_this->OnWindowEnter) {
2610  _this->OnWindowEnter(_this, window);
2611  }
2612 }
2613 
2614 void
2616 {
2617 }
2618 
2619 void
2621 {
2622  SDL_Mouse *mouse = SDL_GetMouse();
2623 
2624  if (window->gamma && _this->SetWindowGammaRamp) {
2625  _this->SetWindowGammaRamp(_this, window, window->gamma);
2626  }
2627 
2628  if (mouse && mouse->relative_mode) {
2629  SDL_SetMouseFocus(window);
2630  SDL_WarpMouseInWindow(window, window->w/2, window->h/2);
2631  }
2632 
2633  SDL_UpdateWindowGrab(window);
2634 }
2635 
2636 static SDL_bool
2638 {
2639  if (!(window->flags & SDL_WINDOW_FULLSCREEN) || window->is_destroying) {
2640  return SDL_FALSE;
2641  }
2642 
2643 #ifdef __MACOSX__
2644  if (SDL_strcmp(_this->name, "cocoa") == 0) { /* don't do this for X11, etc */
2645  if (Cocoa_IsWindowInFullscreenSpace(window)) {
2646  return SDL_FALSE;
2647  }
2648  }
2649 #endif
2650 
2652 }
2653 
2654 void
2656 {
2657  if (window->gamma && _this->SetWindowGammaRamp) {
2658  _this->SetWindowGammaRamp(_this, window, window->saved_gamma);
2659  }
2660 
2661  SDL_UpdateWindowGrab(window);
2662 
2663  if (ShouldMinimizeOnFocusLoss(window)) {
2664  SDL_MinimizeWindow(window);
2665  }
2666 }
2667 
2668 /* !!! FIXME: is this different than SDL_GetKeyboardFocus()?
2669  !!! FIXME: Also, SDL_GetKeyboardFocus() is O(1), this isn't. */
2670 SDL_Window *
2672 {
2673  SDL_Window *window;
2674 
2675  if (!_this) {
2676  return NULL;
2677  }
2678  for (window = _this->windows; window; window = window->next) {
2679  if (window->flags & SDL_WINDOW_INPUT_FOCUS) {
2680  return window;
2681  }
2682  }
2683  return NULL;
2684 }
2685 
2686 void
2688 {
2689  SDL_VideoDisplay *display;
2690 
2691  CHECK_WINDOW_MAGIC(window,);
2692 
2693  window->is_destroying = SDL_TRUE;
2694 
2695  /* Restore video mode, etc. */
2696  SDL_HideWindow(window);
2697 
2698  /* Make sure this window no longer has focus */
2699  if (SDL_GetKeyboardFocus() == window) {
2701  }
2702  if (SDL_GetMouseFocus() == window) {
2704  }
2705 
2706  /* make no context current if this is the current context window. */
2707  if (window->flags & SDL_WINDOW_OPENGL) {
2708  if (_this->current_glwin == window) {
2709  SDL_GL_MakeCurrent(window, NULL);
2710  }
2711  }
2712 
2713  if (window->surface) {
2714  window->surface->flags &= ~SDL_DONTFREE;
2715  SDL_FreeSurface(window->surface);
2716  }
2717  if (_this->DestroyWindowFramebuffer) {
2718  _this->DestroyWindowFramebuffer(_this, window);
2719  }
2720  if (_this->DestroyWindow) {
2721  _this->DestroyWindow(_this, window);
2722  }
2723  if (window->flags & SDL_WINDOW_OPENGL) {
2725  }
2726  if (window->flags & SDL_WINDOW_VULKAN) {
2728  }
2729 
2730  display = SDL_GetDisplayForWindow(window);
2731  if (display->fullscreen_window == window) {
2732  display->fullscreen_window = NULL;
2733  }
2734 
2735  /* Now invalidate magic */
2736  window->magic = NULL;
2737 
2738  /* Free memory associated with the window */
2739  SDL_free(window->title);
2740  SDL_FreeSurface(window->icon);
2741  SDL_free(window->gamma);
2742  while (window->data) {
2743  SDL_WindowUserData *data = window->data;
2744 
2745  window->data = data->next;
2746  SDL_free(data->name);
2747  SDL_free(data);
2748  }
2749 
2750  /* Unlink the window from the list */
2751  if (window->next) {
2752  window->next->prev = window->prev;
2753  }
2754  if (window->prev) {
2755  window->prev->next = window->next;
2756  } else {
2757  _this->windows = window->next;
2758  }
2759 
2760  SDL_free(window);
2761 }
2762 
2763 SDL_bool
2765 {
2766  if (!_this) {
2767  return SDL_TRUE;
2768  }
2769  return _this->suspend_screensaver ? SDL_FALSE : SDL_TRUE;
2770 }
2771 
2772 void
2774 {
2775  if (!_this) {
2776  return;
2777  }
2778  if (!_this->suspend_screensaver) {
2779  return;
2780  }
2781  _this->suspend_screensaver = SDL_FALSE;
2782  if (_this->SuspendScreenSaver) {
2783  _this->SuspendScreenSaver(_this);
2784  }
2785 }
2786 
2787 void
2789 {
2790  if (!_this) {
2791  return;
2792  }
2793  if (_this->suspend_screensaver) {
2794  return;
2795  }
2796  _this->suspend_screensaver = SDL_TRUE;
2797  if (_this->SuspendScreenSaver) {
2798  _this->SuspendScreenSaver(_this);
2799  }
2800 }
2801 
2802 void
2804 {
2805  int i, j;
2806 
2807  if (!_this) {
2808  return;
2809  }
2810 
2811  /* Halt event processing before doing anything else */
2812  SDL_TouchQuit();
2813  SDL_MouseQuit();
2814  SDL_KeyboardQuit();
2816 
2818 
2819  /* Clean up the system video */
2820  while (_this->windows) {
2821  SDL_DestroyWindow(_this->windows);
2822  }
2823  _this->VideoQuit(_this);
2824 
2825  for (i = 0; i < _this->num_displays; ++i) {
2826  SDL_VideoDisplay *display = &_this->displays[i];
2827  for (j = display->num_display_modes; j--;) {
2828  SDL_free(display->display_modes[j].driverdata);
2829  display->display_modes[j].driverdata = NULL;
2830  }
2831  SDL_free(display->display_modes);
2832  display->display_modes = NULL;
2833  SDL_free(display->desktop_mode.driverdata);
2834  display->desktop_mode.driverdata = NULL;
2835  SDL_free(display->driverdata);
2836  display->driverdata = NULL;
2837  }
2838  if (_this->displays) {
2839  for (i = 0; i < _this->num_displays; ++i) {
2840  SDL_free(_this->displays[i].name);
2841  }
2842  SDL_free(_this->displays);
2843  _this->displays = NULL;
2844  _this->num_displays = 0;
2845  }
2846  SDL_free(_this->clipboard_text);
2847  _this->clipboard_text = NULL;
2848  _this->free(_this);
2849  _this = NULL;
2850 }
2851 
2852 int
2854 {
2855  int retval;
2856 
2857  if (!_this) {
2858  return SDL_UninitializedVideo();
2859  }
2860  if (_this->gl_config.driver_loaded) {
2861  if (path && SDL_strcmp(path, _this->gl_config.driver_path) != 0) {
2862  return SDL_SetError("OpenGL library already loaded");
2863  }
2864  retval = 0;
2865  } else {
2866  if (!_this->GL_LoadLibrary) {
2867  return SDL_SetError("No dynamic GL support in current SDL video driver (%s)", _this->name);
2868  }
2869  retval = _this->GL_LoadLibrary(_this, path);
2870  }
2871  if (retval == 0) {
2872  ++_this->gl_config.driver_loaded;
2873  } else {
2874  if (_this->GL_UnloadLibrary) {
2875  _this->GL_UnloadLibrary(_this);
2876  }
2877  }
2878  return (retval);
2879 }
2880 
2881 void *
2882 SDL_GL_GetProcAddress(const char *proc)
2883 {
2884  void *func;
2885 
2886  if (!_this) {
2888  return NULL;
2889  }
2890  func = NULL;
2891  if (_this->GL_GetProcAddress) {
2892  if (_this->gl_config.driver_loaded) {
2893  func = _this->GL_GetProcAddress(_this, proc);
2894  } else {
2895  SDL_SetError("No GL driver has been loaded");
2896  }
2897  } else {
2898  SDL_SetError("No dynamic GL support in current SDL video driver (%s)", _this->name);
2899  }
2900  return func;
2901 }
2902 
2903 void
2905 {
2906  if (!_this) {
2908  return;
2909  }
2910  if (_this->gl_config.driver_loaded > 0) {
2911  if (--_this->gl_config.driver_loaded > 0) {
2912  return;
2913  }
2914  if (_this->GL_UnloadLibrary) {
2915  _this->GL_UnloadLibrary(_this);
2916  }
2917  }
2918 }
2919 
2920 #if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
2921 static SDL_INLINE SDL_bool
2922 isAtLeastGL3(const char *verstr)
2923 {
2924  return (verstr && (SDL_atoi(verstr) >= 3));
2925 }
2926 #endif
2927 
2928 SDL_bool
2929 SDL_GL_ExtensionSupported(const char *extension)
2930 {
2931 #if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
2932  const GLubyte *(APIENTRY * glGetStringFunc) (GLenum);
2933  const char *extensions;
2934  const char *start;
2935  const char *where, *terminator;
2936 
2937  /* Extension names should not have spaces. */
2938  where = SDL_strchr(extension, ' ');
2939  if (where || *extension == '\0') {
2940  return SDL_FALSE;
2941  }
2942  /* See if there's an environment variable override */
2943  start = SDL_getenv(extension);
2944  if (start && *start == '0') {
2945  return SDL_FALSE;
2946  }
2947 
2948  /* Lookup the available extensions */
2949 
2950  glGetStringFunc = SDL_GL_GetProcAddress("glGetString");
2951  if (!glGetStringFunc) {
2952  return SDL_FALSE;
2953  }
2954 
2955  if (isAtLeastGL3((const char *) glGetStringFunc(GL_VERSION))) {
2956  const GLubyte *(APIENTRY * glGetStringiFunc) (GLenum, GLuint);
2957  void (APIENTRY * glGetIntegervFunc) (GLenum pname, GLint * params);
2958  GLint num_exts = 0;
2959  GLint i;
2960 
2961  glGetStringiFunc = SDL_GL_GetProcAddress("glGetStringi");
2962  glGetIntegervFunc = SDL_GL_GetProcAddress("glGetIntegerv");
2963  if ((!glGetStringiFunc) || (!glGetIntegervFunc)) {
2964  return SDL_FALSE;
2965  }
2966 
2967  #ifndef GL_NUM_EXTENSIONS
2968  #define GL_NUM_EXTENSIONS 0x821D
2969  #endif
2970  glGetIntegervFunc(GL_NUM_EXTENSIONS, &num_exts);
2971  for (i = 0; i < num_exts; i++) {
2972  const char *thisext = (const char *) glGetStringiFunc(GL_EXTENSIONS, i);
2973  if (SDL_strcmp(thisext, extension) == 0) {
2974  return SDL_TRUE;
2975  }
2976  }
2977 
2978  return SDL_FALSE;
2979  }
2980 
2981  /* Try the old way with glGetString(GL_EXTENSIONS) ... */
2982 
2983  extensions = (const char *) glGetStringFunc(GL_EXTENSIONS);
2984  if (!extensions) {
2985  return SDL_FALSE;
2986  }
2987  /*
2988  * It takes a bit of care to be fool-proof about parsing the OpenGL
2989  * extensions string. Don't be fooled by sub-strings, etc.
2990  */
2991 
2992  start = extensions;
2993 
2994  for (;;) {
2995  where = SDL_strstr(start, extension);
2996  if (!where)
2997  break;
2998 
2999  terminator = where + SDL_strlen(extension);
3000  if (where == extensions || *(where - 1) == ' ')
3001  if (*terminator == ' ' || *terminator == '\0')
3002  return SDL_TRUE;
3003 
3004  start = terminator;
3005  }
3006  return SDL_FALSE;
3007 #else
3008  return SDL_FALSE;
3009 #endif
3010 }
3011 
3012 /* Deduce supported ES profile versions from the supported
3013  ARB_ES*_compatibility extensions. There is no direct query.
3014 
3015  This is normally only called when the OpenGL driver supports
3016  {GLX,WGL}_EXT_create_context_es2_profile.
3017  */
3018 void
3019 SDL_GL_DeduceMaxSupportedESProfile(int* major, int* minor)
3020 {
3021 /* THIS REQUIRES AN EXISTING GL CONTEXT THAT HAS BEEN MADE CURRENT. */
3022 /* Please refer to https://bugzilla.libsdl.org/show_bug.cgi?id=3725 for discussion. */
3023 #if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
3024  /* XXX This is fragile; it will break in the event of release of
3025  * new versions of OpenGL ES.
3026  */
3027  if (SDL_GL_ExtensionSupported("GL_ARB_ES3_2_compatibility")) {
3028  *major = 3;
3029  *minor = 2;
3030  } else if (SDL_GL_ExtensionSupported("GL_ARB_ES3_1_compatibility")) {
3031  *major = 3;
3032  *minor = 1;
3033  } else if (SDL_GL_ExtensionSupported("GL_ARB_ES3_compatibility")) {
3034  *major = 3;
3035  *minor = 0;
3036  } else {
3037  *major = 2;
3038  *minor = 0;
3039  }
3040 #endif
3041 }
3042 
3043 void
3045 {
3046  if (!_this) {
3047  return;
3048  }
3049 
3050  _this->gl_config.red_size = 3;
3051  _this->gl_config.green_size = 3;
3052  _this->gl_config.blue_size = 2;
3053  _this->gl_config.alpha_size = 0;
3054  _this->gl_config.buffer_size = 0;
3055  _this->gl_config.depth_size = 16;
3056  _this->gl_config.stencil_size = 0;
3057  _this->gl_config.double_buffer = 1;
3058  _this->gl_config.accum_red_size = 0;
3059  _this->gl_config.accum_green_size = 0;
3060  _this->gl_config.accum_blue_size = 0;
3061  _this->gl_config.accum_alpha_size = 0;
3062  _this->gl_config.stereo = 0;
3063  _this->gl_config.multisamplebuffers = 0;
3064  _this->gl_config.multisamplesamples = 0;
3065  _this->gl_config.retained_backing = 1;
3066  _this->gl_config.accelerated = -1; /* accelerated or not, both are fine */
3067 
3068  if (_this->GL_DefaultProfileConfig) {
3069  _this->GL_DefaultProfileConfig(_this, &_this->gl_config.profile_mask,
3070  &_this->gl_config.major_version,
3071  &_this->gl_config.minor_version);
3072  } else {
3073 #if SDL_VIDEO_OPENGL
3074  _this->gl_config.major_version = 2;
3075  _this->gl_config.minor_version = 1;
3076  _this->gl_config.profile_mask = 0;
3077 #elif SDL_VIDEO_OPENGL_ES2
3078  _this->gl_config.major_version = 2;
3079  _this->gl_config.minor_version = 0;
3081 #elif SDL_VIDEO_OPENGL_ES
3082  _this->gl_config.major_version = 1;
3083  _this->gl_config.minor_version = 1;
3085 #endif
3086  }
3087 
3088  _this->gl_config.flags = 0;
3090  _this->gl_config.no_error = 0;
3093 
3095 }
3096 
3097 int
3099 {
3100 #if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
3101  int retval;
3102 
3103  if (!_this) {
3104  return SDL_UninitializedVideo();
3105  }
3106  retval = 0;
3107  switch (attr) {
3108  case SDL_GL_RED_SIZE:
3109  _this->gl_config.red_size = value;
3110  break;
3111  case SDL_GL_GREEN_SIZE:
3112  _this->gl_config.green_size = value;
3113  break;
3114  case SDL_GL_BLUE_SIZE:
3115  _this->gl_config.blue_size = value;
3116  break;
3117  case SDL_GL_ALPHA_SIZE:
3118  _this->gl_config.alpha_size = value;
3119  break;
3120  case SDL_GL_DOUBLEBUFFER:
3121  _this->gl_config.double_buffer = value;
3122  break;
3123  case SDL_GL_BUFFER_SIZE:
3124  _this->gl_config.buffer_size = value;
3125  break;
3126  case SDL_GL_DEPTH_SIZE:
3127  _this->gl_config.depth_size = value;
3128  break;
3129  case SDL_GL_STENCIL_SIZE:
3130  _this->gl_config.stencil_size = value;
3131  break;
3132  case SDL_GL_ACCUM_RED_SIZE:
3133  _this->gl_config.accum_red_size = value;
3134  break;
3136  _this->gl_config.accum_green_size = value;
3137  break;
3139  _this->gl_config.accum_blue_size = value;
3140  break;
3142  _this->gl_config.accum_alpha_size = value;
3143  break;
3144  case SDL_GL_STEREO:
3145  _this->gl_config.stereo = value;
3146  break;
3149  break;
3152  break;
3154  _this->gl_config.accelerated = value;
3155  break;
3157  _this->gl_config.retained_backing = value;
3158  break;
3160  _this->gl_config.major_version = value;
3161  break;
3163  _this->gl_config.minor_version = value;
3164  break;
3165  case SDL_GL_CONTEXT_EGL:
3166  /* FIXME: SDL_GL_CONTEXT_EGL to be deprecated in SDL 2.1 */
3167  if (value != 0) {
3169  } else {
3171  };
3172  break;
3173  case SDL_GL_CONTEXT_FLAGS:
3174  if (value & ~(SDL_GL_CONTEXT_DEBUG_FLAG |
3178  retval = SDL_SetError("Unknown OpenGL context flag %d", value);
3179  break;
3180  }
3181  _this->gl_config.flags = value;
3182  break;
3184  if (value != 0 &&
3185  value != SDL_GL_CONTEXT_PROFILE_CORE &&
3187  value != SDL_GL_CONTEXT_PROFILE_ES) {
3188  retval = SDL_SetError("Unknown OpenGL context profile %d", value);
3189  break;
3190  }
3191  _this->gl_config.profile_mask = value;
3192  break;
3195  break;
3198  break;
3200  _this->gl_config.release_behavior = value;
3201  break;
3204  break;
3206  _this->gl_config.no_error = value;
3207  break;
3208  default:
3209  retval = SDL_SetError("Unknown OpenGL attribute");
3210  break;
3211  }
3212  return retval;
3213 #else
3214  return SDL_Unsupported();
3215 #endif /* SDL_VIDEO_OPENGL */
3216 }
3217 
3218 int
3220 {
3221 #if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
3222  GLenum (APIENTRY *glGetErrorFunc) (void);
3223  GLenum attrib = 0;
3224  GLenum error = 0;
3225 
3226  /*
3227  * Some queries in Core Profile desktop OpenGL 3+ contexts require
3228  * glGetFramebufferAttachmentParameteriv instead of glGetIntegerv. Note that
3229  * the enums we use for the former function don't exist in OpenGL ES 2, and
3230  * the function itself doesn't exist prior to OpenGL 3 and OpenGL ES 2.
3231  */
3232 #if SDL_VIDEO_OPENGL
3233  const GLubyte *(APIENTRY *glGetStringFunc) (GLenum name);
3234  void (APIENTRY *glGetFramebufferAttachmentParameterivFunc) (GLenum target, GLenum attachment, GLenum pname, GLint* params);
3235  GLenum attachment = GL_BACK_LEFT;
3236  GLenum attachmentattrib = 0;
3237 #endif
3238 
3239  if (!value) {
3240  return SDL_InvalidParamError("value");
3241  }
3242 
3243  /* Clear value in any case */
3244  *value = 0;
3245 
3246  if (!_this) {
3247  return SDL_UninitializedVideo();
3248  }
3249 
3250  switch (attr) {
3251  case SDL_GL_RED_SIZE:
3252 #if SDL_VIDEO_OPENGL
3253  attachmentattrib = GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE;
3254 #endif
3255  attrib = GL_RED_BITS;
3256  break;
3257  case SDL_GL_BLUE_SIZE:
3258 #if SDL_VIDEO_OPENGL
3259  attachmentattrib = GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE;
3260 #endif
3261  attrib = GL_BLUE_BITS;
3262  break;
3263  case SDL_GL_GREEN_SIZE:
3264 #if SDL_VIDEO_OPENGL
3265  attachmentattrib = GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE;
3266 #endif
3267  attrib = GL_GREEN_BITS;
3268  break;
3269  case SDL_GL_ALPHA_SIZE:
3270 #if SDL_VIDEO_OPENGL
3271  attachmentattrib = GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE;
3272 #endif
3273  attrib = GL_ALPHA_BITS;
3274  break;
3275  case SDL_GL_DOUBLEBUFFER:
3276 #if SDL_VIDEO_OPENGL
3277  attrib = GL_DOUBLEBUFFER;
3278  break;
3279 #else
3280  /* OpenGL ES 1.0 and above specifications have EGL_SINGLE_BUFFER */
3281  /* parameter which switches double buffer to single buffer. OpenGL ES */
3282  /* SDL driver must set proper value after initialization */
3283  *value = _this->gl_config.double_buffer;
3284  return 0;
3285 #endif
3286  case SDL_GL_DEPTH_SIZE:
3287 #if SDL_VIDEO_OPENGL
3288  attachment = GL_DEPTH;
3289  attachmentattrib = GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE;
3290 #endif
3291  attrib = GL_DEPTH_BITS;
3292  break;
3293  case SDL_GL_STENCIL_SIZE:
3294 #if SDL_VIDEO_OPENGL
3295  attachment = GL_STENCIL;
3296  attachmentattrib = GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE;
3297 #endif
3298  attrib = GL_STENCIL_BITS;
3299  break;
3300 #if SDL_VIDEO_OPENGL
3301  case SDL_GL_ACCUM_RED_SIZE:
3302  attrib = GL_ACCUM_RED_BITS;
3303  break;
3305  attrib = GL_ACCUM_GREEN_BITS;
3306  break;
3308  attrib = GL_ACCUM_BLUE_BITS;
3309  break;
3311  attrib = GL_ACCUM_ALPHA_BITS;
3312  break;
3313  case SDL_GL_STEREO:
3314  attrib = GL_STEREO;
3315  break;
3316 #else
3317  case SDL_GL_ACCUM_RED_SIZE:
3321  case SDL_GL_STEREO:
3322  /* none of these are supported in OpenGL ES */
3323  *value = 0;
3324  return 0;
3325 #endif
3327  attrib = GL_SAMPLE_BUFFERS;
3328  break;
3330  attrib = GL_SAMPLES;
3331  break;
3333 #if SDL_VIDEO_OPENGL
3334  attrib = GL_CONTEXT_RELEASE_BEHAVIOR;
3335 #else
3337 #endif
3338  break;
3339  case SDL_GL_BUFFER_SIZE:
3340  {
3341  int rsize = 0, gsize = 0, bsize = 0, asize = 0;
3342 
3343  /* There doesn't seem to be a single flag in OpenGL for this! */
3344  if (SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &rsize) < 0) {
3345  return -1;
3346  }
3347  if (SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &gsize) < 0) {
3348  return -1;
3349  }
3350  if (SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &bsize) < 0) {
3351  return -1;
3352  }
3353  if (SDL_GL_GetAttribute(SDL_GL_ALPHA_SIZE, &asize) < 0) {
3354  return -1;
3355  }
3356 
3357  *value = rsize + gsize + bsize + asize;
3358  return 0;
3359  }
3361  {
3362  /* FIXME: How do we get this information? */
3363  *value = (_this->gl_config.accelerated != 0);
3364  return 0;
3365  }
3367  {
3368  *value = _this->gl_config.retained_backing;
3369  return 0;
3370  }
3372  {
3373  *value = _this->gl_config.major_version;
3374  return 0;
3375  }
3377  {
3378  *value = _this->gl_config.minor_version;
3379  return 0;
3380  }
3381  case SDL_GL_CONTEXT_EGL:
3382  /* FIXME: SDL_GL_CONTEXT_EGL to be deprecated in SDL 2.1 */
3383  {
3385  *value = 1;
3386  }
3387  else {
3388  *value = 0;
3389  }
3390  return 0;
3391  }
3392  case SDL_GL_CONTEXT_FLAGS:
3393  {
3394  *value = _this->gl_config.flags;
3395  return 0;
3396  }
3398  {
3399  *value = _this->gl_config.profile_mask;
3400  return 0;
3401  }
3403  {
3404  *value = _this->gl_config.share_with_current_context;
3405  return 0;
3406  }
3408  {
3409  *value = _this->gl_config.framebuffer_srgb_capable;
3410  return 0;
3411  }
3413  {
3414  *value = _this->gl_config.no_error;
3415  return 0;
3416  }
3417  default:
3418  return SDL_SetError("Unknown OpenGL attribute");
3419  }
3420 
3421 #if SDL_VIDEO_OPENGL
3422  glGetStringFunc = SDL_GL_GetProcAddress("glGetString");
3423  if (!glGetStringFunc) {
3424  return -1;
3425  }
3426 
3427  if (attachmentattrib && isAtLeastGL3((const char *) glGetStringFunc(GL_VERSION))) {
3428  glGetFramebufferAttachmentParameterivFunc = SDL_GL_GetProcAddress("glGetFramebufferAttachmentParameteriv");
3429 
3430  if (glGetFramebufferAttachmentParameterivFunc) {
3431  glGetFramebufferAttachmentParameterivFunc(GL_FRAMEBUFFER, attachment, attachmentattrib, (GLint *) value);
3432  } else {
3433  return -1;
3434  }
3435  } else
3436 #endif
3437  {
3438  void (APIENTRY *glGetIntegervFunc) (GLenum pname, GLint * params);
3439  glGetIntegervFunc = SDL_GL_GetProcAddress("glGetIntegerv");
3440  if (glGetIntegervFunc) {
3441  glGetIntegervFunc(attrib, (GLint *) value);
3442  } else {
3443  return -1;
3444  }
3445  }
3446 
3447  glGetErrorFunc = SDL_GL_GetProcAddress("glGetError");
3448  if (!glGetErrorFunc) {
3449  return -1;
3450  }
3451 
3452  error = glGetErrorFunc();
3453  if (error != GL_NO_ERROR) {
3454  if (error == GL_INVALID_ENUM) {
3455  return SDL_SetError("OpenGL error: GL_INVALID_ENUM");
3456  } else if (error == GL_INVALID_VALUE) {
3457  return SDL_SetError("OpenGL error: GL_INVALID_VALUE");
3458  }
3459  return SDL_SetError("OpenGL error: %08X", error);
3460  }
3461  return 0;
3462 #else
3463  return SDL_Unsupported();
3464 #endif /* SDL_VIDEO_OPENGL */
3465 }
3466 
3469 {
3471  CHECK_WINDOW_MAGIC(window, NULL);
3472 
3473  if (!(window->flags & SDL_WINDOW_OPENGL)) {
3474  SDL_SetError("The specified window isn't an OpenGL window");
3475  return NULL;
3476  }
3477 
3478  ctx = _this->GL_CreateContext(_this, window);
3479 
3480  /* Creating a context is assumed to make it current in the SDL driver. */
3481  if (ctx) {
3482  _this->current_glwin = window;
3483  _this->current_glctx = ctx;
3484  SDL_TLSSet(_this->current_glwin_tls, window, NULL);
3485  SDL_TLSSet(_this->current_glctx_tls, ctx, NULL);
3486  }
3487  return ctx;
3488 }
3489 
3490 int
3492 {
3493  int retval;
3494 
3495  if (window == SDL_GL_GetCurrentWindow() &&
3496  ctx == SDL_GL_GetCurrentContext()) {
3497  /* We're already current. */
3498  return 0;
3499  }
3500 
3501  if (!ctx) {
3502  window = NULL;
3503  } else {
3504  CHECK_WINDOW_MAGIC(window, -1);
3505 
3506  if (!(window->flags & SDL_WINDOW_OPENGL)) {
3507  return SDL_SetError("The specified window isn't an OpenGL window");
3508  }
3509  }
3510 
3511  retval = _this->GL_MakeCurrent(_this, window, ctx);
3512  if (retval == 0) {
3513  _this->current_glwin = window;
3514  _this->current_glctx = ctx;
3515  SDL_TLSSet(_this->current_glwin_tls, window, NULL);
3516  SDL_TLSSet(_this->current_glctx_tls, ctx, NULL);
3517  }
3518  return retval;
3519 }
3520 
3521 SDL_Window *
3523 {
3524  if (!_this) {
3526  return NULL;
3527  }
3528  return (SDL_Window *)SDL_TLSGet(_this->current_glwin_tls);
3529 }
3530 
3533 {
3534  if (!_this) {
3536  return NULL;
3537  }
3538  return (SDL_GLContext)SDL_TLSGet(_this->current_glctx_tls);
3539 }
3540 
3541 void SDL_GL_GetDrawableSize(SDL_Window * window, int *w, int *h)
3542 {
3543  CHECK_WINDOW_MAGIC(window,);
3544 
3545  if (_this->GL_GetDrawableSize) {
3546  _this->GL_GetDrawableSize(_this, window, w, h);
3547  } else {
3548  SDL_GetWindowSize(window, w, h);
3549  }
3550 }
3551 
3552 int
3554 {
3555  if (!_this) {
3556  return SDL_UninitializedVideo();
3557  } else if (SDL_GL_GetCurrentContext() == NULL) {
3558  return SDL_SetError("No OpenGL context has been made current");
3559  } else if (_this->GL_SetSwapInterval) {
3560  return _this->GL_SetSwapInterval(_this, interval);
3561  } else {
3562  return SDL_SetError("Setting the swap interval is not supported");
3563  }
3564 }
3565 
3566 int
3568 {
3569  if (!_this) {
3570  return 0;
3571  } else if (SDL_GL_GetCurrentContext() == NULL) {
3572  return 0;
3573  } else if (_this->GL_GetSwapInterval) {
3574  return _this->GL_GetSwapInterval(_this);
3575  } else {
3576  return 0;
3577  }
3578 }
3579 
3580 void
3582 {
3583  CHECK_WINDOW_MAGIC(window,);
3584 
3585  if (!(window->flags & SDL_WINDOW_OPENGL)) {
3586  SDL_SetError("The specified window isn't an OpenGL window");
3587  return;
3588  }
3589 
3590  if (SDL_GL_GetCurrentWindow() != window) {
3591  SDL_SetError("The specified window has not been made current");
3592  return;
3593  }
3594 
3595  _this->GL_SwapWindow(_this, window);
3596 }
3597 
3598 void
3600 {
3601  if (!_this || !context) {
3602  return;
3603  }
3604 
3605  if (SDL_GL_GetCurrentContext() == context) {
3607  }
3608 
3609  _this->GL_DeleteContext(_this, context);
3610 }
3611 
3612 #if 0 /* FIXME */
3613 /*
3614  * Utility function used by SDL_WM_SetIcon(); flags & 1 for color key, flags
3615  * & 2 for alpha channel.
3616  */
3617 static void
3618 CreateMaskFromColorKeyOrAlpha(SDL_Surface * icon, Uint8 * mask, int flags)
3619 {
3620  int x, y;
3621  Uint32 colorkey;
3622 #define SET_MASKBIT(icon, x, y, mask) \
3623  mask[(y*((icon->w+7)/8))+(x/8)] &= ~(0x01<<(7-(x%8)))
3624 
3625  colorkey = icon->format->colorkey;
3626  switch (icon->format->BytesPerPixel) {
3627  case 1:
3628  {
3629  Uint8 *pixels;
3630  for (y = 0; y < icon->h; ++y) {
3631  pixels = (Uint8 *) icon->pixels + y * icon->pitch;
3632  for (x = 0; x < icon->w; ++x) {
3633  if (*pixels++ == colorkey) {
3634  SET_MASKBIT(icon, x, y, mask);
3635  }
3636  }
3637  }
3638  }
3639  break;
3640 
3641  case 2:
3642  {
3643  Uint16 *pixels;
3644  for (y = 0; y < icon->h; ++y) {
3645  pixels = (Uint16 *) icon->pixels + y * icon->pitch / 2;
3646  for (x = 0; x < icon->w; ++x) {
3647  if ((flags & 1) && *pixels == colorkey) {
3648  SET_MASKBIT(icon, x, y, mask);
3649  } else if ((flags & 2)
3650  && (*pixels & icon->format->Amask) == 0) {
3651  SET_MASKBIT(icon, x, y, mask);
3652  }
3653  pixels++;
3654  }
3655  }
3656  }
3657  break;
3658 
3659  case 4:
3660  {
3661  Uint32 *pixels;
3662  for (y = 0; y < icon->h; ++y) {
3663  pixels = (Uint32 *) icon->pixels + y * icon->pitch / 4;
3664  for (x = 0; x < icon->w; ++x) {
3665  if ((flags & 1) && *pixels == colorkey) {
3666  SET_MASKBIT(icon, x, y, mask);
3667  } else if ((flags & 2)
3668  && (*pixels & icon->format->Amask) == 0) {
3669  SET_MASKBIT(icon, x, y, mask);
3670  }
3671  pixels++;
3672  }
3673  }
3674  }
3675  break;
3676  }
3677 }
3678 
3679 /*
3680  * Sets the window manager icon for the display window.
3681  */
3682 void
3683 SDL_WM_SetIcon(SDL_Surface * icon, Uint8 * mask)
3684 {
3685  if (icon && _this->SetIcon) {
3686  /* Generate a mask if necessary, and create the icon! */
3687  if (mask == NULL) {
3688  int mask_len = icon->h * (icon->w + 7) / 8;
3689  int flags = 0;
3690  mask = (Uint8 *) SDL_malloc(mask_len);
3691  if (mask == NULL) {
3692  return;
3693  }
3694  SDL_memset(mask, ~0, mask_len);
3695  if (icon->flags & SDL_SRCCOLORKEY)
3696  flags |= 1;
3697  if (icon->flags & SDL_SRCALPHA)
3698  flags |= 2;
3699  if (flags) {
3700  CreateMaskFromColorKeyOrAlpha(icon, mask, flags);
3701  }
3702  _this->SetIcon(_this, icon, mask);
3703  SDL_free(mask);
3704  } else {
3705  _this->SetIcon(_this, icon, mask);
3706  }
3707  }
3708 }
3709 #endif
3710 
3711 SDL_bool
3713 {
3714  CHECK_WINDOW_MAGIC(window, SDL_FALSE);
3715 
3716  if (!info) {
3717  SDL_InvalidParamError("info");
3718  return SDL_FALSE;
3719  }
3720  info->subsystem = SDL_SYSWM_UNKNOWN;
3721 
3722  if (!_this->GetWindowWMInfo) {
3723  SDL_Unsupported();
3724  return SDL_FALSE;
3725  }
3726  return (_this->GetWindowWMInfo(_this, window, info));
3727 }
3728 
3729 void
3731 {
3732  SDL_Window *window;
3733 
3734  /* First, enable text events */
3737 
3738  /* Then show the on-screen keyboard, if any */
3739  window = SDL_GetFocusWindow();
3740  if (window && _this && _this->ShowScreenKeyboard) {
3741  _this->ShowScreenKeyboard(_this, window);
3742  }
3743 
3744  /* Finally start the text input system */
3745  if (_this && _this->StartTextInput) {
3746  _this->StartTextInput(_this);
3747  }
3748 }
3749 
3750 SDL_bool
3752 {
3754 }
3755 
3756 void
3758 {
3759  SDL_Window *window;
3760 
3761  /* Stop the text input system */
3762  if (_this && _this->StopTextInput) {
3763  _this->StopTextInput(_this);
3764  }
3765 
3766  /* Hide the on-screen keyboard, if any */
3767  window = SDL_GetFocusWindow();
3768  if (window && _this && _this->HideScreenKeyboard) {
3769  _this->HideScreenKeyboard(_this, window);
3770  }
3771 
3772  /* Finally disable text events */
3775 }
3776 
3777 void
3779 {
3780  if (_this && _this->SetTextInputRect) {
3781  _this->SetTextInputRect(_this, rect);
3782  }
3783 }
3784 
3785 SDL_bool
3787 {
3788  if (_this && _this->HasScreenKeyboardSupport) {
3789  return _this->HasScreenKeyboardSupport(_this);
3790  }
3791  return SDL_FALSE;
3792 }
3793 
3794 SDL_bool
3796 {
3797  if (window && _this && _this->IsScreenKeyboardShown) {
3798  return _this->IsScreenKeyboardShown(_this, window);
3799  }
3800  return SDL_FALSE;
3801 }
3802 
3803 #if SDL_VIDEO_DRIVER_ANDROID
3805 #endif
3806 #if SDL_VIDEO_DRIVER_WINDOWS
3808 #endif
3809 #if SDL_VIDEO_DRIVER_WINRT
3810 #include "winrt/SDL_winrtmessagebox.h"
3811 #endif
3812 #if SDL_VIDEO_DRIVER_COCOA
3813 #include "cocoa/SDL_cocoamessagebox.h"
3814 #endif
3815 #if SDL_VIDEO_DRIVER_UIKIT
3816 #include "uikit/SDL_uikitmessagebox.h"
3817 #endif
3818 #if SDL_VIDEO_DRIVER_X11
3819 #include "x11/SDL_x11messagebox.h"
3820 #endif
3821 
3822 
3823 #if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_WINRT || SDL_VIDEO_DRIVER_COCOA || SDL_VIDEO_DRIVER_UIKIT || SDL_VIDEO_DRIVER_X11
3825 {
3826  SDL_SysWMinfo info;
3827  SDL_Window *window = messageboxdata->window;
3828 
3829  if (!window) {
3830  return SDL_TRUE;
3831  }
3832 
3833  SDL_VERSION(&info.version);
3834  if (!SDL_GetWindowWMInfo(window, &info)) {
3835  return SDL_TRUE;
3836  } else {
3837  return (info.subsystem == drivertype);
3838  }
3839 }
3840 #endif
3841 
3842 int
3843 SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
3844 {
3845  int dummybutton;
3846  int retval = -1;
3847  SDL_bool relative_mode;
3848  int show_cursor_prev;
3849  SDL_bool mouse_captured;
3850  SDL_Window *current_window;
3851 
3852  if (!messageboxdata) {
3853  return SDL_InvalidParamError("messageboxdata");
3854  } else if (messageboxdata->numbuttons < 0) {
3855  return SDL_SetError("Invalid number of buttons");
3856  }
3857 
3858  current_window = SDL_GetKeyboardFocus();
3859  mouse_captured = current_window && ((SDL_GetWindowFlags(current_window) & SDL_WINDOW_MOUSE_CAPTURE) != 0);
3860  relative_mode = SDL_GetRelativeMouseMode();
3863  show_cursor_prev = SDL_ShowCursor(1);
3865 
3866  if (!buttonid) {
3867  buttonid = &dummybutton;
3868  }
3869 
3870  if (_this && _this->ShowMessageBox) {
3871  retval = _this->ShowMessageBox(_this, messageboxdata, buttonid);
3872  }
3873 
3874  /* It's completely fine to call this function before video is initialized */
3875 #if SDL_VIDEO_DRIVER_ANDROID
3876  if (retval == -1 &&
3877  Android_ShowMessageBox(messageboxdata, buttonid) == 0) {
3878  retval = 0;
3879  }
3880 #endif
3881 #if SDL_VIDEO_DRIVER_WINDOWS
3882  if (retval == -1 &&
3884  WIN_ShowMessageBox(messageboxdata, buttonid) == 0) {
3885  retval = 0;
3886  }
3887 #endif
3888 #if SDL_VIDEO_DRIVER_WINRT
3889  if (retval == -1 &&
3890  SDL_MessageboxValidForDriver(messageboxdata, SDL_SYSWM_WINRT) &&
3891  WINRT_ShowMessageBox(messageboxdata, buttonid) == 0) {
3892  retval = 0;
3893  }
3894 #endif
3895 #if SDL_VIDEO_DRIVER_COCOA
3896  if (retval == -1 &&
3897  SDL_MessageboxValidForDriver(messageboxdata, SDL_SYSWM_COCOA) &&
3898  Cocoa_ShowMessageBox(messageboxdata, buttonid) == 0) {
3899  retval = 0;
3900  }
3901 #endif
3902 #if SDL_VIDEO_DRIVER_UIKIT
3903  if (retval == -1 &&
3904  SDL_MessageboxValidForDriver(messageboxdata, SDL_SYSWM_UIKIT) &&
3905  UIKit_ShowMessageBox(messageboxdata, buttonid) == 0) {
3906  retval = 0;
3907  }
3908 #endif
3909 #if SDL_VIDEO_DRIVER_X11
3910  if (retval == -1 &&
3911  SDL_MessageboxValidForDriver(messageboxdata, SDL_SYSWM_X11) &&
3912  X11_ShowMessageBox(messageboxdata, buttonid) == 0) {
3913  retval = 0;
3914  }
3915 #endif
3916  if (retval == -1) {
3917  SDL_SetError("No message system available");
3918  }
3919 
3920  if (current_window) {
3921  SDL_RaiseWindow(current_window);
3922  if (mouse_captured) {
3924  }
3925  }
3926 
3927  SDL_ShowCursor(show_cursor_prev);
3928  SDL_SetRelativeMouseMode(relative_mode);
3929 
3930  return retval;
3931 }
3932 
3933 int
3934 SDL_ShowSimpleMessageBox(Uint32 flags, const char *title, const char *message, SDL_Window *window)
3935 {
3936 #ifdef __EMSCRIPTEN__
3937  /* !!! FIXME: propose a browser API for this, get this #ifdef out of here? */
3938  /* Web browsers don't (currently) have an API for a custom message box
3939  that can block, but for the most common case (SDL_ShowSimpleMessageBox),
3940  we can use the standard Javascript alert() function. */
3941  EM_ASM_({
3942  alert(UTF8ToString($0) + "\n\n" + UTF8ToString($1));
3943  }, title, message);
3944  return 0;
3945 #else
3948 
3949  SDL_zero(data);
3950  data.flags = flags;
3951  data.title = title;
3952  data.message = message;
3953  data.numbuttons = 1;
3954  data.buttons = &button;
3955  data.window = window;
3956 
3957  SDL_zero(button);
3960  button.text = "OK";
3961 
3962  return SDL_ShowMessageBox(&data, NULL);
3963 #endif
3964 }
3965 
3966 SDL_bool
3968 {
3970 }
3971 
3972 int
3974 {
3975  CHECK_WINDOW_MAGIC(window, -1);
3976 
3977  if (!_this->SetWindowHitTest) {
3978  return SDL_Unsupported();
3979  } else if (_this->SetWindowHitTest(window, callback != NULL) == -1) {
3980  return -1;
3981  }
3982 
3983  window->hit_test = callback;
3984  window->hit_test_data = userdata;
3985 
3986  return 0;
3987 }
3988 
3989 float
3990 SDL_ComputeDiagonalDPI(int hpix, int vpix, float hinches, float vinches)
3991 {
3992  float den2 = hinches * hinches + vinches * vinches;
3993  if (den2 <= 0.0f) {
3994  return 0.0f;
3995  }
3996 
3997  return (float)(SDL_sqrt((double)hpix * (double)hpix + (double)vpix * (double)vpix) /
3998  SDL_sqrt((double)den2));
3999 }
4000 
4001 /*
4002  * Functions used by iOS application delegates
4003  */
4005 {
4007 }
4008 
4010 {
4012 }
4013 
4015 {
4016  if (_this) {
4017  SDL_Window *window;
4018  for (window = _this->windows; window != NULL; window = window->next) {
4021  }
4022  }
4024 }
4025 
4027 {
4029 }
4030 
4032 {
4034 }
4035 
4037 {
4039 
4040  if (_this) {
4041  SDL_Window *window;
4042  for (window = _this->windows; window != NULL; window = window->next) {
4045  }
4046  }
4047 }
4048 
4049 #define NOT_A_VULKAN_WINDOW "The specified window isn't a Vulkan window"
4050 
4052 {
4053  int retval;
4054  if (!_this) {
4056  return -1;
4057  }
4058  if (_this->vulkan_config.loader_loaded) {
4059  if (path && SDL_strcmp(path, _this->vulkan_config.loader_path) != 0) {
4060  return SDL_SetError("Vulkan loader library already loaded");
4061  }
4062  retval = 0;
4063  } else {
4064  if (!_this->Vulkan_LoadLibrary) {
4065  return SDL_SetError("Vulkan support is either not configured in SDL "
4066  "or not available in current SDL video driver "
4067  "(%s) or platform", _this->name);
4068  }
4069  retval = _this->Vulkan_LoadLibrary(_this, path);
4070  }
4071  if (retval == 0) {
4072  _this->vulkan_config.loader_loaded++;
4073  }
4074  return retval;
4075 }
4076 
4078 {
4079  if (!_this) {
4081  return NULL;
4082  }
4083  if (!_this->vulkan_config.loader_loaded) {
4084  SDL_SetError("No Vulkan loader has been loaded");
4085  return NULL;
4086  }
4087  return _this->vulkan_config.vkGetInstanceProcAddr;
4088 }
4089 
4091 {
4092  if (!_this) {
4094  return;
4095  }
4096  if (_this->vulkan_config.loader_loaded > 0) {
4097  if (--_this->vulkan_config.loader_loaded > 0) {
4098  return;
4099  }
4100  if (_this->Vulkan_UnloadLibrary) {
4101  _this->Vulkan_UnloadLibrary(_this);
4102  }
4103  }
4104 }
4105 
4107 {
4108  if (window) {
4109  CHECK_WINDOW_MAGIC(window, SDL_FALSE);
4110 
4111  if (!(window->flags & SDL_WINDOW_VULKAN))
4112  {
4114  return SDL_FALSE;
4115  }
4116  }
4117 
4118  if (!count) {
4119  SDL_InvalidParamError("count");
4120  return SDL_FALSE;
4121  }
4122 
4123  return _this->Vulkan_GetInstanceExtensions(_this, window, count, names);
4124 }
4125 
4127  VkInstance instance,
4128  VkSurfaceKHR *surface)
4129 {
4130  CHECK_WINDOW_MAGIC(window, SDL_FALSE);
4131 
4132  if (!(window->flags & SDL_WINDOW_VULKAN)) {
4134  return SDL_FALSE;
4135  }
4136 
4137  if (!instance) {
4138  SDL_InvalidParamError("instance");
4139  return SDL_FALSE;
4140  }
4141 
4142  if (!surface) {
4143  SDL_InvalidParamError("surface");
4144  return SDL_FALSE;
4145  }
4146 
4147  return _this->Vulkan_CreateSurface(_this, window, instance, surface);
4148 }
4149 
4150 void SDL_Vulkan_GetDrawableSize(SDL_Window * window, int *w, int *h)
4151 {
4152  CHECK_WINDOW_MAGIC(window,);
4153 
4154  if (_this->Vulkan_GetDrawableSize) {
4155  _this->Vulkan_GetDrawableSize(_this, window, w, h);
4156  } else {
4157  SDL_GetWindowSize(window, w, h);
4158  }
4159 }
4160 
4161 /* vi: set ts=4 sw=4 expandtab: */
#define SDL_CreateTexture
#define SDL_TLSSet
#define SDL_WINDOWPOS_ISUNDEFINED(X)
Definition: SDL_video.h:131
int(* Vulkan_LoadLibrary)(_THIS, const char *path)
Definition: SDL_sysvideo.h:271
SDL_Window * next
Definition: SDL_sysvideo.h:114
static int SDL_GetNumDisplayModesForDisplay(SDL_VideoDisplay *display)
Definition: SDL_video.c:790
#define GL_STENCIL_BITS
Definition: SDL_opengl.h:474
void SDL_GL_ResetAttributes()
Reset all previously set OpenGL context attributes to their default values.
Definition: SDL_video.c:3044
SDL_Window * SDL_GetFocusWindow(void)
Definition: SDL_video.c:2671
const char * name
Definition: SDL_sysvideo.h:152
const char * message
#define SDL_RenderSetViewport
void * SDL_GetWindowData(SDL_Window *window, const char *name)
Retrieve the data pointer associated with a window.
Definition: SDL_video.c:1839
void SDL_OnWindowShown(SDL_Window *window)
Definition: SDL_video.c:2566
int(* GetDisplayDPI)(_THIS, SDL_VideoDisplay *display, float *ddpi, float *hdpi, float *vdpi)
Definition: SDL_sysvideo.h:192
#define SDL_INIT_EVENTS
Definition: SDL.h:83
#define SDL_ConvertSurfaceFormat
#define GL_INVALID_ENUM
Definition: SDL_opengl.h:720
void SDL_OnWindowLeave(SDL_Window *window)
Definition: SDL_video.c:2615
#define GL_SAMPLE_BUFFERS
Definition: SDL_opengl.h:1839
int SDL_GetNumVideoDrivers(void)
Get the number of video drivers compiled into SDL.
Definition: SDL_video.c:446
SDL_Mouse * SDL_GetMouse(void)
Definition: SDL_mouse.c:144
void SDL_OnWindowFocusGained(SDL_Window *window)
Definition: SDL_video.c:2620
VideoBootStrap X11_bootstrap
void(* RestoreWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:228
#define GL_BACK_LEFT
Definition: SDL_opengl.h:499
#define SDL_min(x, y)
Definition: SDL_stdinc.h:406
#define SDL_qsort
SDL_Texture * button
const char * SDL_GetWindowTitle(SDL_Window *window)
Get the title of a window, in UTF-8 format.
Definition: SDL_video.c:1762
void SDL_SetWindowSize(SDL_Window *window, int w, int h)
Set the size of a window&#39;s client area.
Definition: SDL_video.c:1983
void SDL_SetKeyboardFocus(SDL_Window *window)
Definition: SDL_keyboard.c:630
SDL_DisplayMode fullscreen_mode
Definition: SDL_sysvideo.h:89
#define GL_DOUBLEBUFFER
Definition: SDL_opengl.h:521
void SDL_GL_GetDrawableSize(SDL_Window *window, int *w, int *h)
Get the size of a window&#39;s underlying drawable in pixels (for use with glViewport).
Definition: SDL_video.c:3541
GLdouble GLdouble right
#define GL_VENDOR
Definition: SDL_opengl.h:713
int(* SetWindowHitTest)(SDL_Window *window, SDL_bool enabled)
Definition: SDL_sysvideo.h:306
const char * title
SDL_Window * window
#define SDL_PIXELLAYOUT(X)
Definition: SDL_pixels.h:126
void SDL_OnApplicationDidReceiveMemoryWarning(void)
Definition: SDL_video.c:4009
void * hit_test_data
Definition: SDL_sysvideo.h:107
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
VideoBootStrap KMSDRM_bootstrap
GLuint GLsizei const GLchar * message
void SDL_VideoQuit(void)
Shuts down the video subsystem.
Definition: SDL_video.c:2803
#define FULLSCREEN_VISIBLE(W)
Definition: SDL_sysvideo.h:116
GLuint GLuint * names
Uint8 BytesPerPixel
Definition: SDL_pixels.h:320
SDL_bool(* IsScreenKeyboardShown)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:295
SDL_bool SDL_IsScreenKeyboardShown(SDL_Window *window)
Returns whether the screen keyboard is shown for given window.
Definition: SDL_video.c:3795
void SDL_OnApplicationWillEnterForeground(void)
Definition: SDL_video.c:4031
int SDL_GetDisplayMode(int displayIndex, int index, SDL_DisplayMode *mode)
Fill in information about a specific display mode.
Definition: SDL_video.c:809
const void * magic
Definition: SDL_sysvideo.h:75
GLuint GLuint GLsizei count
Definition: SDL_opengl.h:1571
SDL_Texture * texture
Definition: SDL_video.c:162
SDL_Rect rect
Definition: testrelative.c:27
VideoBootStrap MIR_bootstrap
void SDL_ShowWindow(SDL_Window *window)
Show a window.
Definition: SDL_video.c:2150
SDL_TLSID current_glwin_tls
Definition: SDL_sysvideo.h:365
VideoBootStrap Wayland_bootstrap
static int available()
Definition: video.c:356
#define NOT_A_VULKAN_WINDOW
Definition: SDL_video.c:4049
#define SDL_GetNumRenderDrivers
SDL_SYSWM_TYPE
Definition: SDL_syswm.h:116
void(* free)(_THIS)
Definition: SDL_sysvideo.h:394
int SDL_GL_SetSwapInterval(int interval)
Set the swap interval for the current OpenGL context.
Definition: SDL_video.c:3553
#define SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS
Minimize your SDL_Window if it loses key focus when in fullscreen mode. Defaults to true...
Definition: SDL_hints.h:322
GLfloat GLfloat GLfloat GLfloat h
#define SDL_HINT_VIDEO_ALLOW_SCREENSAVER
A variable controlling whether the screensaver is enabled.
Definition: SDL_hints.h:165
static void SDL_RestoreMousePosition(SDL_Window *window)
Definition: SDL_video.c:1171
int SDL_UpdateWindowSurfaceRects(SDL_Window *window, const SDL_Rect *rects, int numrects)
Copy a number of rectangles on the window surface to the screen.
Definition: SDL_video.c:2326
#define SDL_QuitSubSystem
#define SDL_HINT_VIDEO_HIGHDPI_DISABLED
If set to 1, then do not allow high-DPI windows. ("Retina" on Mac and iOS)
Definition: SDL_hints.h:632
struct xkb_state * state
#define APIENTRY
Definition: SDL_opengl.h:139
EGLSurface surface
Definition: eglext.h:248
#define GL_RED_BITS
Definition: SDL_opengl.h:513
int SDL_GL_LoadLibrary(const char *path)
Dynamically load an OpenGL library.
Definition: SDL_video.c:2853
The structure that defines a point.
Definition: SDL_rect.h:48
int GLint
Definition: SDL_opengl.h:182
A collection of pixels used in software blitting.
Definition: SDL_surface.h:69
int(* GL_SetSwapInterval)(_THIS, int interval)
Definition: SDL_sysvideo.h:261
#define GL_CONTEXT_RELEASE_BEHAVIOR
SDL_bool SDL_IsScreenSaverEnabled()
Returns whether the screensaver is currently enabled (default off).
Definition: SDL_video.c:2764
void SDL_GetWindowPosition(SDL_Window *window, int *x, int *y)
Get the position of a window.
Definition: SDL_video.c:1905
void SDL_SetWindowTitle(SDL_Window *window, const char *title)
Set the title of a window, in UTF-8 format.
Definition: SDL_video.c:1745
void SDL_GL_DeleteContext(SDL_GLContext context)
Delete an OpenGL context.
Definition: SDL_video.c:3599
#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE
void(* ShowWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:223
#define SDL_DONTFREE
Definition: SDL_surface.h:55
Uint32 texture_formats[16]
Definition: SDL_render.h:83
uint8_t Uint8
Definition: SDL_stdinc.h:179
static screen_context_t context
Definition: video.c:25
The structure that defines a display mode.
Definition: SDL_video.h:53
#define SDL_GetHint
int SDL_SetWindowInputFocus(SDL_Window *window)
Explicitly sets input focus to the window.
Definition: SDL_video.c:2412
SDL_version version
Definition: SDL_syswm.h:196
VideoBootStrap DirectFB_bootstrap
#define SDL_itoa
void SDL_SetWindowGrab(SDL_Window *window, SDL_bool grabbed)
Set a window&#39;s input grab mode.
Definition: SDL_video.c:2535
#define SDL_ENABLE
Definition: SDL_events.h:756
#define SDL_WINDOWPOS_ISCENTERED(X)
Definition: SDL_video.h:140
SDL_HitTestResult(* SDL_HitTest)(SDL_Window *win, const SDL_Point *area, void *data)
Callback used for hit-testing.
Definition: SDL_video.h:1039
void(* StartTextInput)(_THIS)
Definition: SDL_sysvideo.h:287
GLbyte green
void SDL_OnWindowMinimized(SDL_Window *window)
Definition: SDL_video.c:2585
GLint GLint bottom
void(* SetWindowSize)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:216
GLfloat f
#define SDL_BYTESPERPIXEL(X)
Definition: SDL_pixels.h:128
#define SDL_InitSubSystem
#define GL_EXTENSIONS
Definition: SDL_opengl.h:716
SDL_Window * SDL_GetWindowFromID(Uint32 id)
Get a window from a stored ID, or NULL if it doesn&#39;t exist.
Definition: SDL_video.c:1721
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: SDL_opengl.h:1974
GLuint start
Definition: SDL_opengl.h:1571
SDL_bool is_destroying
Definition: SDL_sysvideo.h:101
#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE
int(* GetWindowBordersSize)(_THIS, SDL_Window *window, int *top, int *left, int *bottom, int *right)
Definition: SDL_sysvideo.h:219
SDL_SYSWM_TYPE subsystem
Definition: SDL_syswm.h:197
void SDL_GL_DeduceMaxSupportedESProfile(int *major, int *minor)
Definition: SDL_video.c:3019
void SDL_SetWindowMinimumSize(SDL_Window *window, int min_w, int min_h)
Set the minimum size of a window&#39;s client area.
Definition: SDL_video.c:2065
#define GL_SAMPLES
Definition: SDL_opengl.h:1840
#define GL_DEPTH_BITS
Definition: SDL_opengl.h:328
int SDL_SetWindowBrightness(SDL_Window *window, float brightness)
Set the brightness (gamma correction) for a window.
Definition: SDL_video.c:2339
int SDL_SendWindowEvent(SDL_Window *window, Uint8 windowevent, int data1, int data2)
#define SDL_SetRelativeMouseMode
float SDL_GetWindowBrightness(SDL_Window *window)
Get the brightness (gamma correction) for a window.
Definition: SDL_video.c:2355
int SDL_GetWindowOpacity(SDL_Window *window, float *out_opacity)
Get the opacity of a window.
Definition: SDL_video.c:2387
#define SDL_ISPIXELFORMAT_ALPHA(format)
Definition: SDL_pixels.h:154
VideoBootStrap Emscripten_bootstrap
SDL_bool is_dummy
Definition: SDL_sysvideo.h:313
void SDL_SetMouseFocus(SDL_Window *window)
Definition: SDL_mouse.c:177
int SDL_SetWindowHitTest(SDL_Window *window, SDL_HitTest callback, void *userdata)
Provide a callback that decides if a window region has special properties.
Definition: SDL_video.c:3973
int SDL_KeyboardInit(void)
Definition: SDL_keyboard.c:562
Uint16 * saved_gamma
Definition: SDL_sysvideo.h:95
void SDL_HideWindow(SDL_Window *window)
Hide a window.
Definition: SDL_video.c:2165
#define SDL_GetKeyboardFocus
#define GL_VERSION
Definition: SDL_opengl.h:715
#define SDL_InvalidParamError(param)
Definition: SDL_error.h:54
#define SDL_realloc
#define SDL_strcasecmp
#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE
GLenum src
const char * name
Definition: SDL_render.h:80
uint32_t Uint32
Definition: SDL_stdinc.h:203
#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE
#define SDL_strncasecmp
GLdouble GLdouble GLdouble GLdouble top
VideoBootStrap NACL_bootstrap
#define SDL_GetRenderDriverInfo
void SDL_MouseQuit(void)
Definition: SDL_mouse.c:592
SDL_Surface * SDL_GetWindowSurface(SDL_Window *window)
Get the SDL surface associated with the window.
Definition: SDL_video.c:2293
SDL_Rect windowed
Definition: SDL_sysvideo.h:87
SDL_Window * SDL_CreateWindowFrom(const void *data)
Create an SDL window from an existing native window.
Definition: SDL_video.c:1576
void SDL_MinimizeWindow(SDL_Window *window)
Minimize a window to an iconic representation.
Definition: SDL_video.c:2213
SDL_GLContext SDL_GL_CreateContext(SDL_Window *window)
Create an OpenGL context for use with an OpenGL window, and make it current.
Definition: SDL_video.c:3468
#define SDL_max(x, y)
Definition: SDL_stdinc.h:407
#define SDL_CreateRGBSurfaceFrom
#define SDL_UpdateTexture
#define GL_ACCUM_ALPHA_BITS
Definition: SDL_opengl.h:383
int(* GL_LoadLibrary)(_THIS, const char *path)
Definition: SDL_sysvideo.h:255
SDL_DisplayMode * SDL_GetClosestDisplayMode(int displayIndex, const SDL_DisplayMode *mode, SDL_DisplayMode *closest)
Get the closest match to the requested display mode.
Definition: SDL_video.c:962
int SDL_GetDesktopDisplayMode(int displayIndex, SDL_DisplayMode *mode)
Fill in information about the desktop display mode.
Definition: SDL_video.c:827
#define GL_FRAMEBUFFER
GLuint const GLchar * name
VideoBootStrap HAIKU_bootstrap
int SDL_GL_GetSwapInterval(void)
Get the swap interval for the current OpenGL context.
Definition: SDL_video.c:3567
int(* SetDisplayMode)(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
Definition: SDL_sysvideo.h:205
int SDL_MouseInit(void)
Definition: SDL_mouse.c:106
void SDL_RaiseWindow(SDL_Window *window)
Raise a window above other windows and set the input focus.
Definition: SDL_video.c:2184
#define SDL_strchr
Uint32 flags
Definition: SDL_surface.h:71
#define SDL_GetHintBoolean
void(* SetWindowBordered)(_THIS, SDL_Window *window, SDL_bool bordered)
Definition: SDL_sysvideo.h:229
void(* GL_GetDrawableSize)(_THIS, SDL_Window *window, int *w, int *h)
Definition: SDL_sysvideo.h:260
Individual button data.
const GLubyte GLuint red
Definition: SDL_glfuncs.h:79
void SDL_ToggleDragAndDropSupport(void)
Definition: SDL_video.c:1374
#define SDL_VERSION(x)
Macro to determine SDL version program was compiled against.
Definition: SDL_version.h:79
#define GL_NO_ERROR
Definition: SDL_opengl.h:719
struct SDL_VideoDevice::@33 gl_config
Uint32 SDL_GetWindowFlags(SDL_Window *window)
Get the window flags.
Definition: SDL_video.c:1737
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
static SDL_INLINE SDL_bool IsAcceptingDragAndDrop(void)
Definition: SDL_video.c:1354
int SDL_SetWindowOpacity(SDL_Window *window, float opacity)
Set the opacity for a window.
Definition: SDL_video.c:2363
SDL_GLattr
OpenGL configuration attributes.
Definition: SDL_video.h:198
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: SDL_opengl.h:1572
char loader_path[256]
Definition: SDL_sysvideo.h:375
void SDL_OnApplicationWillTerminate(void)
Definition: SDL_video.c:4004
void(* HideWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:224
int x
Definition: SDL_rect.h:50
#define SDL_RenderCopy
#define CREATE_FLAGS
Definition: SDL_video.c:1350
#define GL_BLUE_BITS
Definition: SDL_opengl.h:515
void SDL_OnWindowRestored(SDL_Window *window)
Definition: SDL_video.c:2591
#define GL_NUM_EXTENSIONS
const char * SDL_GetCurrentVideoDriver()
Returns the name of the currently initialized video driver.
Definition: SDL_video.c:576
SDL_DisplayOrientation
Definition: SDL_video.h:181
const char * SDL_GetVideoDriver(int index)
Get the name of a built in video driver.
Definition: SDL_video.c:452
SDL_bool retval
void(* RaiseWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:225
struct SDL_WindowUserData * next
Definition: SDL_sysvideo.h:69
SDL_VideoDisplay * SDL_GetDisplay(int displayIndex)
Definition: SDL_video.c:1024
static SDL_INLINE SDL_bool isAtLeastGL3(const char *verstr)
Definition: SDL_video.c:2922
#define SDL_GetRelativeMouseMode
int SDL_GetWindowDisplayMode(SDL_Window *window, SDL_DisplayMode *mode)
Fill in information about the display mode used when a fullscreen window is visible.
Definition: SDL_video.c:1123
void(* SetTextInputRect)(_THIS, SDL_Rect *rect)
Definition: SDL_sysvideo.h:289
SDL_VideoDevice * device
Definition: SDL_sysvideo.h:137
#define SDL_memcpy
float opacity
Definition: SDL_sysvideo.h:91
SDL_bool(* Vulkan_GetInstanceExtensions)(_THIS, SDL_Window *window, unsigned *count, const char **names)
Definition: SDL_sysvideo.h:273
VideoBootStrap Android_bootstrap
VideoBootStrap VIVANTE_bootstrap
#define GL_STENCIL
Definition: SDL_opengl.h:526
const char * SDL_GetDisplayName(int displayIndex)
Get the name of a display in UTF-8 encoding.
Definition: SDL_video.c:668
SDL_bool SDL_ShouldAllowTopmost(void)
Definition: SDL_video.c:3967
void * SDL_GLContext
An opaque handle to an OpenGL context.
Definition: SDL_video.h:193
void * SDL_SetWindowData(SDL_Window *window, const char *name, void *userdata)
Associate an arbitrary named pointer with a window.
Definition: SDL_video.c:1792
VideoBootStrap WINRT_bootstrap
SDL_VideoDisplay * SDL_GetDisplayForWindow(SDL_Window *window)
Definition: SDL_video.c:1092
SDL_bool(* GetWindowWMInfo)(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info)
Definition: SDL_sysvideo.h:248
static int SDL_UpdateWindowTexture(SDL_VideoDevice *unused, SDL_Window *window, const SDL_Rect *rects, int numrects)
Definition: SDL_video.c:369
SDL_GLContext current_glctx
Definition: SDL_sysvideo.h:364
int SDL_GetIndexOfDisplay(SDL_VideoDisplay *display)
Definition: SDL_video.c:645
SDL_GLContext(* GL_CreateContext)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:258
int SDL_SetWindowDisplayMode(SDL_Window *window, const SDL_DisplayMode *mode)
Set the display mode used when a fullscreen window is visible.
Definition: SDL_video.c:1103
#define SDL_GetEventState(type)
Definition: SDL_events.h:769
static int cmpmodes(const void *A, const void *B)
Definition: SDL_video.c:419
VideoBootStrap WINDOWS_bootstrap
void(* Vulkan_GetDrawableSize)(_THIS, SDL_Window *window, int *w, int *h)
Definition: SDL_sysvideo.h:275
int y
Definition: SDL_rect.h:51
SDL_bool(* Vulkan_CreateSurface)(_THIS, SDL_Window *window, VkInstance instance, VkSurfaceKHR *surface)
Definition: SDL_sysvideo.h:274
#define SDL_WINDOWTEXTUREDATA
Definition: SDL_video.c:158
void * pixels
Definition: SDL_surface.h:75
#define SDL_FreeSurface
static SDL_Renderer * renderer
int(* GL_MakeCurrent)(_THIS, SDL_Window *window, SDL_GLContext context)
Definition: SDL_sysvideo.h:259
#define SDL_free
void SDL_SetWindowMaximumSize(SDL_Window *window, int max_w, int max_h)
Set the maximum size of a window&#39;s client area.
Definition: SDL_video.c:2108
void SDL_OnApplicationDidEnterBackground(void)
Definition: SDL_video.c:4026
void SDL_OnWindowEnter(SDL_Window *window)
Definition: SDL_video.c:2607
#define GL_ALPHA_BITS
Definition: SDL_opengl.h:512
void * driverdata
Definition: SDL_video.h:59
SDL_Window * SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
Create a window with the specified position, dimensions, and flags.
Definition: SDL_video.c:1408
void SDL_DestroyWindow(SDL_Window *window)
Destroy a window.
Definition: SDL_video.c:2687
int SDL_GetDisplayUsableBounds(int displayIndex, SDL_Rect *rect)
Get the usable desktop area represented by a display, with the primary display located at 0...
Definition: SDL_video.c:703
SDL_bool relative_mode
Definition: SDL_mouse_c.h:87
void(* Vulkan_UnloadLibrary)(_THIS)
Definition: SDL_sysvideo.h:272
int SDL_GL_MakeCurrent(SDL_Window *window, SDL_GLContext ctx)
Set up an OpenGL context for rendering into an OpenGL window.
Definition: SDL_video.c:3491
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int int in j)
Definition: SDL_x11sym.h:50
void SDL_GL_UnloadLibrary(void)
Unload the OpenGL library previously loaded by SDL_GL_LoadLibrary().
Definition: SDL_video.c:2904
VideoBootStrap QNX_bootstrap
Definition: video.c:361
#define SDL_HINT_ALLOW_TOPMOST
If set to "0" then never set the top most bit on a SDL Window, even if the video mode expects it...
Definition: SDL_hints.h:568
char driver_path[256]
Definition: SDL_sysvideo.h:354
GLenum GLint GLuint mask
#define SDL_memcmp
SDL_DisplayMode * display_modes
Definition: SDL_sysvideo.h:130
SDL_bool SDL_GetWindowGrab(SDL_Window *window)
Get a window&#39;s input grab mode.
Definition: SDL_video.c:2551
void SDL_UpdateWindowGrab(SDL_Window *window)
Definition: SDL_video.c:2504
void(* SetWindowMinimumSize)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:217
Uint32 SDL_GetWindowPixelFormat(SDL_Window *window)
Get the pixel format associated with the window.
Definition: SDL_video.c:1160
SDL_DisplayMode current_mode
Definition: SDL_sysvideo.h:132
void SDL_Vulkan_GetDrawableSize(SDL_Window *window, int *w, int *h)
Get the size of a window&#39;s underlying drawable in pixels (for use with setting viewport, scissor & etc).
Definition: SDL_video.c:4150
GLenum mode
GLubyte GLubyte GLubyte GLubyte w
GLsizei const GLfloat * value
SDL_VideoDisplay * displays
Definition: SDL_sysvideo.h:316
int(* GetDisplayBounds)(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect)
Definition: SDL_sysvideo.h:182
void(* DestroyWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:235
void(* StopTextInput)(_THIS)
Definition: SDL_sysvideo.h:288
#define SDL_TLSCreate
#define SDL_zero(x)
Definition: SDL_stdinc.h:416
void SDL_GetWindowSize(SDL_Window *window, int *w, int *h)
Get the size of a window&#39;s client area.
Definition: SDL_video.c:2031
static Uint32 callback(Uint32 interval, void *param)
Definition: testtimer.c:34
void SDL_OnApplicationDidBecomeActive(void)
Definition: SDL_video.c:4036
void(* SetWindowIcon)(_THIS, SDL_Window *window, SDL_Surface *icon)
Definition: SDL_sysvideo.h:214
Uint32 WINRT_DetectWindowFlags(SDL_Window *window)
int SDL_GetCurrentDisplayMode(int displayIndex, SDL_DisplayMode *mode)
Fill in information about the current display mode.
Definition: SDL_video.c:841
int SDL_SetWindowGammaRamp(SDL_Window *window, const Uint16 *red, const Uint16 *green, const Uint16 *blue)
Set the gamma ramp for a window.
Definition: SDL_video.c:2425
#define GL_DEPTH
Definition: SDL_opengl.h:525
char * title
Definition: SDL_sysvideo.h:77
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574
SDL_bool SDL_HasWindows(void)
Definition: SDL_video.c:1707
#define GL_ACCUM_RED_BITS
Definition: SDL_opengl.h:380
#define SDL_PixelFormatEnumToMasks
void SDL_StopTextInput(void)
Stop receiving any text input events. This function will hide the on-screen keyboard if supported...
Definition: SDL_video.c:3757
int x
Definition: SDL_rect.h:66
static int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen)
Definition: SDL_video.c:1186
SDL_bool SDL_AddDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mode)
Definition: SDL_video.c:754
SDL_Window * windows
Definition: SDL_sysvideo.h:317
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
Definition: SDL_opengl.h:1572
static SDL_bool SDL_MessageboxValidForDriver(const SDL_MessageBoxData *messageboxdata, SDL_SYSWM_TYPE drivertype)
Definition: SDL_video.c:3824
int SDL_GetDisplayBounds(int displayIndex, SDL_Rect *rect)
Get the desktop area represented by a display, with the primary display located at 0...
Definition: SDL_video.c:676
#define GL_INVALID_VALUE
Definition: SDL_opengl.h:721
static int SDL_CreateWindowTexture(SDL_VideoDevice *unused, SDL_Window *window, Uint32 *format, void **pixels, int *pitch)
Definition: SDL_video.c:259
int SDL_AddBasicVideoDisplay(const SDL_DisplayMode *desktop_mode)
Definition: SDL_video.c:592
int framebuffer_srgb_capable
Definition: SDL_sysvideo.h:350
unsigned char GLubyte
Definition: SDL_opengl.h:183
const SDL_MessageBoxButtonData * buttons
int w
Definition: SDL_rect.h:67
MessageBox structure containing title, text, window, etc.
#define GL_CONTEXT_RELEASE_BEHAVIOR_KHR
Definition: gl2ext.h:83
SDL_bool(* HasScreenKeyboardSupport)(_THIS)
Definition: SDL_sysvideo.h:292
void SDL_MaximizeWindow(SDL_Window *window)
Make a window as large as possible.
Definition: SDL_video.c:2197
static void SDL_DestroyWindowTexture(SDL_VideoDevice *unused, SDL_Window *window)
Definition: SDL_video.c:399
#define SDL_atoi
void SDL_OnApplicationWillResignActive(void)
Definition: SDL_video.c:4014
void SDL_KeyboardQuit(void)
Definition: SDL_keyboard.c:832
GLuint index
#define GL_ACCUM_GREEN_BITS
Definition: SDL_opengl.h:381
void SDL_RestoreWindow(SDL_Window *window)
Restore the size and position of a minimized or maximized window.
Definition: SDL_video.c:2229
void SDL_StartTextInput(void)
Start accepting Unicode text input events. This function will show the on-screen keyboard if supporte...
Definition: SDL_video.c:3730
static int SDL_SetDisplayModeForDisplay(SDL_VideoDisplay *display, const SDL_DisplayMode *mode)
Definition: SDL_video.c:975
VideoBootStrap PSP_bootstrap
float brightness
Definition: SDL_sysvideo.h:93
#define SDL_PIXELTYPE(X)
Definition: SDL_pixels.h:124
SDL_Window * fullscreen_window
Definition: SDL_sysvideo.h:135
#define SDL_getenv
void(* DestroyWindowFramebuffer)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:238
#define GL_STEREO
Definition: SDL_opengl.h:522
int SDL_GetNumVideoDisplays(void)
Returns the number of available video displays.
Definition: SDL_video.c:635
SDL_VideoDevice * SDL_GetVideoDevice(void)
Definition: SDL_video.c:586
#define SDL_TLSGet
void(* GL_UnloadLibrary)(_THIS)
Definition: SDL_sysvideo.h:257
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
int share_with_current_context
Definition: SDL_sysvideo.h:347
int SDL_GetDisplayDPI(int displayIndex, float *ddpi, float *hdpi, float *vdpi)
Get the dots/pixels-per-inch for a display.
Definition: SDL_video.c:723
#define SDL_assert(condition)
Definition: SDL_assert.h:169
void(* GetDisplayModes)(_THIS, SDL_VideoDisplay *display)
Definition: SDL_sysvideo.h:197
int(* ShowMessageBox)(_THIS, const SDL_MessageBoxData *messageboxdata, int *buttonid)
Definition: SDL_sysvideo.h:303
GLenum target
unsigned int GLenum
Definition: SDL_opengl.h:176
int SDL_AddVideoDisplay(const SDL_VideoDisplay *display)
Definition: SDL_video.c:606
#define SDL_DISABLE
Definition: SDL_events.h:755
void(* SetWindowMaximumSize)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:218
VideoBootStrap RPI_bootstrap
#define NULL
Definition: begin_code.h:164
int(* CreateSDLWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:211
#define SDL_OutOfMemory()
Definition: SDL_error.h:52
SDL_bool
Definition: SDL_stdinc.h:161
SDL_DisplayMode desktop_mode
Definition: SDL_sysvideo.h:131
#define SDL_GetMouseFocus
SDL_HitTest hit_test
Definition: SDL_sysvideo.h:106
GLboolean enable
struct SDL_VideoDevice::@34 vulkan_config
SDL_bool SDL_GetWindowWMInfo(SDL_Window *window, struct SDL_SysWMinfo *info)
This function allows access to driver-dependent window information.
Definition: SDL_video.c:3712
SDL_PixelFormat * format
Definition: SDL_surface.h:72
SDL_bool SDL_IsTextInputActive(void)
Return whether or not Unicode text input events are enabled.
Definition: SDL_video.c:3751
void * SDL_GetDisplayDriverData(int displayIndex)
Definition: SDL_video.c:660
void(* VideoQuit)(_THIS)
Definition: SDL_sysvideo.h:167
void SDL_SetWindowBordered(SDL_Window *window, SDL_bool bordered)
Set the border state of a window.
Definition: SDL_video.c:1947
Uint32 last_fullscreen_flags
Definition: SDL_sysvideo.h:84
int SDL_SetWindowModalFor(SDL_Window *modal_window, SDL_Window *parent_window)
Sets the window as a modal for another window (TODO: reconsider this function and/or its name) ...
Definition: SDL_video.c:2399
unsigned int GLuint
Definition: SDL_opengl.h:185
#define SDL_SetError
VideoBootStrap DUMMY_bootstrap
Information on the capabilities of a render driver or context.
Definition: SDL_render.h:78
void SDL_SetWindowResizable(SDL_Window *window, SDL_bool resizable)
Set the user-resizable state of a window.
Definition: SDL_video.c:1965
GLbitfield flags
GLenum func
#define SDL_calloc
void SDL_SetWindowIcon(SDL_Window *window, SDL_Surface *icon)
Set the icon for a window.
Definition: SDL_video.c:1770
SDL_Window * SDL_GetGrabbedWindow(void)
Get the window that currently has an input grab enabled.
Definition: SDL_video.c:2559
SDL_Surface * icon
Definition: SDL_sysvideo.h:78
int(* SetWindowOpacity)(_THIS, SDL_Window *window, float opacity)
Definition: SDL_sysvideo.h:220
SDL_bool SDL_Vulkan_CreateSurface(SDL_Window *window, VkInstance instance, VkSurfaceKHR *surface)
Create a Vulkan rendering surface for a window.
Definition: SDL_video.c:4126
float SDL_ComputeDiagonalDPI(int hpix, int vpix, float hinches, float vinches)
Definition: SDL_video.c:3990
static SDL_bool ShouldUseTextureFramebuffer()
Definition: SDL_video.c:169
EGLSurface EGLNativeWindowType * window
Definition: eglext.h:1025
#define SDL_DestroyTexture
void(* SetWindowPosition)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:215
SDL_Window * prev
Definition: SDL_sysvideo.h:113
void SDL_GetWindowMaximumSize(SDL_Window *window, int *max_w, int *max_h)
Get the maximum size of a window&#39;s client area.
Definition: SDL_video.c:2138
SDL_Renderer * renderer
Definition: SDL_video.c:161
#define GL_ACCUM_BLUE_BITS
Definition: SDL_opengl.h:382
int(* GL_SwapWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:263
#define SDL_strlen
int SDL_VideoInit(const char *driver_name)
Initialize the video subsystem, optionally specifying a video driver.
Definition: SDL_video.c:464
int h
Definition: SDL_rect.h:67
void(* ShowScreenKeyboard)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:293
#define SDL_strdup
SDL_TLSID current_glctx_tls
Definition: SDL_sysvideo.h:366
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 void
The type used to identify a window.
Definition: SDL_sysvideo.h:73
void SDL_Vulkan_UnloadLibrary(void)
Unload the Vulkan loader library previously loaded by SDL_Vulkan_LoadLibrary().
Definition: SDL_video.c:4090
GLbyte GLbyte blue
int(* GetWindowGammaRamp)(_THIS, SDL_Window *window, Uint16 *ramp)
Definition: SDL_sysvideo.h:233
SDL_DisplayOrientation SDL_GetDisplayOrientation(int displayIndex)
Get the orientation of a display.
Definition: SDL_video.c:743
#define SDL_EventState
void SDL_ResetKeyboard(void)
Definition: SDL_keyboard.c:572
#define SDL_HINT_FRAMEBUFFER_ACCELERATION
A variable controlling how 3D acceleration is used to accelerate the SDL screen surface.
Definition: SDL_hints.h:65
int SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
Create a modal message box.
Definition: SDL_video.c:3843
static void SDL_FinishWindowCreation(SDL_Window *window, Uint32 flags)
Definition: SDL_video.c:1386
void(* MinimizeWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:227
void SDL_TicksInit(void)
Uint32 id
Definition: SDL_sysvideo.h:76
SDL_VideoDevice *(* create)(int devindex)
Definition: SDL_sysvideo.h:402
#define SDL_CaptureMouse
GLenum attachment
VideoBootStrap PND_bootstrap
int SDL_GL_SetAttribute(SDL_GLattr attr, int value)
Set an OpenGL window attribute before window creation.
Definition: SDL_video.c:3098
SDL_GLContext SDL_GL_GetCurrentContext(void)
Get the currently active OpenGL context.
Definition: SDL_video.c:3532
VideoBootStrap COCOA_bootstrap
#define SDL_HINT_RENDER_DRIVER
A variable specifying which render driver to use.
Definition: SDL_hints.h:85
static int SDL_UninitializedVideo()
Definition: SDL_video.c:440
SDL_bool SDL_GL_ExtensionSupported(const char *extension)
Return true if an OpenGL extension is supported for the current context.
Definition: SDL_video.c:2929
PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr
Definition: SDL_sysvideo.h:372
uint16_t Uint16
Definition: SDL_stdinc.h:191
#define SDL_sqrt
const GLfloat * params
int(* SetWindowInputFocus)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:222
static VideoBootStrap * bootstrap[]
Definition: SDL_video.c:60
const char * name
Definition: SDL_sysvideo.h:399
void * SDL_GL_GetProcAddress(const char *proc)
Get the address of an OpenGL function.
Definition: SDL_video.c:2882
Uint32 num_texture_formats
Definition: SDL_render.h:82
SDL_Window * grabbed_window
Definition: SDL_sysvideo.h:318
#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE
int(* VideoInit)(_THIS)
Definition: SDL_sysvideo.h:161
int SDL_UpdateWindowSurface(SDL_Window *window)
Copy the window surface to the screen.
Definition: SDL_video.c:2312
SDL_bool suspend_screensaver
Definition: SDL_sysvideo.h:314
int(* CreateSDLWindowFrom)(_THIS, SDL_Window *window, const void *data)
Definition: SDL_sysvideo.h:212
#define SDL_arraysize(array)
Definition: SDL_stdinc.h:115
static SDL_DisplayMode * SDL_GetClosestDisplayModeForDisplay(SDL_VideoDisplay *display, const SDL_DisplayMode *mode, SDL_DisplayMode *closest)
Definition: SDL_video.c:855
#define SDL_INLINE
Definition: begin_code.h:131
void(* SetWindowFullscreen)(_THIS, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen)
Definition: SDL_sysvideo.h:231
int SDL_GL_GetAttribute(SDL_GLattr attr, int *value)
Get the actual value for an attribute from the current context.
Definition: SDL_video.c:3219
void * SDL_Vulkan_GetVkGetInstanceProcAddr(void)
Get the address of the vkGetInstanceProcAddr function.
Definition: SDL_video.c:4077
void SDL_OnWindowHidden(SDL_Window *window)
Definition: SDL_video.c:2572
int(* SetWindowModalFor)(_THIS, SDL_Window *modal_window, SDL_Window *parent_window)
Definition: SDL_sysvideo.h:221
#define SDL_CalculateGammaRamp
#define SDL_malloc
int SDL_GetWindowGammaRamp(SDL_Window *window, Uint16 *red, Uint16 *green, Uint16 *blue)
Get the gamma ramp for a window.
Definition: SDL_video.c:2459
GLsizei const GLchar *const * path
VideoBootStrap UIKIT_bootstrap
#define SDL_WarpMouseInWindow
int(* UpdateWindowFramebuffer)(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects)
Definition: SDL_sysvideo.h:237
#define CHECK_DISPLAY_INDEX(displayIndex, retval)
Definition: SDL_video.c:134
void SDL_GL_SwapWindow(SDL_Window *window)
Swap the OpenGL buffers for a window, if double-buffering is supported.
Definition: SDL_video.c:3581
#define SDL_DestroyRenderer
#define SDL_EnclosePoints
static SDL_INLINE void PrepareDragAndDropSupport(SDL_Window *window)
Definition: SDL_video.c:1365
Uint16 * gamma
Definition: SDL_sysvideo.h:94
int SDL_RecreateWindow(SDL_Window *window, Uint32 flags)
Definition: SDL_video.c:1617
int SDL_SendAppEvent(SDL_EventType eventType)
Definition: SDL_events.c:942
#define SDL_strcmp
#define FULLSCREEN_MASK
Definition: SDL_video.c:147
void(* GL_DeleteContext)(_THIS, SDL_GLContext context)
Definition: SDL_sysvideo.h:264
#define SDL_ISPIXELFORMAT_FOURCC(format)
Definition: SDL_pixels.h:167
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:123
void(* GL_DefaultProfileConfig)(_THIS, int *mask, int *major, int *minor)
Definition: SDL_sysvideo.h:265
Uint32 format
Definition: SDL_video.h:55
int SDL_ShowSimpleMessageBox(Uint32 flags, const char *title, const char *message, SDL_Window *window)
Create a simple modal message box.
Definition: SDL_video.c:3934
void(* SetWindowTitle)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:213
int SDL_Vulkan_LoadLibrary(const char *path)
Dynamically load a Vulkan loader library.
Definition: SDL_video.c:4051
EGLSurface EGLint * rects
Definition: eglext.h:282
void(* SetWindowResizable)(_THIS, SDL_Window *window, SDL_bool resizable)
Definition: SDL_sysvideo.h:230
int(* GetDisplayUsableBounds)(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect)
Definition: SDL_sysvideo.h:187
int(* GL_GetSwapInterval)(_THIS)
Definition: SDL_sysvideo.h:262
#define GL_GREEN_BITS
Definition: SDL_opengl.h:514
void(* MaximizeWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:226
void SDL_OnWindowFocusLost(SDL_Window *window)
Definition: SDL_video.c:2655
int SDL_GetWindowDisplayIndex(SDL_Window *window)
Get the display index associated with a window.
Definition: SDL_video.c:1032
GLenum pname
#define SDL_ShowCursor
GLboolean GLboolean GLboolean GLboolean a
SDL_bool surface_valid
Definition: SDL_sysvideo.h:98
Uint32 flags
Definition: SDL_sysvideo.h:83
int(* SetWindowGammaRamp)(_THIS, SDL_Window *window, const Uint16 *ramp)
Definition: SDL_sysvideo.h:232
Uint32 next_object_id
Definition: SDL_sysvideo.h:320
SDL_Window * SDL_GL_GetCurrentWindow(void)
Get the currently active OpenGL window.
Definition: SDL_video.c:3522
void SDL_EnableScreenSaver()
Allow the screen to be blanked by a screensaver.
Definition: SDL_video.c:2773
SDL_Surface * surface
Definition: SDL_sysvideo.h:97
static SDL_bool ShouldMinimizeOnFocusLoss(SDL_Window *window)
Definition: SDL_video.c:2637
Uint32 SDL_GetWindowID(SDL_Window *window)
Get the numeric ID of a window, for logging purposes.
Definition: SDL_video.c:1713
void(* OnWindowEnter)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:239
void(* SuspendScreenSaver)(_THIS)
Definition: SDL_sysvideo.h:284
GLboolean GLboolean GLboolean b
SDL_bool SDL_HasScreenKeyboardSupport(void)
Returns whether the platform has some screen keyboard support.
Definition: SDL_video.c:3786
SDL_Window * current_glwin
Definition: SDL_sysvideo.h:363
void(* SetWindowGrab)(_THIS, SDL_Window *window, SDL_bool grabbed)
Definition: SDL_sysvideo.h:234
void SDL_TouchQuit(void)
Definition: SDL_touch.c:361
#define SDL_BITSPERPIXEL(X)
Definition: SDL_pixels.h:127
int y
Definition: SDL_rect.h:66
#define SDL_Unsupported()
Definition: SDL_error.h:53
#define SDL_GetMouseState
int(* CreateWindowFramebuffer)(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch)
Definition: SDL_sysvideo.h:236
void *(* GL_GetProcAddress)(_THIS, const char *proc)
Definition: SDL_sysvideo.h:256
SDL_WindowUserData * data
Definition: SDL_sysvideo.h:109
void SDL_SetWindowPosition(SDL_Window *window, int x, int y)
Set the position of a window.
Definition: SDL_video.c:1860
#define SDL_CreateRenderer
void SDL_OnWindowResized(SDL_Window *window)
Definition: SDL_video.c:2578
#define SDL_memset
A rectangle, with the origin at the upper left.
Definition: SDL_rect.h:64
int SDL_TouchInit(void)
Definition: SDL_touch.c:37
#define SDL_GetRendererInfo
SDL_bool SDL_GetSpanEnclosingRect(int width, int height, int numrects, const SDL_Rect *rects, SDL_Rect *span)
Definition: SDL_rect.c:469
#define SDL_strstr
#define SDL_RenderPresent
void SDL_DisableScreenSaver()
Prevent the screen from being blanked by a screensaver.
Definition: SDL_video.c:2788
char * clipboard_text
Definition: SDL_sysvideo.h:321
SDL_bool SDL_Vulkan_GetInstanceExtensions(SDL_Window *window, unsigned *count, const char **names)
Definition: SDL_video.c:4106
int SDL_SetWindowFullscreen(SDL_Window *window, Uint32 flags)
Set a window&#39;s fullscreen state.
Definition: SDL_video.c:2243
SDL_bool is_hiding
Definition: SDL_sysvideo.h:100
GLint left
void SDL_SetTextInputRect(SDL_Rect *rect)
Set the rectangle used to type Unicode text inputs. This is used as a hint for IME and on-screen keyb...
Definition: SDL_video.c:3778
SDL_DisplayOrientation orientation
Definition: SDL_sysvideo.h:133
int SDL_GetNumDisplayModes(int displayIndex)
Returns the number of available display modes.
Definition: SDL_video.c:801
static SDL_Surface * SDL_CreateWindowFramebuffer(SDL_Window *window)
Definition: SDL_video.c:2269
void(* HideScreenKeyboard)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:294
void(* AcceptDragAndDrop)(SDL_Window *window, SDL_bool accept)
Definition: SDL_sysvideo.h:309
void SDL_GetWindowMinimumSize(SDL_Window *window, int *min_w, int *min_h)
Get the minimum size of a window&#39;s client area.
Definition: SDL_video.c:2096
int SDL_GetWindowBordersSize(SDL_Window *window, int *top, int *left, int *bottom, int *right)
Get the size of a window&#39;s borders (decorations) around the client area.
Definition: SDL_video.c:2043
#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE
EGLContext ctx
Definition: eglext.h:208