SDL  2.0
SDL_video.c File Reference
#include "../SDL_internal.h"
#include "SDL.h"
#include "SDL_video.h"
#include "SDL_sysvideo.h"
#include "SDL_blit.h"
#include "SDL_pixels_c.h"
#include "SDL_rect_c.h"
#include "../events/SDL_events_c.h"
#include "../timer/SDL_timer_c.h"
#include "SDL_syswm.h"
#include "SDL_opengl.h"
#include "x11/SDL_x11messagebox.h"
+ Include dependency graph for SDL_video.c:

Go to the source code of this file.

Data Structures

struct  SDL_WindowTextureData
 

Macros

#define CHECK_WINDOW_MAGIC(window, retval)
 
#define CHECK_DISPLAY_INDEX(displayIndex, retval)
 
#define FULLSCREEN_MASK   (SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_FULLSCREEN)
 
#define SDL_WINDOWTEXTUREDATA   "_SDL_WindowTextureData"
 
#define CREATE_FLAGS    (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 | SDL_WINDOW_METAL)
 
#define GL_NUM_EXTENSIONS   0x821D
 
#define NOT_A_VULKAN_WINDOW   "The specified window isn't a Vulkan window"
 

Functions

static SDL_bool ShouldUseTextureFramebuffer ()
 
static int SDL_CreateWindowTexture (SDL_VideoDevice *unused, SDL_Window *window, Uint32 *format, void **pixels, int *pitch)
 
static int SDL_UpdateWindowTexture (SDL_VideoDevice *unused, SDL_Window *window, const SDL_Rect *rects, int numrects)
 
static void SDL_DestroyWindowTexture (SDL_VideoDevice *unused, SDL_Window *window)
 
static int cmpmodes (const void *A, const void *B)
 
static int SDL_UninitializedVideo ()
 
int SDL_GetNumVideoDrivers (void)
 Get the number of video drivers compiled into SDL. More...
 
const char * SDL_GetVideoDriver (int index)
 Get the name of a built in video driver. More...
 
int SDL_VideoInit (const char *driver_name)
 Initialize the video subsystem, optionally specifying a video driver. More...
 
const char * SDL_GetCurrentVideoDriver ()
 Returns the name of the currently initialized video driver. More...
 
SDL_VideoDeviceSDL_GetVideoDevice (void)
 
int SDL_AddBasicVideoDisplay (const SDL_DisplayMode *desktop_mode)
 
int SDL_AddVideoDisplay (const SDL_VideoDisplay *display, SDL_bool send_event)
 
void SDL_DelVideoDisplay (int index)
 
int SDL_GetNumVideoDisplays (void)
 Returns the number of available video displays. More...
 
int SDL_GetIndexOfDisplay (SDL_VideoDisplay *display)
 
voidSDL_GetDisplayDriverData (int displayIndex)
 
SDL_bool SDL_IsVideoContextExternal (void)
 
const char * SDL_GetDisplayName (int displayIndex)
 Get the name of a display in UTF-8 encoding. More...
 
int SDL_GetDisplayBounds (int displayIndex, SDL_Rect *rect)
 Get the desktop area represented by a display, with the primary display located at 0,0. More...
 
static int ParseDisplayUsableBoundsHint (SDL_Rect *rect)
 
int SDL_GetDisplayUsableBounds (int displayIndex, SDL_Rect *rect)
 Get the usable desktop area represented by a display, with the primary display located at 0,0. More...
 
int SDL_GetDisplayDPI (int displayIndex, float *ddpi, float *hdpi, float *vdpi)
 Get the dots/pixels-per-inch for a display. More...
 
SDL_DisplayOrientation SDL_GetDisplayOrientation (int displayIndex)
 Get the orientation of a display. More...
 
SDL_bool SDL_AddDisplayMode (SDL_VideoDisplay *display, const SDL_DisplayMode *mode)
 
static int SDL_GetNumDisplayModesForDisplay (SDL_VideoDisplay *display)
 
int SDL_GetNumDisplayModes (int displayIndex)
 Returns the number of available display modes. More...
 
int SDL_GetDisplayMode (int displayIndex, int index, SDL_DisplayMode *mode)
 Fill in information about a specific display mode. More...
 
int SDL_GetDesktopDisplayMode (int displayIndex, SDL_DisplayMode *mode)
 Fill in information about the desktop display mode. More...
 
int SDL_GetCurrentDisplayMode (int displayIndex, SDL_DisplayMode *mode)
 Fill in information about the current display mode. More...
 
static SDL_DisplayModeSDL_GetClosestDisplayModeForDisplay (SDL_VideoDisplay *display, const SDL_DisplayMode *mode, SDL_DisplayMode *closest)
 
SDL_DisplayModeSDL_GetClosestDisplayMode (int displayIndex, const SDL_DisplayMode *mode, SDL_DisplayMode *closest)
 Get the closest match to the requested display mode. More...
 
static int SDL_SetDisplayModeForDisplay (SDL_VideoDisplay *display, const SDL_DisplayMode *mode)
 
SDL_VideoDisplaySDL_GetDisplay (int displayIndex)
 
int SDL_GetWindowDisplayIndex (SDL_Window *window)
 Get the display index associated with a window. More...
 
SDL_VideoDisplaySDL_GetDisplayForWindow (SDL_Window *window)
 
int SDL_SetWindowDisplayMode (SDL_Window *window, const SDL_DisplayMode *mode)
 Set the display mode used when a fullscreen window is visible. More...
 
int SDL_GetWindowDisplayMode (SDL_Window *window, SDL_DisplayMode *mode)
 Fill in information about the display mode used when a fullscreen window is visible. More...
 
Uint32 SDL_GetWindowPixelFormat (SDL_Window *window)
 Get the pixel format associated with the window. More...
 
static void SDL_RestoreMousePosition (SDL_Window *window)
 
static int SDL_UpdateFullscreenMode (SDL_Window *window, SDL_bool fullscreen)
 
static SDL_INLINE SDL_bool IsAcceptingDragAndDrop (void)
 
static SDL_INLINE void PrepareDragAndDropSupport (SDL_Window *window)
 
void SDL_ToggleDragAndDropSupport (void)
 
static void SDL_FinishWindowCreation (SDL_Window *window, Uint32 flags)
 
SDL_WindowSDL_CreateWindow (const char *title, int x, int y, int w, int h, Uint32 flags)
 Create a window with the specified position, dimensions, and flags. More...
 
SDL_WindowSDL_CreateWindowFrom (const void *data)
 Create an SDL window from an existing native window. More...
 
int SDL_RecreateWindow (SDL_Window *window, Uint32 flags)
 
SDL_bool SDL_HasWindows (void)
 
Uint32 SDL_GetWindowID (SDL_Window *window)
 Get the numeric ID of a window, for logging purposes. More...
 
SDL_WindowSDL_GetWindowFromID (Uint32 id)
 Get a window from a stored ID, or NULL if it doesn't exist. More...
 
Uint32 SDL_GetWindowFlags (SDL_Window *window)
 Get the window flags. More...
 
void SDL_SetWindowTitle (SDL_Window *window, const char *title)
 Set the title of a window, in UTF-8 format. More...
 
const char * SDL_GetWindowTitle (SDL_Window *window)
 Get the title of a window, in UTF-8 format. More...
 
void SDL_SetWindowIcon (SDL_Window *window, SDL_Surface *icon)
 Set the icon for a window. More...
 
voidSDL_SetWindowData (SDL_Window *window, const char *name, void *userdata)
 Associate an arbitrary named pointer with a window. More...
 
voidSDL_GetWindowData (SDL_Window *window, const char *name)
 Retrieve the data pointer associated with a window. More...
 
void SDL_SetWindowPosition (SDL_Window *window, int x, int y)
 Set the position of a window. More...
 
void SDL_GetWindowPosition (SDL_Window *window, int *x, int *y)
 Get the position of a window. More...
 
void SDL_SetWindowBordered (SDL_Window *window, SDL_bool bordered)
 Set the border state of a window. More...
 
void SDL_SetWindowResizable (SDL_Window *window, SDL_bool resizable)
 Set the user-resizable state of a window. More...
 
void SDL_SetWindowSize (SDL_Window *window, int w, int h)
 Set the size of a window's client area. More...
 
void SDL_GetWindowSize (SDL_Window *window, int *w, int *h)
 Get the size of a window's client area. More...
 
int SDL_GetWindowBordersSize (SDL_Window *window, int *top, int *left, int *bottom, int *right)
 Get the size of a window's borders (decorations) around the client area. More...
 
void SDL_SetWindowMinimumSize (SDL_Window *window, int min_w, int min_h)
 Set the minimum size of a window's client area. More...
 
void SDL_GetWindowMinimumSize (SDL_Window *window, int *min_w, int *min_h)
 Get the minimum size of a window's client area. More...
 
void SDL_SetWindowMaximumSize (SDL_Window *window, int max_w, int max_h)
 Set the maximum size of a window's client area. More...
 
void SDL_GetWindowMaximumSize (SDL_Window *window, int *max_w, int *max_h)
 Get the maximum size of a window's client area. More...
 
void SDL_ShowWindow (SDL_Window *window)
 Show a window. More...
 
void SDL_HideWindow (SDL_Window *window)
 Hide a window. More...
 
void SDL_RaiseWindow (SDL_Window *window)
 Raise a window above other windows and set the input focus. More...
 
void SDL_MaximizeWindow (SDL_Window *window)
 Make a window as large as possible. More...
 
static SDL_bool CanMinimizeWindow (SDL_Window *window)
 
void SDL_MinimizeWindow (SDL_Window *window)
 Minimize a window to an iconic representation. More...
 
void SDL_RestoreWindow (SDL_Window *window)
 Restore the size and position of a minimized or maximized window. More...
 
int SDL_SetWindowFullscreen (SDL_Window *window, Uint32 flags)
 Set a window's fullscreen state. More...
 
static SDL_SurfaceSDL_CreateWindowFramebuffer (SDL_Window *window)
 
SDL_SurfaceSDL_GetWindowSurface (SDL_Window *window)
 Get the SDL surface associated with the window. More...
 
int SDL_UpdateWindowSurface (SDL_Window *window)
 Copy the window surface to the screen. More...
 
int SDL_UpdateWindowSurfaceRects (SDL_Window *window, const SDL_Rect *rects, int numrects)
 Copy a number of rectangles on the window surface to the screen. More...
 
int SDL_SetWindowBrightness (SDL_Window *window, float brightness)
 Set the brightness (gamma correction) for a window. More...
 
float SDL_GetWindowBrightness (SDL_Window *window)
 Get the brightness (gamma correction) for a window. More...
 
int SDL_SetWindowOpacity (SDL_Window *window, float opacity)
 Set the opacity for a window. More...
 
int SDL_GetWindowOpacity (SDL_Window *window, float *out_opacity)
 Get the opacity of a window. More...
 
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) More...
 
int SDL_SetWindowInputFocus (SDL_Window *window)
 Explicitly sets input focus to the window. More...
 
int SDL_SetWindowGammaRamp (SDL_Window *window, const Uint16 *red, const Uint16 *green, const Uint16 *blue)
 Set the gamma ramp for a window. More...
 
int SDL_GetWindowGammaRamp (SDL_Window *window, Uint16 *red, Uint16 *green, Uint16 *blue)
 Get the gamma ramp for a window. More...
 
void SDL_UpdateWindowGrab (SDL_Window *window)
 
void SDL_SetWindowGrab (SDL_Window *window, SDL_bool grabbed)
 Set a window's input grab mode. More...
 
SDL_bool SDL_GetWindowGrab (SDL_Window *window)
 Get a window's input grab mode. More...
 
SDL_WindowSDL_GetGrabbedWindow (void)
 Get the window that currently has an input grab enabled. More...
 
void SDL_OnWindowShown (SDL_Window *window)
 
void SDL_OnWindowHidden (SDL_Window *window)
 
void SDL_OnWindowResized (SDL_Window *window)
 
void SDL_OnWindowMinimized (SDL_Window *window)
 
void SDL_OnWindowRestored (SDL_Window *window)
 
void SDL_OnWindowEnter (SDL_Window *window)
 
void SDL_OnWindowLeave (SDL_Window *window)
 
void SDL_OnWindowFocusGained (SDL_Window *window)
 
static SDL_bool ShouldMinimizeOnFocusLoss (SDL_Window *window)
 
void SDL_OnWindowFocusLost (SDL_Window *window)
 
SDL_WindowSDL_GetFocusWindow (void)
 
void SDL_DestroyWindow (SDL_Window *window)
 Destroy a window. More...
 
SDL_bool SDL_IsScreenSaverEnabled ()
 Returns whether the screensaver is currently enabled (default off). More...
 
void SDL_EnableScreenSaver ()
 Allow the screen to be blanked by a screensaver. More...
 
void SDL_DisableScreenSaver ()
 Prevent the screen from being blanked by a screensaver. More...
 
void SDL_VideoQuit (void)
 Shuts down the video subsystem. More...
 
int SDL_GL_LoadLibrary (const char *path)
 Dynamically load an OpenGL library. More...
 
voidSDL_GL_GetProcAddress (const char *proc)
 Get the address of an OpenGL function. More...
 
void SDL_GL_UnloadLibrary (void)
 Unload the OpenGL library previously loaded by SDL_GL_LoadLibrary(). More...
 
static SDL_INLINE SDL_bool isAtLeastGL3 (const char *verstr)
 
SDL_bool SDL_GL_ExtensionSupported (const char *extension)
 Return true if an OpenGL extension is supported for the current context. More...
 
void SDL_GL_DeduceMaxSupportedESProfile (int *major, int *minor)
 
void SDL_GL_ResetAttributes ()
 Reset all previously set OpenGL context attributes to their default values. More...
 
int SDL_GL_SetAttribute (SDL_GLattr attr, int value)
 Set an OpenGL window attribute before window creation. More...
 
int SDL_GL_GetAttribute (SDL_GLattr attr, int *value)
 Get the actual value for an attribute from the current context. More...
 
SDL_GLContext SDL_GL_CreateContext (SDL_Window *window)
 Create an OpenGL context for use with an OpenGL window, and make it current. More...
 
int SDL_GL_MakeCurrent (SDL_Window *window, SDL_GLContext ctx)
 Set up an OpenGL context for rendering into an OpenGL window. More...
 
SDL_WindowSDL_GL_GetCurrentWindow (void)
 Get the currently active OpenGL window. More...
 
SDL_GLContext SDL_GL_GetCurrentContext (void)
 Get the currently active OpenGL context. More...
 
void SDL_GL_GetDrawableSize (SDL_Window *window, int *w, int *h)
 Get the size of a window's underlying drawable in pixels (for use with glViewport). More...
 
int SDL_GL_SetSwapInterval (int interval)
 Set the swap interval for the current OpenGL context. More...
 
int SDL_GL_GetSwapInterval (void)
 Get the swap interval for the current OpenGL context. More...
 
void SDL_GL_SwapWindow (SDL_Window *window)
 Swap the OpenGL buffers for a window, if double-buffering is supported. More...
 
void SDL_GL_DeleteContext (SDL_GLContext context)
 Delete an OpenGL context. More...
 
SDL_bool SDL_GetWindowWMInfo (SDL_Window *window, struct SDL_SysWMinfo *info)
 This function allows access to driver-dependent window information. More...
 
void SDL_StartTextInput (void)
 Start accepting Unicode text input events. This function will show the on-screen keyboard if supported. More...
 
SDL_bool SDL_IsTextInputActive (void)
 Return whether or not Unicode text input events are enabled. More...
 
void SDL_StopTextInput (void)
 Stop receiving any text input events. This function will hide the on-screen keyboard if supported. More...
 
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 keyboard placement. More...
 
SDL_bool SDL_HasScreenKeyboardSupport (void)
 Returns whether the platform has some screen keyboard support. More...
 
SDL_bool SDL_IsScreenKeyboardShown (SDL_Window *window)
 Returns whether the screen keyboard is shown for given window. More...
 
static SDL_bool SDL_MessageboxValidForDriver (const SDL_MessageBoxData *messageboxdata, SDL_SYSWM_TYPE drivertype)
 
int SDL_ShowMessageBox (const SDL_MessageBoxData *messageboxdata, int *buttonid)
 Create a modal message box. More...
 
int SDL_ShowSimpleMessageBox (Uint32 flags, const char *title, const char *message, SDL_Window *window)
 Create a simple modal message box. More...
 
SDL_bool SDL_ShouldAllowTopmost (void)
 
int SDL_SetWindowHitTest (SDL_Window *window, SDL_HitTest callback, void *userdata)
 Provide a callback that decides if a window region has special properties. More...
 
float SDL_ComputeDiagonalDPI (int hpix, int vpix, float hinches, float vinches)
 
void SDL_OnApplicationWillTerminate (void)
 
void SDL_OnApplicationDidReceiveMemoryWarning (void)
 
void SDL_OnApplicationWillResignActive (void)
 
void SDL_OnApplicationDidEnterBackground (void)
 
void SDL_OnApplicationWillEnterForeground (void)
 
void SDL_OnApplicationDidBecomeActive (void)
 
int SDL_Vulkan_LoadLibrary (const char *path)
 Dynamically load a Vulkan loader library. More...
 
voidSDL_Vulkan_GetVkGetInstanceProcAddr (void)
 Get the address of the vkGetInstanceProcAddr function. More...
 
void SDL_Vulkan_UnloadLibrary (void)
 Unload the Vulkan loader library previously loaded by SDL_Vulkan_LoadLibrary(). More...
 
SDL_bool SDL_Vulkan_GetInstanceExtensions (SDL_Window *window, unsigned *count, const char **names)
 
SDL_bool SDL_Vulkan_CreateSurface (SDL_Window *window, VkInstance instance, VkSurfaceKHR *surface)
 Create a Vulkan rendering surface for a window. More...
 
void SDL_Vulkan_GetDrawableSize (SDL_Window *window, int *w, int *h)
 Get the size of a window's underlying drawable in pixels (for use with setting viewport, scissor & etc). More...
 
SDL_MetalView SDL_Metal_CreateView (SDL_Window *window)
 Create a CAMetalLayer-backed NSView/UIView and attach it to the specified window. More...
 
void SDL_Metal_DestroyView (SDL_MetalView view)
 Destroy an existing SDL_MetalView object. More...
 
voidSDL_Metal_GetLayer (SDL_MetalView view)
 Get a pointer to the backing CAMetalLayer for the given view. More...
 
void SDL_Metal_GetDrawableSize (SDL_Window *window, int *w, int *h)
 Get the size of a window's underlying drawable in pixels (for use with setting viewport, scissor & etc). More...
 

Variables

static VideoBootStrapbootstrap []
 
static SDL_VideoDevice_this = NULL
 

Macro Definition Documentation

◆ CHECK_DISPLAY_INDEX

#define CHECK_DISPLAY_INDEX (   displayIndex,
  retval 
)
Value:
if (!_this) { \
SDL_UninitializedVideo(); \
return retval; \
} \
SDL_assert(_this->displays != NULL); \
SDL_assert(displayIndex >= 0 && displayIndex < _this->num_displays); \
if (displayIndex < 0 || displayIndex >= _this->num_displays) { \
SDL_SetError("displayIndex must be in the range 0 - %d", \
return retval; \
}
static SDL_VideoDevice * _this
Definition: SDL_video.c:126
#define NULL
Definition: begin_code.h:163
SDL_VideoDisplay * displays
Definition: SDL_sysvideo.h:326
SDL_bool retval

Definition at line 139 of file SDL_video.c.

◆ CHECK_WINDOW_MAGIC

#define CHECK_WINDOW_MAGIC (   window,
  retval 
)
Value:
if (!_this) { \
SDL_UninitializedVideo(); \
return retval; \
} \
SDL_assert(window && window->magic == &_this->window_magic); \
if (!window || window->magic != &_this->window_magic) { \
SDL_SetError("Invalid window"); \
return retval; \
}
EGLSurface EGLNativeWindowType * window
Definition: eglext.h:1025

Definition at line 128 of file SDL_video.c.

◆ CREATE_FLAGS

◆ FULLSCREEN_MASK

#define FULLSCREEN_MASK   (SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_FULLSCREEN)

Definition at line 152 of file SDL_video.c.

◆ GL_NUM_EXTENSIONS

#define GL_NUM_EXTENSIONS   0x821D

◆ NOT_A_VULKAN_WINDOW

#define NOT_A_VULKAN_WINDOW   "The specified window isn't a Vulkan window"

Definition at line 4221 of file SDL_video.c.

◆ SDL_WINDOWTEXTUREDATA

#define SDL_WINDOWTEXTUREDATA   "_SDL_WindowTextureData"

Definition at line 163 of file SDL_video.c.

Function Documentation

◆ CanMinimizeWindow()

static SDL_bool CanMinimizeWindow ( SDL_Window window)
static

Definition at line 2327 of file SDL_video.c.

2328 {
2329  if (!_this->MinimizeWindow) {
2330  return SDL_FALSE;
2331  }
2332  return SDL_TRUE;
2333 }
@ SDL_TRUE
Definition: SDL_stdinc.h:170
@ SDL_FALSE
Definition: SDL_stdinc.h:169
void(* MinimizeWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:228

References _this, SDL_VideoDevice::MinimizeWindow, SDL_FALSE, and SDL_TRUE.

Referenced by SDL_MinimizeWindow().

◆ cmpmodes()

static int cmpmodes ( const void A,
const void B 
)
static

Definition at line 424 of file SDL_video.c.

425 {
426  const SDL_DisplayMode *a = (const SDL_DisplayMode *) A;
427  const SDL_DisplayMode *b = (const SDL_DisplayMode *) B;
428  if (a == b) {
429  return 0;
430  } else if (a->w != b->w) {
431  return b->w - a->w;
432  } else if (a->h != b->h) {
433  return b->h - a->h;
434  } else if (SDL_BITSPERPIXEL(a->format) != SDL_BITSPERPIXEL(b->format)) {
435  return SDL_BITSPERPIXEL(b->format) - SDL_BITSPERPIXEL(a->format);
436  } else if (SDL_PIXELLAYOUT(a->format) != SDL_PIXELLAYOUT(b->format)) {
437  return SDL_PIXELLAYOUT(b->format) - SDL_PIXELLAYOUT(a->format);
438  } else if (a->refresh_rate != b->refresh_rate) {
439  return b->refresh_rate - a->refresh_rate;
440  }
441  return 0;
442 }
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
#define SDL_BITSPERPIXEL(X)
Definition: SDL_pixels.h:127
#define SDL_PIXELLAYOUT(X)
Definition: SDL_pixels.h:126
The structure that defines a display mode.
Definition: SDL_video.h:54

References SDL_BITSPERPIXEL, SDL_PIXELLAYOUT, and SDL_DisplayMode::w.

Referenced by SDL_AddDisplayMode(), and SDL_GetNumDisplayModesForDisplay().

◆ IsAcceptingDragAndDrop()

static SDL_INLINE SDL_bool IsAcceptingDragAndDrop ( void  )
static

Definition at line 1392 of file SDL_video.c.

1393 {
1396  return SDL_TRUE;
1397  }
1398  return SDL_FALSE;
1399 }
@ SDL_DROPTEXT
Definition: SDL_events.h:148
@ SDL_DROPFILE
Definition: SDL_events.h:147
#define SDL_GetEventState(type)
Definition: SDL_events.h:808
#define SDL_ENABLE
Definition: SDL_events.h:795

References SDL_DROPFILE, SDL_DROPTEXT, SDL_ENABLE, SDL_FALSE, SDL_GetEventState, and SDL_TRUE.

Referenced by PrepareDragAndDropSupport(), and SDL_ToggleDragAndDropSupport().

◆ isAtLeastGL3()

static SDL_INLINE SDL_bool isAtLeastGL3 ( const char *  verstr)
static

Definition at line 3065 of file SDL_video.c.

3066 {
3067  return (verstr && (SDL_atoi(verstr) >= 3));
3068 }
#define SDL_atoi

References SDL_atoi.

Referenced by SDL_GL_ExtensionSupported(), and SDL_GL_GetAttribute().

◆ ParseDisplayUsableBoundsHint()

static int ParseDisplayUsableBoundsHint ( SDL_Rect rect)
static

Definition at line 730 of file SDL_video.c.

731 {
732  const char *hint = SDL_GetHint(SDL_HINT_DISPLAY_USABLE_BOUNDS);
733  return hint && (SDL_sscanf(hint, "%d,%d,%d,%d", &rect->x, &rect->y, &rect->w, &rect->h) == 4);
734 }
#define SDL_sscanf
#define SDL_GetHint
#define SDL_HINT_DISPLAY_USABLE_BOUNDS
Override for SDL_GetDisplayUsableBounds()
Definition: SDL_hints.h:1430
int h
Definition: SDL_rect.h:80
int w
Definition: SDL_rect.h:80
int y
Definition: SDL_rect.h:79
int x
Definition: SDL_rect.h:79
SDL_Rect rect
Definition: testrelative.c:27

References SDL_Rect::h, rect, SDL_GetHint, SDL_HINT_DISPLAY_USABLE_BOUNDS, SDL_sscanf, SDL_Rect::w, SDL_Rect::x, and SDL_Rect::y.

Referenced by SDL_GetDisplayUsableBounds().

◆ PrepareDragAndDropSupport()

static SDL_INLINE void PrepareDragAndDropSupport ( SDL_Window window)
static

Definition at line 1403 of file SDL_video.c.

1404 {
1405  if (_this->AcceptDragAndDrop) {
1407  }
1408 }
static SDL_INLINE SDL_bool IsAcceptingDragAndDrop(void)
Definition: SDL_video.c:1392
void(* AcceptDragAndDrop)(SDL_Window *window, SDL_bool accept)
Definition: SDL_sysvideo.h:319

References _this, SDL_VideoDevice::AcceptDragAndDrop, and IsAcceptingDragAndDrop().

Referenced by SDL_CreateWindowFrom(), and SDL_FinishWindowCreation().

◆ SDL_AddBasicVideoDisplay()

int SDL_AddBasicVideoDisplay ( const SDL_DisplayMode desktop_mode)

Definition at line 593 of file SDL_video.c.

594 {
595  SDL_VideoDisplay display;
596 
597  SDL_zero(display);
598  if (desktop_mode) {
599  display.desktop_mode = *desktop_mode;
600  }
601  display.current_mode = display.desktop_mode;
602 
603  return SDL_AddVideoDisplay(&display, SDL_FALSE);
604 }
#define SDL_zero(x)
Definition: SDL_stdinc.h:426
int SDL_AddVideoDisplay(const SDL_VideoDisplay *display, SDL_bool send_event)
Definition: SDL_video.c:607
SDL_DisplayMode desktop_mode
Definition: SDL_sysvideo.h:132
SDL_DisplayMode current_mode
Definition: SDL_sysvideo.h:133

References SDL_VideoDisplay::current_mode, SDL_VideoDisplay::desktop_mode, SDL_AddVideoDisplay(), SDL_FALSE, and SDL_zero.

◆ SDL_AddDisplayMode()

SDL_bool SDL_AddDisplayMode ( SDL_VideoDisplay display,
const SDL_DisplayMode mode 
)

Definition at line 792 of file SDL_video.c.

793 {
794  SDL_DisplayMode *modes;
795  int i, nmodes;
796 
797  /* Make sure we don't already have the mode in the list */
798  modes = display->display_modes;
799  nmodes = display->num_display_modes;
800  for (i = 0; i < nmodes; ++i) {
801  if (cmpmodes(mode, &modes[i]) == 0) {
802  return SDL_FALSE;
803  }
804  }
805 
806  /* Go ahead and add the new mode */
807  if (nmodes == display->max_display_modes) {
808  modes =
809  SDL_realloc(modes,
810  (display->max_display_modes + 32) * sizeof(*modes));
811  if (!modes) {
812  return SDL_FALSE;
813  }
814  display->display_modes = modes;
815  display->max_display_modes += 32;
816  }
817  modes[nmodes] = *mode;
818  display->num_display_modes++;
819 
820  /* Re-sort video modes */
821  SDL_qsort(display->display_modes, display->num_display_modes,
822  sizeof(SDL_DisplayMode), cmpmodes);
823 
824  return SDL_TRUE;
825 }
#define SDL_qsort
#define SDL_realloc
GLenum mode
static int cmpmodes(const void *A, const void *B)
Definition: SDL_video.c:424
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
SDL_DisplayMode * display_modes
Definition: SDL_sysvideo.h:131

References cmpmodes(), SDL_VideoDisplay::display_modes, i, SDL_VideoDisplay::max_display_modes, SDL_VideoDisplay::num_display_modes, SDL_FALSE, SDL_qsort, SDL_realloc, and SDL_TRUE.

◆ SDL_AddVideoDisplay()

int SDL_AddVideoDisplay ( const SDL_VideoDisplay display,
SDL_bool  send_event 
)

Definition at line 607 of file SDL_video.c.

608 {
609  SDL_VideoDisplay *displays;
610  int index = -1;
611 
612  displays =
614  (_this->num_displays + 1) * sizeof(*displays));
615  if (displays) {
616  index = _this->num_displays++;
617  displays[index] = *display;
618  displays[index].device = _this;
619  _this->displays = displays;
620 
621  if (display->name) {
622  displays[index].name = SDL_strdup(display->name);
623  } else {
624  char name[32];
625 
626  SDL_itoa(index, name, 10);
627  displays[index].name = SDL_strdup(name);
628  }
629 
630  if (send_event) {
632  }
633  } else {
634  SDL_OutOfMemory();
635  }
636  return index;
637 }
int SDL_SendDisplayEvent(SDL_VideoDisplay *display, Uint8 displayevent, int data1)
#define SDL_strdup
#define SDL_itoa
#define SDL_OutOfMemory()
Definition: SDL_error.h:88
GLuint index
GLuint const GLchar * name
@ SDL_DISPLAYEVENT_CONNECTED
Definition: SDL_video.h:179
SDL_VideoDevice * device
Definition: SDL_sysvideo.h:138

References _this, SDL_VideoDisplay::device, SDL_VideoDevice::displays, SDL_VideoDisplay::name, SDL_VideoDevice::num_displays, SDL_DISPLAYEVENT_CONNECTED, SDL_itoa, SDL_OutOfMemory, SDL_realloc, SDL_SendDisplayEvent(), and SDL_strdup.

Referenced by SDL_AddBasicVideoDisplay(), and videoInit().

◆ SDL_ComputeDiagonalDPI()

float SDL_ComputeDiagonalDPI ( int  hpix,
int  vpix,
float  hinches,
float  vinches 
)

Definition at line 4162 of file SDL_video.c.

4163 {
4164  float den2 = hinches * hinches + vinches * vinches;
4165  if (den2 <= 0.0f) {
4166  return 0.0f;
4167  }
4168 
4169  return (float)(SDL_sqrt((double)hpix * (double)hpix + (double)vpix * (double)vpix) /
4170  SDL_sqrt((double)den2));
4171 }
#define SDL_sqrt

References SDL_sqrt.

◆ SDL_CreateWindow()

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.

Parameters
titleThe title of the window, in UTF-8 encoding.
xThe x position of the window, SDL_WINDOWPOS_CENTERED, or SDL_WINDOWPOS_UNDEFINED.
yThe y position of the window, SDL_WINDOWPOS_CENTERED, or SDL_WINDOWPOS_UNDEFINED.
wThe width of the window, in screen coordinates.
hThe height of the window, in screen coordinates.
flagsThe flags for the window, a mask of any of the following: SDL_WINDOW_FULLSCREEN, SDL_WINDOW_OPENGL, SDL_WINDOW_HIDDEN, SDL_WINDOW_BORDERLESS, SDL_WINDOW_RESIZABLE, SDL_WINDOW_MAXIMIZED, SDL_WINDOW_MINIMIZED, SDL_WINDOW_INPUT_GRABBED, SDL_WINDOW_ALLOW_HIGHDPI, SDL_WINDOW_VULKAN SDL_WINDOW_METAL.
Returns
The created window, or NULL if window creation failed.

If the window is created with the SDL_WINDOW_ALLOW_HIGHDPI flag, its size in pixels may differ from its size in screen coordinates on platforms with high-DPI support (e.g. iOS and Mac OS X). Use SDL_GetWindowSize() to query the client area's size in screen coordinates, and SDL_GL_GetDrawableSize(), SDL_Vulkan_GetDrawableSize(), or SDL_GetRendererOutputSize() to query the drawable size in pixels.

If the window is created with any of the SDL_WINDOW_OPENGL or SDL_WINDOW_VULKAN flags, then the corresponding LoadLibrary function (SDL_GL_LoadLibrary or SDL_Vulkan_LoadLibrary) is called and the corresponding UnloadLibrary function is called by SDL_DestroyWindow().

If SDL_WINDOW_VULKAN is specified and there isn't a working Vulkan driver, SDL_CreateWindow() will fail because SDL_Vulkan_LoadLibrary() will fail.

If SDL_WINDOW_METAL is specified on an OS that does not support Metal, SDL_CreateWindow() will fail.

Note
On non-Apple devices, SDL requires you to either not link to the Vulkan loader or link to a dynamic library version. This limitation may be removed in a future version of SDL.
See also
SDL_DestroyWindow()
SDL_GL_LoadLibrary()
SDL_Vulkan_LoadLibrary()

Definition at line 1446 of file SDL_video.c.

1447 {
1448  SDL_Window *window;
1449 
1450  if (!_this) {
1451  /* Initialize the video system if needed */
1452  if (SDL_Init(SDL_INIT_VIDEO) < 0) {
1453  return NULL;
1454  }
1455  }
1456 
1457  if ((((flags & SDL_WINDOW_UTILITY) != 0) + ((flags & SDL_WINDOW_TOOLTIP) != 0) + ((flags & SDL_WINDOW_POPUP_MENU) != 0)) > 1) {
1458  SDL_SetError("Conflicting window flags specified");
1459  return NULL;
1460  }
1461 
1462  /* Some platforms can't create zero-sized windows */
1463  if (w < 1) {
1464  w = 1;
1465  }
1466  if (h < 1) {
1467  h = 1;
1468  }
1469 
1470  /* Some platforms blow up if the windows are too large. Raise it later? */
1471  if ((w > 16384) || (h > 16384)) {
1472  SDL_SetError("Window is too large.");
1473  return NULL;
1474  }
1475 
1476  /* Some platforms have OpenGL enabled by default */
1477 #if (SDL_VIDEO_OPENGL && __MACOSX__) || __IPHONEOS__ || __ANDROID__ || __NACL__
1480  }
1481 #endif
1482  if (flags & SDL_WINDOW_OPENGL) {
1483  if (!_this->GL_CreateContext) {
1484  SDL_SetError("OpenGL support is either not configured in SDL "
1485  "or not available in current SDL video driver "
1486  "(%s) or platform", _this->name);
1487  return NULL;
1488  }
1489  if (SDL_GL_LoadLibrary(NULL) < 0) {
1490  return NULL;
1491  }
1492  }
1493 
1494  if (flags & SDL_WINDOW_VULKAN) {
1495  if (!_this->Vulkan_CreateSurface) {
1496  SDL_SetError("Vulkan support is either not configured in SDL "
1497  "or not available in current SDL video driver "
1498  "(%s) or platform", _this->name);
1499  return NULL;
1500  }
1501  if (flags & SDL_WINDOW_OPENGL) {
1502  SDL_SetError("Vulkan and OpenGL not supported on same window");
1503  return NULL;
1504  }
1505  if (SDL_Vulkan_LoadLibrary(NULL) < 0) {
1506  return NULL;
1507  }
1508  }
1509 
1510  if (flags & SDL_WINDOW_METAL) {
1511  if (!_this->Metal_CreateView) {
1512  SDL_SetError("Metal support is either not configured in SDL "
1513  "or not available in current SDL video driver "
1514  "(%s) or platform", _this->name);
1515  return NULL;
1516  }
1517  if (flags & SDL_WINDOW_OPENGL) {
1518  SDL_SetError("Metal and OpenGL not supported on same window");
1519  return NULL;
1520  }
1521  if (flags & SDL_WINDOW_VULKAN) {
1522  SDL_SetError("Metal and Vulkan not supported on same window. "
1523  "To use MoltenVK, set SDL_WINDOW_VULKAN only.");
1524  return NULL;
1525  }
1526  }
1527 
1528  /* Unless the user has specified the high-DPI disabling hint, respect the
1529  * SDL_WINDOW_ALLOW_HIGHDPI flag.
1530  */
1534  }
1535  }
1536 
1537  window = (SDL_Window *)SDL_calloc(1, sizeof(*window));
1538  if (!window) {
1539  SDL_OutOfMemory();
1540  return NULL;
1541  }
1542  window->magic = &_this->window_magic;
1543  window->id = _this->next_object_id++;
1544  window->x = x;
1545  window->y = y;
1546  window->w = w;
1547  window->h = h;
1551  int displayIndex;
1552  SDL_Rect bounds;
1553 
1554  displayIndex = SDL_GetIndexOfDisplay(display);
1555  SDL_GetDisplayBounds(displayIndex, &bounds);
1557  window->x = bounds.x + (bounds.w - w) / 2;
1558  }
1560  window->y = bounds.y + (bounds.h - h) / 2;
1561  }
1562  }
1563  window->windowed.x = window->x;
1564  window->windowed.y = window->y;
1565  window->windowed.w = window->w;
1566  window->windowed.h = window->h;
1567 
1568  if (flags & SDL_WINDOW_FULLSCREEN) {
1570  int displayIndex;
1571  SDL_Rect bounds;
1572 
1573  displayIndex = SDL_GetIndexOfDisplay(display);
1574  SDL_GetDisplayBounds(displayIndex, &bounds);
1575 
1576  window->x = bounds.x;
1577  window->y = bounds.y;
1578  window->w = bounds.w;
1579  window->h = bounds.h;
1580  }
1581 
1582  window->flags = ((flags & CREATE_FLAGS) | SDL_WINDOW_HIDDEN);
1583  window->last_fullscreen_flags = window->flags;
1584  window->opacity = 1.0f;
1585  window->brightness = 1.0f;
1586  window->next = _this->windows;
1588 
1589  if (_this->windows) {
1590  _this->windows->prev = window;
1591  }
1592  _this->windows = window;
1593 
1596  return NULL;
1597  }
1598 
1599  /* Clear minimized if not on windows, only windows handles it at create rather than FinishWindowCreation,
1600  * but it's important or window focus will get broken on windows!
1601  */
1602 #if !defined(__WIN32__)
1603  if (window->flags & SDL_WINDOW_MINIMIZED) {
1604  window->flags &= ~SDL_WINDOW_MINIMIZED;
1605  }
1606 #endif
1607 
1608 #if __WINRT__ && (NTDDI_VERSION < NTDDI_WIN10)
1609  /* HACK: WinRT 8.x apps can't choose whether or not they are fullscreen
1610  or not. The user can choose this, via OS-provided UI, but this can't
1611  be set programmatically.
1612 
1613  Just look at what SDL's WinRT video backend code detected with regards
1614  to fullscreen (being active, or not), and figure out a return/error code
1615  from that.
1616  */
1617  flags = window->flags;
1618 #endif
1619 
1620  if (title) {
1621  SDL_SetWindowTitle(window, title);
1622  }
1624 
1625  /* If the window was created fullscreen, make sure the mode code matches */
1627 
1628  return window;
1629 }
#define SDL_INIT_VIDEO
Definition: SDL.h:82
#define SDL_SetError
#define SDL_GetHintBoolean
#define SDL_Init
#define SDL_calloc
#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:839
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
GLbitfield flags
GLfloat GLfloat GLfloat GLfloat h
GLubyte GLubyte GLubyte GLubyte w
#define FULLSCREEN_VISIBLE(W)
Definition: SDL_sysvideo.h:117
#define CREATE_FLAGS
Definition: SDL_video.c:1388
static int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen)
Definition: SDL_video.c:1224
void SDL_SetWindowTitle(SDL_Window *window, const char *title)
Set the title of a window, in UTF-8 format.
Definition: SDL_video.c:1860
static void SDL_FinishWindowCreation(SDL_Window *window, Uint32 flags)
Definition: SDL_video.c:1424
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:702
int SDL_Vulkan_LoadLibrary(const char *path)
Dynamically load a Vulkan loader library.
Definition: SDL_video.c:4223
SDL_bool SDL_IsVideoContextExternal(void)
Definition: SDL_video.c:688
void SDL_DestroyWindow(SDL_Window *window)
Destroy a window.
Definition: SDL_video.c:2828
int SDL_GL_LoadLibrary(const char *path)
Dynamically load an OpenGL library.
Definition: SDL_video.c:2996
SDL_VideoDisplay * SDL_GetDisplayForWindow(SDL_Window *window)
Definition: SDL_video.c:1130
int SDL_GetIndexOfDisplay(SDL_VideoDisplay *display)
Definition: SDL_video.c:665
#define SDL_WINDOWPOS_ISCENTERED(X)
Definition: SDL_video.h:140
#define SDL_WINDOWPOS_ISUNDEFINED(X)
Definition: SDL_video.h:131
@ SDL_WINDOW_ALLOW_HIGHDPI
Definition: SDL_video.h:112
@ SDL_WINDOW_TOOLTIP
Definition: SDL_video.h:119
@ SDL_WINDOW_VULKAN
Definition: SDL_video.h:121
@ SDL_WINDOW_OPENGL
Definition: SDL_video.h:100
@ SDL_WINDOW_MINIMIZED
Definition: SDL_video.h:105
@ SDL_WINDOW_UTILITY
Definition: SDL_video.h:118
@ SDL_WINDOW_FULLSCREEN
Definition: SDL_video.h:99
@ SDL_WINDOW_METAL
Definition: SDL_video.h:122
@ SDL_WINDOW_HIDDEN
Definition: SDL_video.h:102
@ SDL_WINDOW_POPUP_MENU
Definition: SDL_video.h:120
A rectangle, with the origin at the upper left (integer).
Definition: SDL_rect.h:78
const char * name
Definition: SDL_sysvideo.h:153
int(* CreateSDLWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:212
SDL_GLContext(* GL_CreateContext)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:259
SDL_bool is_dummy
Definition: SDL_sysvideo.h:323
SDL_MetalView(* Metal_CreateView)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:282
SDL_bool(* Vulkan_CreateSurface)(_THIS, SDL_Window *window, VkInstance instance, VkSurfaceKHR *surface)
Definition: SDL_sysvideo.h:275
SDL_Window * windows
Definition: SDL_sysvideo.h:327
Uint32 next_object_id
Definition: SDL_sysvideo.h:330
The type used to identify a window.
Definition: SDL_sysvideo.h:75
SDL_bool is_destroying
Definition: SDL_sysvideo.h:102
SDL_Window * prev
Definition: SDL_sysvideo.h:114

References _this, CREATE_FLAGS, SDL_VideoDevice::CreateSDLWindow, FULLSCREEN_VISIBLE, SDL_VideoDevice::GL_CreateContext, SDL_Rect::h, SDL_Window::is_destroying, SDL_VideoDevice::is_dummy, SDL_VideoDevice::Metal_CreateView, SDL_VideoDevice::name, SDL_VideoDevice::next_object_id, NULL, SDL_Window::prev, SDL_calloc, SDL_DestroyWindow(), SDL_FALSE, SDL_FinishWindowCreation(), SDL_GetDisplayBounds(), SDL_GetDisplayForWindow(), SDL_GetHintBoolean, SDL_GetIndexOfDisplay(), SDL_GL_LoadLibrary(), SDL_HINT_VIDEO_HIGHDPI_DISABLED, SDL_Init, SDL_INIT_VIDEO, SDL_IsVideoContextExternal(), SDL_OutOfMemory, SDL_SetError, SDL_SetWindowTitle(), SDL_UpdateFullscreenMode(), SDL_Vulkan_LoadLibrary(), SDL_WINDOW_ALLOW_HIGHDPI, SDL_WINDOW_FULLSCREEN, SDL_WINDOW_HIDDEN, SDL_WINDOW_METAL, SDL_WINDOW_MINIMIZED, SDL_WINDOW_OPENGL, SDL_WINDOW_POPUP_MENU, SDL_WINDOW_TOOLTIP, SDL_WINDOW_UTILITY, SDL_WINDOW_VULKAN, SDL_WINDOWPOS_ISCENTERED, SDL_WINDOWPOS_ISUNDEFINED, SDL_VideoDevice::Vulkan_CreateSurface, SDL_Rect::w, SDL_VideoDevice::window_magic, SDL_VideoDevice::windows, SDL_Rect::x, and SDL_Rect::y.

Referenced by ShouldUseTextureFramebuffer().

◆ SDL_CreateWindowFramebuffer()

static SDL_Surface* SDL_CreateWindowFramebuffer ( SDL_Window window)
static

Definition at line 2396 of file SDL_video.c.

2397 {
2398  Uint32 format;
2399  void *pixels;
2400  int pitch;
2401  int bpp;
2402  Uint32 Rmask, Gmask, Bmask, Amask;
2403 
2405  return NULL;
2406  }
2407 
2408  if (_this->CreateWindowFramebuffer(_this, window, &format, &pixels, &pitch) < 0) {
2409  return NULL;
2410  }
2411 
2412  if (window->surface) {
2413  return window->surface;
2414  }
2415 
2416  if (!SDL_PixelFormatEnumToMasks(format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
2417  return NULL;
2418  }
2419 
2420  return SDL_CreateRGBSurfaceFrom(pixels, window->w, window->h, bpp, pitch, Rmask, Gmask, Bmask, Amask);
2421 }
#define SDL_PixelFormatEnumToMasks
#define SDL_CreateRGBSurfaceFrom
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
Definition: SDL_opengl.h:1572
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: SDL_opengl.h:1572
uint32_t Uint32
Definition: SDL_stdinc.h:209
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp
int(* CreateWindowFramebuffer)(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch)
Definition: SDL_sysvideo.h:237
int(* UpdateWindowFramebuffer)(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects)
Definition: SDL_sysvideo.h:238

References _this, bpp, SDL_VideoDevice::CreateWindowFramebuffer, NULL, SDL_CreateRGBSurfaceFrom, SDL_PixelFormatEnumToMasks, and SDL_VideoDevice::UpdateWindowFramebuffer.

Referenced by SDL_GetWindowSurface().

◆ SDL_CreateWindowFrom()

SDL_Window* SDL_CreateWindowFrom ( const void data)

Create an SDL window from an existing native window.

Parameters
dataA pointer to driver-dependent window creation data
Returns
The created window, or NULL if window creation failed.
See also
SDL_DestroyWindow()

Definition at line 1632 of file SDL_video.c.

1633 {
1634  SDL_Window *window;
1635 
1636  if (!_this) {
1638  return NULL;
1639  }
1640  if (!_this->CreateSDLWindowFrom) {
1641  SDL_Unsupported();
1642  return NULL;
1643  }
1644  window = (SDL_Window *)SDL_calloc(1, sizeof(*window));
1645  if (!window) {
1646  SDL_OutOfMemory();
1647  return NULL;
1648  }
1649  window->magic = &_this->window_magic;
1650  window->id = _this->next_object_id++;
1651  window->flags = SDL_WINDOW_FOREIGN;
1652  window->last_fullscreen_flags = window->flags;
1653  window->is_destroying = SDL_FALSE;
1654  window->opacity = 1.0f;
1655  window->brightness = 1.0f;
1656  window->next = _this->windows;
1657  if (_this->windows) {
1658  _this->windows->prev = window;
1659  }
1660  _this->windows = window;
1661 
1662  if (_this->CreateSDLWindowFrom(_this, window, data) < 0) {
1664  return NULL;
1665  }
1666 
1668 
1669  return window;
1670 }
#define SDL_Unsupported()
Definition: SDL_error.h:89
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: SDL_opengl.h:1974
static SDL_INLINE void PrepareDragAndDropSupport(SDL_Window *window)
Definition: SDL_video.c:1403
static int SDL_UninitializedVideo()
Definition: SDL_video.c:445
@ SDL_WINDOW_FOREIGN
Definition: SDL_video.h:111
int(* CreateSDLWindowFrom)(_THIS, SDL_Window *window, const void *data)
Definition: SDL_sysvideo.h:213

References _this, SDL_VideoDevice::CreateSDLWindowFrom, SDL_VideoDevice::next_object_id, NULL, PrepareDragAndDropSupport(), SDL_Window::prev, SDL_calloc, SDL_DestroyWindow(), SDL_FALSE, SDL_OutOfMemory, SDL_UninitializedVideo(), SDL_Unsupported, SDL_WINDOW_FOREIGN, SDL_VideoDevice::window_magic, and SDL_VideoDevice::windows.

◆ SDL_CreateWindowTexture()

static int SDL_CreateWindowTexture ( SDL_VideoDevice unused,
SDL_Window window,
Uint32 format,
void **  pixels,
int pitch 
)
static

Definition at line 264 of file SDL_video.c.

265 {
267 
269  if (!data) {
271  int i;
273 
274  /* Check to see if there's a specific driver requested */
275  if (hint && *hint != '0' && *hint != '1' &&
276  SDL_strcasecmp(hint, "true") != 0 &&
277  SDL_strcasecmp(hint, "false") != 0 &&
278  SDL_strcasecmp(hint, "software") != 0) {
279  for (i = 0; i < SDL_GetNumRenderDrivers(); ++i) {
280  SDL_RendererInfo info;
281  SDL_GetRenderDriverInfo(i, &info);
282  if (SDL_strcasecmp(info.name, hint) == 0) {
284  break;
285  }
286  }
287  }
288 
289  if (!renderer) {
290  for (i = 0; i < SDL_GetNumRenderDrivers(); ++i) {
291  SDL_RendererInfo info;
292  SDL_GetRenderDriverInfo(i, &info);
293  if (SDL_strcmp(info.name, "software") != 0) {
295  if (renderer) {
296  break;
297  }
298  }
299  }
300  }
301  if (!renderer) {
302  return SDL_SetError("No hardware accelerated renderers available");
303  }
304 
305  /* Create the data after we successfully create the renderer (bug #1116) */
306  data = (SDL_WindowTextureData *)SDL_calloc(1, sizeof(*data));
307  if (!data) {
309  return SDL_OutOfMemory();
310  }
312 
313  data->renderer = renderer;
314  }
315 
316  /* Free any old texture and pixel data */
317  if (data->texture) {
318  SDL_DestroyTexture(data->texture);
319  data->texture = NULL;
320  }
321  SDL_free(data->pixels);
322  data->pixels = NULL;
323 
324  {
325  SDL_RendererInfo info;
326  Uint32 i;
327 
328  if (SDL_GetRendererInfo(data->renderer, &info) < 0) {
329  return -1;
330  }
331 
332  /* Find the first format without an alpha channel */
333  *format = info.texture_formats[0];
334 
335  for (i = 0; i < info.num_texture_formats; ++i) {
338  *format = info.texture_formats[i];
339  break;
340  }
341  }
342  }
343 
344  data->texture = SDL_CreateTexture(data->renderer, *format,
346  window->w, window->h);
347  if (!data->texture) {
348  return -1;
349  }
350 
351  /* Create framebuffer data */
352  data->bytes_per_pixel = SDL_BYTESPERPIXEL(*format);
353  data->pitch = (((window->w * data->bytes_per_pixel) + 3) & ~3);
354 
355  {
356  /* Make static analysis happy about potential malloc(0) calls. */
357  const size_t allocsize = window->h * data->pitch;
358  data->pixels = SDL_malloc((allocsize > 0) ? allocsize : 1);
359  if (!data->pixels) {
360  return SDL_OutOfMemory();
361  }
362  }
363 
364  *pixels = data->pixels;
365  *pitch = data->pitch;
366 
367  /* Make sure we're not double-scaling the viewport */
368  SDL_RenderSetViewport(data->renderer, NULL);
369 
370  return 0;
371 }
#define SDL_DestroyRenderer
#define SDL_DestroyTexture
#define SDL_CreateTexture
#define SDL_GetRenderDriverInfo
#define SDL_CreateRenderer
#define SDL_malloc
#define SDL_strcasecmp
#define SDL_free
#define SDL_strcmp
#define SDL_GetNumRenderDrivers
#define SDL_GetRendererInfo
#define SDL_RenderSetViewport
#define SDL_HINT_FRAMEBUFFER_ACCELERATION
A variable controlling how 3D acceleration is used to accelerate the SDL screen surface.
Definition: SDL_hints.h:65
#define SDL_BYTESPERPIXEL(X)
Definition: SDL_pixels.h:128
#define SDL_ISPIXELFORMAT_ALPHA(format)
Definition: SDL_pixels.h:154
#define SDL_ISPIXELFORMAT_FOURCC(format)
Definition: SDL_pixels.h:167
@ SDL_TEXTUREACCESS_STREAMING
Definition: SDL_render.h:104
#define SDL_WINDOWTEXTUREDATA
Definition: SDL_video.c:163
void * SDL_GetWindowData(SDL_Window *window, const char *name)
Retrieve the data pointer associated with a window.
Definition: SDL_video.c:1954
void * SDL_SetWindowData(SDL_Window *window, const char *name, void *userdata)
Associate an arbitrary named pointer with a window.
Definition: SDL_video.c:1907
Information on the capabilities of a render driver or context.
Definition: SDL_render.h:79
const char * name
Definition: SDL_render.h:80
Uint32 texture_formats[16]
Definition: SDL_render.h:83
Uint32 num_texture_formats
Definition: SDL_render.h:82
static SDL_Renderer * renderer

References i, SDL_RendererInfo::name, NULL, SDL_RendererInfo::num_texture_formats, renderer, SDL_BYTESPERPIXEL, SDL_calloc, SDL_CreateRenderer, SDL_CreateTexture, SDL_DestroyRenderer, SDL_DestroyTexture, SDL_free, SDL_GetHint, SDL_GetNumRenderDrivers, SDL_GetRenderDriverInfo, SDL_GetRendererInfo, SDL_GetWindowData(), SDL_HINT_FRAMEBUFFER_ACCELERATION, SDL_ISPIXELFORMAT_ALPHA, SDL_ISPIXELFORMAT_FOURCC, SDL_malloc, SDL_OutOfMemory, SDL_RenderSetViewport, SDL_SetError, SDL_SetWindowData(), SDL_strcasecmp, SDL_strcmp, SDL_TEXTUREACCESS_STREAMING, SDL_WINDOWTEXTUREDATA, and SDL_RendererInfo::texture_formats.

Referenced by SDL_VideoInit().

◆ SDL_DelVideoDisplay()

void SDL_DelVideoDisplay ( int  index)

Definition at line 640 of file SDL_video.c.

641 {
643  return;
644  }
645 
647 
648  if (index < (_this->num_displays - 1)) {
650  }
651  --_this->num_displays;
652 }
#define SDL_memmove
@ SDL_DISPLAYEVENT_DISCONNECTED
Definition: SDL_video.h:180

References _this, SDL_VideoDevice::displays, SDL_VideoDevice::num_displays, SDL_DISPLAYEVENT_DISCONNECTED, SDL_memmove, and SDL_SendDisplayEvent().

◆ SDL_DestroyWindow()

void SDL_DestroyWindow ( SDL_Window window)

Destroy a window.

Definition at line 2828 of file SDL_video.c.

2829 {
2830  SDL_VideoDisplay *display;
2831 
2833 
2834  window->is_destroying = SDL_TRUE;
2835 
2836  /* Restore video mode, etc. */
2838 
2839  /* Make sure this window no longer has focus */
2840  if (SDL_GetKeyboardFocus() == window) {
2842  }
2843  if (SDL_GetMouseFocus() == window) {
2845  }
2846 
2847  /* make no context current if this is the current context window. */
2848  if (window->flags & SDL_WINDOW_OPENGL) {
2849  if (_this->current_glwin == window) {
2851  }
2852  }
2853 
2854  if (window->surface) {
2855  window->surface->flags &= ~SDL_DONTFREE;
2856  SDL_FreeSurface(window->surface);
2857  window->surface = NULL;
2858  window->surface_valid = SDL_FALSE;
2859  }
2862  }
2863  if (_this->DestroyWindow) {
2865  }
2866  if (window->flags & SDL_WINDOW_OPENGL) {
2868  }
2869  if (window->flags & SDL_WINDOW_VULKAN) {
2871  }
2872 
2873  display = SDL_GetDisplayForWindow(window);
2874  if (display->fullscreen_window == window) {
2875  display->fullscreen_window = NULL;
2876  }
2877 
2878  /* Now invalidate magic */
2879  window->magic = NULL;
2880 
2881  /* Free memory associated with the window */
2882  SDL_free(window->title);
2883  SDL_FreeSurface(window->icon);
2884  SDL_free(window->gamma);
2885  while (window->data) {
2887 
2888  window->data = data->next;
2889  SDL_free(data->name);
2890  SDL_free(data);
2891  }
2892 
2893  /* Unlink the window from the list */
2894  if (window->next) {
2895  window->next->prev = window->prev;
2896  }
2897  if (window->prev) {
2898  window->prev->next = window->next;
2899  } else {
2900  _this->windows = window->next;
2901  }
2902 
2903  SDL_free(window);
2904 }
#define SDL_GetKeyboardFocus
#define SDL_GetMouseFocus
#define SDL_FreeSurface
void SDL_SetKeyboardFocus(SDL_Window *window)
Definition: SDL_keyboard.c:634
void SDL_SetMouseFocus(SDL_Window *window)
Definition: SDL_mouse.c:208
#define SDL_DONTFREE
Definition: SDL_surface.h:55
void SDL_HideWindow(SDL_Window *window)
Hide a window.
Definition: SDL_video.c:2279
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:128
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:3634
void SDL_GL_UnloadLibrary(void)
Unload the OpenGL library previously loaded by SDL_GL_LoadLibrary().
Definition: SDL_video.c:3047
void SDL_Vulkan_UnloadLibrary(void)
Unload the Vulkan loader library previously loaded by SDL_Vulkan_LoadLibrary().
Definition: SDL_video.c:4262
void(* DestroyWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:236
void(* DestroyWindowFramebuffer)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:239
SDL_Window * current_glwin
Definition: SDL_sysvideo.h:373
SDL_Window * fullscreen_window
Definition: SDL_sysvideo.h:136
SDL_Window * next
Definition: SDL_sysvideo.h:115

References _this, CHECK_WINDOW_MAGIC, SDL_VideoDevice::current_glwin, SDL_WindowUserData::data, SDL_VideoDevice::DestroyWindow, SDL_VideoDevice::DestroyWindowFramebuffer, SDL_VideoDisplay::fullscreen_window, SDL_Window::next, NULL, SDL_DONTFREE, SDL_FALSE, SDL_free, SDL_FreeSurface, SDL_GetDisplayForWindow(), SDL_GetKeyboardFocus, SDL_GetMouseFocus, SDL_GL_MakeCurrent(), SDL_GL_UnloadLibrary(), SDL_HideWindow(), SDL_SetKeyboardFocus(), SDL_SetMouseFocus(), SDL_TRUE, SDL_Vulkan_UnloadLibrary(), SDL_WINDOW_OPENGL, SDL_WINDOW_VULKAN, and SDL_VideoDevice::windows.

Referenced by SDL_CreateWindow(), SDL_CreateWindowFrom(), SDL_VideoQuit(), and ShouldUseTextureFramebuffer().

◆ SDL_DestroyWindowTexture()

static void SDL_DestroyWindowTexture ( SDL_VideoDevice unused,
SDL_Window window 
)
static

Definition at line 404 of file SDL_video.c.

405 {
407 
409  if (!data) {
410  return;
411  }
412  if (data->texture) {
413  SDL_DestroyTexture(data->texture);
414  }
415  if (data->renderer) {
416  SDL_DestroyRenderer(data->renderer);
417  }
418  SDL_free(data->pixels);
419  SDL_free(data);
420 }

References NULL, SDL_DestroyRenderer, SDL_DestroyTexture, SDL_free, SDL_SetWindowData(), and SDL_WINDOWTEXTUREDATA.

Referenced by SDL_VideoInit().

◆ SDL_DisableScreenSaver()

void SDL_DisableScreenSaver ( void  )

Prevent the screen from being blanked by a screensaver.

See also
SDL_IsScreenSaverEnabled()
SDL_EnableScreenSaver()

Definition at line 2931 of file SDL_video.c.

2932 {
2933  if (!_this) {
2934  return;
2935  }
2936  if (_this->suspend_screensaver) {
2937  return;
2938  }
2940  if (_this->SuspendScreenSaver) {
2942  }
2943 }
void(* SuspendScreenSaver)(_THIS)
Definition: SDL_sysvideo.h:294
SDL_bool suspend_screensaver
Definition: SDL_sysvideo.h:324

References _this, SDL_TRUE, SDL_VideoDevice::suspend_screensaver, and SDL_VideoDevice::SuspendScreenSaver.

Referenced by SDL_VideoInit().

◆ SDL_EnableScreenSaver()

void SDL_EnableScreenSaver ( void  )

Allow the screen to be blanked by a screensaver.

See also
SDL_IsScreenSaverEnabled()
SDL_DisableScreenSaver()

Definition at line 2916 of file SDL_video.c.

2917 {
2918  if (!_this) {
2919  return;
2920  }
2921  if (!_this->suspend_screensaver) {
2922  return;
2923  }
2925  if (_this->SuspendScreenSaver) {
2927  }
2928 }

References _this, SDL_FALSE, SDL_VideoDevice::suspend_screensaver, and SDL_VideoDevice::SuspendScreenSaver.

Referenced by SDL_VideoQuit().

◆ SDL_FinishWindowCreation()

static void SDL_FinishWindowCreation ( SDL_Window window,
Uint32  flags 
)
static

Definition at line 1424 of file SDL_video.c.

1425 {
1427 
1428  if (flags & SDL_WINDOW_MAXIMIZED) {
1430  }
1431  if (flags & SDL_WINDOW_MINIMIZED) {
1433  }
1434  if (flags & SDL_WINDOW_FULLSCREEN) {
1436  }
1439  }
1440  if (!(flags & SDL_WINDOW_HIDDEN)) {
1442  }
1443 }
void SDL_SetWindowGrab(SDL_Window *window, SDL_bool grabbed)
Set a window's input grab mode.
Definition: SDL_video.c:2667
int SDL_SetWindowFullscreen(SDL_Window *window, Uint32 flags)
Set a window's fullscreen state.
Definition: SDL_video.c:2370
void SDL_ShowWindow(SDL_Window *window)
Show a window.
Definition: SDL_video.c:2264
void SDL_MaximizeWindow(SDL_Window *window)
Make a window as large as possible.
Definition: SDL_video.c:2311
void SDL_MinimizeWindow(SDL_Window *window)
Minimize a window to an iconic representation.
Definition: SDL_video.c:2336
@ SDL_WINDOW_INPUT_GRABBED
Definition: SDL_video.h:107
@ SDL_WINDOW_MAXIMIZED
Definition: SDL_video.h:106

References PrepareDragAndDropSupport(), SDL_MaximizeWindow(), SDL_MinimizeWindow(), SDL_SetWindowFullscreen(), SDL_SetWindowGrab(), SDL_ShowWindow(), SDL_TRUE, SDL_WINDOW_FULLSCREEN, SDL_WINDOW_HIDDEN, SDL_WINDOW_INPUT_GRABBED, SDL_WINDOW_MAXIMIZED, and SDL_WINDOW_MINIMIZED.

Referenced by SDL_CreateWindow(), and SDL_RecreateWindow().

◆ SDL_GetClosestDisplayMode()

SDL_DisplayMode* SDL_GetClosestDisplayMode ( int  displayIndex,
const SDL_DisplayMode mode,
SDL_DisplayMode closest 
)

Get the closest match to the requested display mode.

Parameters
displayIndexThe index of display from which mode should be queried.
modeThe desired display mode
closestA pointer to a display mode to be filled in with the closest match of the available display modes.
Returns
The passed in value closest, or NULL if no matching video mode was available.

The available display modes are scanned, and closest is filled in with the closest mode matching the requested mode and returned. The mode format and refresh_rate default to the desktop mode if they are 0. The modes are scanned with size being first priority, format being second priority, and finally checking the refresh_rate. If all the available modes are too small, then NULL is returned.

See also
SDL_GetNumDisplayModes()
SDL_GetDisplayMode()

Definition at line 1000 of file SDL_video.c.

1003 {
1004  SDL_VideoDisplay *display;
1005 
1006  CHECK_DISPLAY_INDEX(displayIndex, NULL);
1007 
1008  display = &_this->displays[displayIndex];
1009  return SDL_GetClosestDisplayModeForDisplay(display, mode, closest);
1010 }
#define CHECK_DISPLAY_INDEX(displayIndex, retval)
Definition: SDL_video.c:139
static SDL_DisplayMode * SDL_GetClosestDisplayModeForDisplay(SDL_VideoDisplay *display, const SDL_DisplayMode *mode, SDL_DisplayMode *closest)
Definition: SDL_video.c:893

References _this, CHECK_DISPLAY_INDEX, SDL_VideoDevice::displays, NULL, and SDL_GetClosestDisplayModeForDisplay().

◆ SDL_GetClosestDisplayModeForDisplay()

static SDL_DisplayMode* SDL_GetClosestDisplayModeForDisplay ( SDL_VideoDisplay display,
const SDL_DisplayMode mode,
SDL_DisplayMode closest 
)
static

Definition at line 893 of file SDL_video.c.

896 {
897  Uint32 target_format;
898  int target_refresh_rate;
899  int i;
900  SDL_DisplayMode *current, *match;
901 
902  if (!mode || !closest) {
903  SDL_SetError("Missing desired mode or closest mode parameter");
904  return NULL;
905  }
906 
907  /* Default to the desktop format */
908  if (mode->format) {
909  target_format = mode->format;
910  } else {
911  target_format = display->desktop_mode.format;
912  }
913 
914  /* Default to the desktop refresh rate */
915  if (mode->refresh_rate) {
916  target_refresh_rate = mode->refresh_rate;
917  } else {
918  target_refresh_rate = display->desktop_mode.refresh_rate;
919  }
920 
921  match = NULL;
922  for (i = 0; i < SDL_GetNumDisplayModesForDisplay(display); ++i) {
923  current = &display->display_modes[i];
924 
925  if (current->w && (current->w < mode->w)) {
926  /* Out of sorted modes large enough here */
927  break;
928  }
929  if (current->h && (current->h < mode->h)) {
930  if (current->w && (current->w == mode->w)) {
931  /* Out of sorted modes large enough here */
932  break;
933  }
934  /* Wider, but not tall enough, due to a different
935  aspect ratio. This mode must be skipped, but closer
936  modes may still follow. */
937  continue;
938  }
939  if (!match || current->w < match->w || current->h < match->h) {
940  match = current;
941  continue;
942  }
943  if (current->format != match->format) {
944  /* Sorted highest depth to lowest */
945  if (current->format == target_format ||
946  (SDL_BITSPERPIXEL(current->format) >=
947  SDL_BITSPERPIXEL(target_format)
948  && SDL_PIXELTYPE(current->format) ==
949  SDL_PIXELTYPE(target_format))) {
950  match = current;
951  }
952  continue;
953  }
954  if (current->refresh_rate != match->refresh_rate) {
955  /* Sorted highest refresh to lowest */
956  if (current->refresh_rate >= target_refresh_rate) {
957  match = current;
958  }
959  }
960  }
961  if (match) {
962  if (match->format) {
963  closest->format = match->format;
964  } else {
965  closest->format = mode->format;
966  }
967  if (match->w && match->h) {
968  closest->w = match->w;
969  closest->h = match->h;
970  } else {
971  closest->w = mode->w;
972  closest->h = mode->h;
973  }
974  if (match->refresh_rate) {
975  closest->refresh_rate = match->refresh_rate;
976  } else {
977  closest->refresh_rate = mode->refresh_rate;
978  }
979  closest->driverdata = match->driverdata;
980 
981  /*
982  * Pick some reasonable defaults if the app and driver don't
983  * care
984  */
985  if (!closest->format) {
986  closest->format = SDL_PIXELFORMAT_RGB888;
987  }
988  if (!closest->w) {
989  closest->w = 640;
990  }
991  if (!closest->h) {
992  closest->h = 480;
993  }
994  return closest;
995  }
996  return NULL;
997 }
@ SDL_PIXELFORMAT_RGB888
Definition: SDL_pixels.h:246
#define SDL_PIXELTYPE(X)
Definition: SDL_pixels.h:124
static int SDL_GetNumDisplayModesForDisplay(SDL_VideoDisplay *display)
Definition: SDL_video.c:828
void * driverdata
Definition: SDL_video.h:59
Uint32 format
Definition: SDL_video.h:55

References SDL_VideoDisplay::desktop_mode, SDL_VideoDisplay::display_modes, SDL_DisplayMode::driverdata, SDL_DisplayMode::format, SDL_DisplayMode::h, i, NULL, SDL_DisplayMode::refresh_rate, SDL_BITSPERPIXEL, SDL_GetNumDisplayModesForDisplay(), SDL_PIXELFORMAT_RGB888, SDL_PIXELTYPE, SDL_SetError, and SDL_DisplayMode::w.

Referenced by SDL_GetClosestDisplayMode(), SDL_GetWindowDisplayMode(), and SDL_SetDisplayModeForDisplay().

◆ SDL_GetCurrentDisplayMode()

int SDL_GetCurrentDisplayMode ( int  displayIndex,
SDL_DisplayMode mode 
)

Fill in information about the current display mode.

Definition at line 879 of file SDL_video.c.

880 {
881  SDL_VideoDisplay *display;
882 
883  CHECK_DISPLAY_INDEX(displayIndex, -1);
884 
885  display = &_this->displays[displayIndex];
886  if (mode) {
887  *mode = display->current_mode;
888  }
889  return 0;
890 }

References _this, CHECK_DISPLAY_INDEX, SDL_VideoDisplay::current_mode, and SDL_VideoDevice::displays.

◆ SDL_GetCurrentVideoDriver()

const char* SDL_GetCurrentVideoDriver ( void  )

Returns the name of the currently initialized video driver.

Returns
The name of the current video driver or NULL if no driver has been initialized
See also
SDL_GetNumVideoDrivers()
SDL_GetVideoDriver()

Definition at line 577 of file SDL_video.c.

578 {
579  if (!_this) {
581  return NULL;
582  }
583  return _this->name;
584 }

References _this, SDL_VideoDevice::name, NULL, and SDL_UninitializedVideo().

◆ SDL_GetDesktopDisplayMode()

int SDL_GetDesktopDisplayMode ( int  displayIndex,
SDL_DisplayMode mode 
)

Fill in information about the desktop display mode.

Definition at line 865 of file SDL_video.c.

866 {
867  SDL_VideoDisplay *display;
868 
869  CHECK_DISPLAY_INDEX(displayIndex, -1);
870 
871  display = &_this->displays[displayIndex];
872  if (mode) {
873  *mode = display->desktop_mode;
874  }
875  return 0;
876 }

References _this, CHECK_DISPLAY_INDEX, SDL_VideoDisplay::desktop_mode, and SDL_VideoDevice::displays.

◆ SDL_GetDisplay()

SDL_VideoDisplay* SDL_GetDisplay ( int  displayIndex)

Definition at line 1062 of file SDL_video.c.

1063 {
1064  CHECK_DISPLAY_INDEX(displayIndex, NULL);
1065 
1066  return &_this->displays[displayIndex];
1067 }

References _this, CHECK_DISPLAY_INDEX, SDL_VideoDevice::displays, and NULL.

◆ SDL_GetDisplayBounds()

int SDL_GetDisplayBounds ( int  displayIndex,
SDL_Rect rect 
)

Get the desktop area represented by a display, with the primary display located at 0,0.

Returns
0 on success, or -1 if the index is out of range.
See also
SDL_GetNumVideoDisplays()

Definition at line 702 of file SDL_video.c.

703 {
704  CHECK_DISPLAY_INDEX(displayIndex, -1);
705 
706  if (rect) {
707  SDL_VideoDisplay *display = &_this->displays[displayIndex];
708 
709  if (_this->GetDisplayBounds) {
710  if (_this->GetDisplayBounds(_this, display, rect) == 0) {
711  return 0;
712  }
713  }
714 
715  /* Assume that the displays are left to right */
716  if (displayIndex == 0) {
717  rect->x = 0;
718  rect->y = 0;
719  } else {
720  SDL_GetDisplayBounds(displayIndex-1, rect);
721  rect->x += rect->w;
722  }
723  rect->w = display->current_mode.w;
724  rect->h = display->current_mode.h;
725  }
726  return 0; /* !!! FIXME: should this be an error if (rect==NULL) ? */
727 }
int(* GetDisplayBounds)(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect)
Definition: SDL_sysvideo.h:183

References _this, CHECK_DISPLAY_INDEX, SDL_VideoDisplay::current_mode, SDL_VideoDevice::displays, SDL_VideoDevice::GetDisplayBounds, SDL_Rect::h, SDL_DisplayMode::h, rect, SDL_GetDisplayBounds(), SDL_Rect::w, SDL_DisplayMode::w, SDL_Rect::x, and SDL_Rect::y.

Referenced by SDL_CreateWindow(), SDL_GetDisplayBounds(), SDL_GetDisplayUsableBounds(), SDL_GetWindowDisplayIndex(), SDL_GetWindowPosition(), and SDL_SetWindowPosition().

◆ SDL_GetDisplayDPI()

int SDL_GetDisplayDPI ( int  displayIndex,
float *  ddpi,
float *  hdpi,
float *  vdpi 
)

Get the dots/pixels-per-inch for a display.

Note
Diagonal, horizontal and vertical DPI can all be optionally returned if the parameter is non-NULL.
Returns
0 on success, or -1 if no DPI information is available or the index is out of range.
See also
SDL_GetNumVideoDisplays()

Definition at line 761 of file SDL_video.c.

762 {
763  SDL_VideoDisplay *display;
764 
765  CHECK_DISPLAY_INDEX(displayIndex, -1);
766 
767  display = &_this->displays[displayIndex];
768 
769  if (_this->GetDisplayDPI) {
770  if (_this->GetDisplayDPI(_this, display, ddpi, hdpi, vdpi) == 0) {
771  return 0;
772  }
773  } else {
774  return SDL_Unsupported();
775  }
776 
777  return -1;
778 }
int(* GetDisplayDPI)(_THIS, SDL_VideoDisplay *display, float *ddpi, float *hdpi, float *vdpi)
Definition: SDL_sysvideo.h:193

References _this, CHECK_DISPLAY_INDEX, SDL_VideoDevice::displays, SDL_VideoDevice::GetDisplayDPI, and SDL_Unsupported.

◆ SDL_GetDisplayDriverData()

void* SDL_GetDisplayDriverData ( int  displayIndex)

Definition at line 680 of file SDL_video.c.

681 {
682  CHECK_DISPLAY_INDEX(displayIndex, NULL);
683 
684  return _this->displays[displayIndex].driverdata;
685 }

References _this, CHECK_DISPLAY_INDEX, SDL_VideoDevice::displays, SDL_VideoDisplay::driverdata, and NULL.

◆ SDL_GetDisplayForWindow()

SDL_VideoDisplay* SDL_GetDisplayForWindow ( SDL_Window window)

Definition at line 1130 of file SDL_video.c.

1131 {
1132  int displayIndex = SDL_GetWindowDisplayIndex(window);
1133  if (displayIndex >= 0) {
1134  return &_this->displays[displayIndex];
1135  } else {
1136  return NULL;
1137  }
1138 }
int SDL_GetWindowDisplayIndex(SDL_Window *window)
Get the display index associated with a window.
Definition: SDL_video.c:1070

References _this, SDL_VideoDevice::displays, NULL, and SDL_GetWindowDisplayIndex().

Referenced by SDL_CreateWindow(), SDL_DestroyWindow(), SDL_Fcitx_UpdateTextRect(), SDL_GetWindowDisplayMode(), SDL_GetWindowPixelFormat(), SDL_SetWindowDisplayMode(), and SDL_UpdateFullscreenMode().

◆ SDL_GetDisplayMode()

int SDL_GetDisplayMode ( int  displayIndex,
int  modeIndex,
SDL_DisplayMode mode 
)

Fill in information about a specific display mode.

Note
The display modes are sorted in this priority:
  • bits per pixel -> more colors to fewer colors
  • width -> largest to smallest
  • height -> largest to smallest
  • refresh rate -> highest to lowest
See also
SDL_GetNumDisplayModes()

Definition at line 847 of file SDL_video.c.

848 {
849  SDL_VideoDisplay *display;
850 
851  CHECK_DISPLAY_INDEX(displayIndex, -1);
852 
853  display = &_this->displays[displayIndex];
855  return SDL_SetError("index must be in the range of 0 - %d",
856  SDL_GetNumDisplayModesForDisplay(display) - 1);
857  }
858  if (mode) {
859  *mode = display->display_modes[index];
860  }
861  return 0;
862 }

References _this, CHECK_DISPLAY_INDEX, SDL_VideoDisplay::display_modes, SDL_VideoDevice::displays, SDL_GetNumDisplayModesForDisplay(), and SDL_SetError.

◆ SDL_GetDisplayName()

const char* SDL_GetDisplayName ( int  displayIndex)

Get the name of a display in UTF-8 encoding.

Returns
The name of a display, or NULL for an invalid display index.
See also
SDL_GetNumVideoDisplays()

Definition at line 694 of file SDL_video.c.

695 {
696  CHECK_DISPLAY_INDEX(displayIndex, NULL);
697 
698  return _this->displays[displayIndex].name;
699 }

References _this, CHECK_DISPLAY_INDEX, SDL_VideoDevice::displays, SDL_VideoDisplay::name, and NULL.

◆ SDL_GetDisplayOrientation()

SDL_DisplayOrientation SDL_GetDisplayOrientation ( int  displayIndex)

Get the orientation of a display.

Returns
The orientation of the display, or SDL_ORIENTATION_UNKNOWN if it isn't available.
See also
SDL_GetNumVideoDisplays()

Definition at line 781 of file SDL_video.c.

782 {
783  SDL_VideoDisplay *display;
784 
786 
787  display = &_this->displays[displayIndex];
788  return display->orientation;
789 }
@ SDL_ORIENTATION_UNKNOWN
Definition: SDL_video.h:185
SDL_DisplayOrientation orientation
Definition: SDL_sysvideo.h:134

References _this, CHECK_DISPLAY_INDEX, SDL_VideoDevice::displays, SDL_VideoDisplay::orientation, and SDL_ORIENTATION_UNKNOWN.

◆ SDL_GetDisplayUsableBounds()

int SDL_GetDisplayUsableBounds ( int  displayIndex,
SDL_Rect rect 
)

Get the usable desktop area represented by a display, with the primary display located at 0,0.

This is the same area as SDL_GetDisplayBounds() reports, but with portions reserved by the system removed. For example, on Mac OS X, this subtracts the area occupied by the menu bar and dock.

Setting a window to be fullscreen generally bypasses these unusable areas, so these are good guidelines for the maximum space available to a non-fullscreen window.

Returns
0 on success, or -1 if the index is out of range.
See also
SDL_GetDisplayBounds()
SDL_GetNumVideoDisplays()

Definition at line 737 of file SDL_video.c.

738 {
739  CHECK_DISPLAY_INDEX(displayIndex, -1);
740 
741  if (rect) {
742  SDL_VideoDisplay *display = &_this->displays[displayIndex];
743 
744  if ((displayIndex == 0) && ParseDisplayUsableBoundsHint(rect)) {
745  return 0;
746  }
747 
749  if (_this->GetDisplayUsableBounds(_this, display, rect) == 0) {
750  return 0;
751  }
752  }
753 
754  /* Oh well, just give the entire display bounds. */
755  return SDL_GetDisplayBounds(displayIndex, rect);
756  }
757  return 0; /* !!! FIXME: should this be an error if (rect==NULL) ? */
758 }
static int ParseDisplayUsableBoundsHint(SDL_Rect *rect)
Definition: SDL_video.c:730
int(* GetDisplayUsableBounds)(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect)
Definition: SDL_sysvideo.h:188

References _this, CHECK_DISPLAY_INDEX, SDL_VideoDevice::displays, SDL_VideoDevice::GetDisplayUsableBounds, ParseDisplayUsableBoundsHint(), rect, and SDL_GetDisplayBounds().

◆ SDL_GetFocusWindow()

SDL_Window* SDL_GetFocusWindow ( void  )

Definition at line 2812 of file SDL_video.c.

2813 {
2814  SDL_Window *window;
2815 
2816  if (!_this) {
2817  return NULL;
2818  }
2819  for (window = _this->windows; window; window = window->next) {
2820  if (window->flags & SDL_WINDOW_INPUT_FOCUS) {
2821  return window;
2822  }
2823  }
2824  return NULL;
2825 }
@ SDL_WINDOW_INPUT_FOCUS
Definition: SDL_video.h:108

References _this, SDL_Window::next, NULL, SDL_WINDOW_INPUT_FOCUS, and SDL_VideoDevice::windows.

Referenced by SDL_PromptAssertion(), SDL_StartTextInput(), and SDL_StopTextInput().

◆ SDL_GetGrabbedWindow()

SDL_Window* SDL_GetGrabbedWindow ( void  )

Get the window that currently has an input grab enabled.

Returns
This returns the window if input is grabbed, and NULL otherwise.
See also
SDL_SetWindowGrab()

Definition at line 2691 of file SDL_video.c.

2692 {
2694  return _this->grabbed_window;
2695 }
#define SDL_assert(condition)
Definition: SDL_assert.h:171
SDL_Window * grabbed_window
Definition: SDL_sysvideo.h:328
Uint32 flags
Definition: SDL_sysvideo.h:84

References _this, SDL_Window::flags, SDL_VideoDevice::grabbed_window, SDL_assert, and SDL_WINDOW_INPUT_GRABBED.

◆ SDL_GetIndexOfDisplay()

int SDL_GetIndexOfDisplay ( SDL_VideoDisplay display)

Definition at line 665 of file SDL_video.c.

666 {
667  int displayIndex;
668 
669  for (displayIndex = 0; displayIndex < _this->num_displays; ++displayIndex) {
670  if (display == &_this->displays[displayIndex]) {
671  return displayIndex;
672  }
673  }
674 
675  /* Couldn't find the display, just use index 0 */
676  return 0;
677 }

References _this, SDL_VideoDevice::displays, and SDL_VideoDevice::num_displays.

Referenced by SDL_CreateWindow(), and SDL_SendDisplayEvent().

◆ SDL_GetNumDisplayModes()

int SDL_GetNumDisplayModes ( int  displayIndex)

Returns the number of available display modes.

See also
SDL_GetDisplayMode()

Definition at line 839 of file SDL_video.c.

840 {
841  CHECK_DISPLAY_INDEX(displayIndex, -1);
842 
843  return SDL_GetNumDisplayModesForDisplay(&_this->displays[displayIndex]);
844 }

References _this, CHECK_DISPLAY_INDEX, SDL_VideoDevice::displays, and SDL_GetNumDisplayModesForDisplay().

◆ SDL_GetNumDisplayModesForDisplay()

static int SDL_GetNumDisplayModesForDisplay ( SDL_VideoDisplay display)
static

Definition at line 828 of file SDL_video.c.

829 {
830  if (!display->num_display_modes && _this->GetDisplayModes) {
831  _this->GetDisplayModes(_this, display);
832  SDL_qsort(display->display_modes, display->num_display_modes,
833  sizeof(SDL_DisplayMode), cmpmodes);
834  }
835  return display->num_display_modes;
836 }
void(* GetDisplayModes)(_THIS, SDL_VideoDisplay *display)
Definition: SDL_sysvideo.h:198

References _this, cmpmodes(), SDL_VideoDisplay::display_modes, SDL_VideoDevice::GetDisplayModes, SDL_VideoDisplay::num_display_modes, and SDL_qsort.

Referenced by SDL_GetClosestDisplayModeForDisplay(), SDL_GetDisplayMode(), and SDL_GetNumDisplayModes().

◆ SDL_GetNumVideoDisplays()

int SDL_GetNumVideoDisplays ( void  )

Returns the number of available video displays.

See also
SDL_GetDisplayBounds()

Definition at line 655 of file SDL_video.c.

656 {
657  if (!_this) {
659  return 0;
660  }
661  return _this->num_displays;
662 }

References _this, SDL_VideoDevice::num_displays, and SDL_UninitializedVideo().

◆ SDL_GetNumVideoDrivers()

int SDL_GetNumVideoDrivers ( void  )

Get the number of video drivers compiled into SDL.

See also
SDL_GetVideoDriver()

Definition at line 451 of file SDL_video.c.

452 {
453  return SDL_arraysize(bootstrap) - 1;
454 }
#define SDL_arraysize(array)
Definition: SDL_stdinc.h:121
static VideoBootStrap * bootstrap[]
Definition: SDL_video.c:60

References bootstrap, and SDL_arraysize.

Referenced by SDL_GetVideoDriver().

◆ SDL_GetVideoDevice()

◆ SDL_GetVideoDriver()

const char* SDL_GetVideoDriver ( int  index)

Get the name of a built in video driver.

Note
The video drivers are presented in the order in which they are normally checked during initialization.
See also
SDL_GetNumVideoDrivers()

Definition at line 457 of file SDL_video.c.

458 {
459  if (index >= 0 && index < SDL_GetNumVideoDrivers()) {
460  return bootstrap[index]->name;
461  }
462  return NULL;
463 }
int SDL_GetNumVideoDrivers(void)
Get the number of video drivers compiled into SDL.
Definition: SDL_video.c:451
const char * name
Definition: SDL_sysvideo.h:414

References bootstrap, VideoBootStrap::name, NULL, and SDL_GetNumVideoDrivers().

◆ SDL_GetWindowBordersSize()

int SDL_GetWindowBordersSize ( SDL_Window window,
int top,
int left,
int bottom,
int right 
)

Get the size of a window's borders (decorations) around the client area.

Parameters
windowThe window to query.
topPointer to variable for storing the size of the top border. NULL is permitted.
leftPointer to variable for storing the size of the left border. NULL is permitted.
bottomPointer to variable for storing the size of the bottom border. NULL is permitted.
rightPointer to variable for storing the size of the right border. NULL is permitted.
Returns
0 on success, or -1 if getting this information is not supported.
Note
if this function fails (returns -1), the size values will be initialized to 0, 0, 0, 0 (if a non-NULL pointer is provided), as if the window in question was borderless.

Definition at line 2157 of file SDL_video.c.

2158 {
2159  int dummy = 0;
2160 
2161  if (!top) { top = &dummy; }
2162  if (!left) { left = &dummy; }
2163  if (!right) { right = &dummy; }
2164  if (!bottom) { bottom = &dummy; }
2165 
2166  /* Always initialize, so applications don't have to care */
2167  *top = *left = *bottom = *right = 0;
2168 
2170 
2171  if (!_this->GetWindowBordersSize) {
2172  return SDL_Unsupported();
2173  }
2174 
2176 }
GLdouble GLdouble GLdouble GLdouble top
GLint left
GLint GLint bottom
GLdouble GLdouble right
int(* GetWindowBordersSize)(_THIS, SDL_Window *window, int *top, int *left, int *bottom, int *right)
Definition: SDL_sysvideo.h:220

References _this, CHECK_WINDOW_MAGIC, SDL_VideoDevice::GetWindowBordersSize, and SDL_Unsupported.

◆ SDL_GetWindowBrightness()

float SDL_GetWindowBrightness ( SDL_Window window)

Get the brightness (gamma correction) for a window.

Returns
The last brightness value passed to SDL_SetWindowBrightness()
See also
SDL_SetWindowBrightness()

Definition at line 2487 of file SDL_video.c.

2488 {
2489  CHECK_WINDOW_MAGIC(window, 1.0f);
2490 
2491  return window->brightness;
2492 }

References CHECK_WINDOW_MAGIC.

◆ SDL_GetWindowData()

void* SDL_GetWindowData ( SDL_Window window,
const char *  name 
)

Retrieve the data pointer associated with a window.

Parameters
windowThe window to query.
nameThe name of the pointer.
Returns
The value associated with 'name'
See also
SDL_SetWindowData()

Definition at line 1954 of file SDL_video.c.

1955 {
1957 
1959 
1960  /* Input validation */
1961  if (name == NULL || name[0] == '\0') {
1962  SDL_InvalidParamError("name");
1963  return NULL;
1964  }
1965 
1966  for (data = window->data; data; data = data->next) {
1967  if (data->name && SDL_strcmp(data->name, name) == 0) {
1968  return data->data;
1969  }
1970  }
1971  return NULL;
1972 }
#define SDL_InvalidParamError(param)
Definition: SDL_error.h:90

References CHECK_WINDOW_MAGIC, NULL, SDL_InvalidParamError, and SDL_strcmp.

Referenced by SDL_CreateWindowTexture(), and SDL_UpdateWindowTexture().

◆ SDL_GetWindowDisplayIndex()

int SDL_GetWindowDisplayIndex ( SDL_Window window)

Get the display index associated with a window.

Returns
the display index of the display containing the center of the window, or -1 on error.

Definition at line 1070 of file SDL_video.c.

1071 {
1072  int displayIndex;
1073  int i, dist;
1074  int closest = -1;
1075  int closest_dist = 0x7FFFFFFF;
1076  SDL_Point center;
1077  SDL_Point delta;
1078  SDL_Rect rect;
1079 
1081 
1084  displayIndex = (window->x & 0xFFFF);
1085  if (displayIndex >= _this->num_displays) {
1086  displayIndex = 0;
1087  }
1088  return displayIndex;
1089  }
1092  displayIndex = (window->y & 0xFFFF);
1093  if (displayIndex >= _this->num_displays) {
1094  displayIndex = 0;
1095  }
1096  return displayIndex;
1097  }
1098 
1099  /* Find the display containing the window */
1100  for (i = 0; i < _this->num_displays; ++i) {
1101  SDL_VideoDisplay *display = &_this->displays[i];
1102 
1103  if (display->fullscreen_window == window) {
1104  return i;
1105  }
1106  }
1107  center.x = window->x + window->w / 2;
1108  center.y = window->y + window->h / 2;
1109  for (i = 0; i < _this->num_displays; ++i) {
1111  if (SDL_EnclosePoints(&center, 1, &rect, NULL)) {
1112  return i;
1113  }
1114 
1115  delta.x = center.x - (rect.x + rect.w / 2);
1116  delta.y = center.y - (rect.y + rect.h / 2);
1117  dist = (delta.x*delta.x + delta.y*delta.y);
1118  if (dist < closest_dist) {
1119  closest = i;
1120  closest_dist = dist;
1121  }
1122  }
1123  if (closest < 0) {
1124  SDL_SetError("Couldn't find any displays");
1125  }
1126  return closest;
1127 }
#define SDL_EnclosePoints
The structure that defines a point (integer)
Definition: SDL_rect.h:49
int x
Definition: SDL_rect.h:50
int y
Definition: SDL_rect.h:51

References _this, CHECK_WINDOW_MAGIC, SDL_VideoDevice::displays, SDL_VideoDisplay::fullscreen_window, SDL_Rect::h, i, NULL, SDL_VideoDevice::num_displays, rect, SDL_EnclosePoints, SDL_GetDisplayBounds(), SDL_SetError, SDL_WINDOWPOS_ISCENTERED, SDL_WINDOWPOS_ISUNDEFINED, SDL_Rect::w, SDL_Point::x, SDL_Rect::x, SDL_Point::y, and SDL_Rect::y.

Referenced by SDL_GetDisplayForWindow(), and SDL_GetWindowPosition().

◆ SDL_GetWindowDisplayMode()

int SDL_GetWindowDisplayMode ( SDL_Window window,
SDL_DisplayMode mode 
)

Fill in information about the display mode used when a fullscreen window is visible.

See also
SDL_SetWindowDisplayMode()
SDL_SetWindowFullscreen()

Definition at line 1161 of file SDL_video.c.

1162 {
1163  SDL_DisplayMode fullscreen_mode;
1164  SDL_VideoDisplay *display;
1165 
1167 
1168  if (!mode) {
1169  return SDL_InvalidParamError("mode");
1170  }
1171 
1172  fullscreen_mode = window->fullscreen_mode;
1173  if (!fullscreen_mode.w) {
1174  fullscreen_mode.w = window->windowed.w;
1175  }
1176  if (!fullscreen_mode.h) {
1177  fullscreen_mode.h = window->windowed.h;
1178  }
1179 
1180  display = SDL_GetDisplayForWindow(window);
1181 
1182  /* if in desktop size mode, just return the size of the desktop */
1184  fullscreen_mode = display->desktop_mode;
1186  &fullscreen_mode,
1187  &fullscreen_mode)) {
1188  return SDL_SetError("Couldn't find display mode match");
1189  }
1190 
1191  if (mode) {
1192  *mode = fullscreen_mode;
1193  }
1194  return 0;
1195 }
@ SDL_WINDOW_FULLSCREEN_DESKTOP
Definition: SDL_video.h:110

References CHECK_WINDOW_MAGIC, SDL_VideoDisplay::desktop_mode, SDL_DisplayMode::h, SDL_GetClosestDisplayModeForDisplay(), SDL_GetDisplayForWindow(), SDL_InvalidParamError, SDL_SetError, SDL_WINDOW_FULLSCREEN_DESKTOP, and SDL_DisplayMode::w.

Referenced by SDL_SetWindowDisplayMode(), and SDL_UpdateFullscreenMode().

◆ SDL_GetWindowFlags()

Uint32 SDL_GetWindowFlags ( SDL_Window window)

Get the window flags.

Definition at line 1852 of file SDL_video.c.

1853 {
1855 
1856  return window->flags;
1857 }

References CHECK_WINDOW_MAGIC.

Referenced by SDL_ShowMessageBox().

◆ SDL_GetWindowFromID()

SDL_Window* SDL_GetWindowFromID ( Uint32  id)

Get a window from a stored ID, or NULL if it doesn't exist.

Definition at line 1836 of file SDL_video.c.

1837 {
1838  SDL_Window *window;
1839 
1840  if (!_this) {
1841  return NULL;
1842  }
1843  for (window = _this->windows; window; window = window->next) {
1844  if (window->id == id) {
1845  return window;
1846  }
1847  }
1848  return NULL;
1849 }

References _this, SDL_Window::next, NULL, and SDL_VideoDevice::windows.

◆ SDL_GetWindowGammaRamp()

int SDL_GetWindowGammaRamp ( SDL_Window window,
Uint16 red,
Uint16 green,
Uint16 blue 
)

Get the gamma ramp for a window.

Parameters
windowThe window from which the gamma ramp should be queried.
redA pointer to a 256 element array of 16-bit quantities to hold the translation table for the red channel, or NULL.
greenA pointer to a 256 element array of 16-bit quantities to hold the translation table for the green channel, or NULL.
blueA pointer to a 256 element array of 16-bit quantities to hold the translation table for the blue channel, or NULL.
Returns
0 on success, or -1 if gamma ramps are unsupported.
See also
SDL_SetWindowGammaRamp()

Definition at line 2591 of file SDL_video.c.

2594 {
2596 
2597  if (!window->gamma) {
2598  int i;
2599 
2600  window->gamma = (Uint16 *)SDL_malloc(256*6*sizeof(Uint16));
2601  if (!window->gamma) {
2602  return SDL_OutOfMemory();
2603  }
2604  window->saved_gamma = window->gamma + 3*256;
2605 
2606  if (_this->GetWindowGammaRamp) {
2607  if (_this->GetWindowGammaRamp(_this, window, window->gamma) < 0) {
2608  return -1;
2609  }
2610  } else {
2611  /* Create an identity gamma ramp */
2612  for (i = 0; i < 256; ++i) {
2613  Uint16 value = (Uint16)((i << 8) | i);
2614 
2615  window->gamma[0*256+i] = value;
2616  window->gamma[1*256+i] = value;
2617  window->gamma[2*256+i] = value;
2618  }
2619  }
2620  SDL_memcpy(window->saved_gamma, window->gamma, 3*256*sizeof(Uint16));
2621  }
2622 
2623  if (red) {
2624  SDL_memcpy(red, &window->gamma[0*256], 256*sizeof(Uint16));
2625  }
2626  if (green) {
2627  SDL_memcpy(green, &window->gamma[1*256], 256*sizeof(Uint16));
2628  }
2629  if (blue) {
2630  SDL_memcpy(blue, &window->gamma[2*256], 256*sizeof(Uint16));
2631  }
2632  return 0;
2633 }
#define SDL_memcpy
const GLubyte GLuint red
Definition: SDL_glfuncs.h:80
GLbyte GLbyte blue
GLbyte green
GLsizei const GLfloat * value
uint16_t Uint16
Definition: SDL_stdinc.h:197
int(* GetWindowGammaRamp)(_THIS, SDL_Window *window, Uint16 *ramp)
Definition: SDL_sysvideo.h:234

References _this, CHECK_WINDOW_MAGIC, SDL_VideoDevice::GetWindowGammaRamp, i, red, SDL_malloc, SDL_memcpy, and SDL_OutOfMemory.

Referenced by SDL_SetWindowGammaRamp().

◆ SDL_GetWindowGrab()

SDL_bool SDL_GetWindowGrab ( SDL_Window window)

Get a window's input grab mode.

Returns
This returns SDL_TRUE if input is grabbed, and SDL_FALSE otherwise.
See also
SDL_SetWindowGrab()

Definition at line 2683 of file SDL_video.c.

References _this, CHECK_WINDOW_MAGIC, SDL_Window::flags, SDL_VideoDevice::grabbed_window, SDL_assert, SDL_FALSE, and SDL_WINDOW_INPUT_GRABBED.

◆ SDL_GetWindowID()

Uint32 SDL_GetWindowID ( SDL_Window window)

Get the numeric ID of a window, for logging purposes.

Definition at line 1828 of file SDL_video.c.

1829 {
1831 
1832  return window->id;
1833 }

References CHECK_WINDOW_MAGIC.

◆ SDL_GetWindowMaximumSize()

void SDL_GetWindowMaximumSize ( SDL_Window window,
int w,
int h 
)

Get the maximum size of a window's client area.

Parameters
windowThe window to query.
wPointer to variable for storing the maximum width, may be NULL
hPointer to variable for storing the maximum height, may be NULL
See also
SDL_GetWindowMinimumSize()
SDL_SetWindowMaximumSize()

Definition at line 2252 of file SDL_video.c.

2253 {
2255  if (max_w) {
2256  *max_w = window->max_w;
2257  }
2258  if (max_h) {
2259  *max_h = window->max_h;
2260  }
2261 }

References CHECK_WINDOW_MAGIC.

◆ SDL_GetWindowMinimumSize()

void SDL_GetWindowMinimumSize ( SDL_Window window,
int w,
int h 
)

Get the minimum size of a window's client area.

Parameters
windowThe window to query.
wPointer to variable for storing the minimum width, may be NULL
hPointer to variable for storing the minimum height, may be NULL
See also
SDL_GetWindowMaximumSize()
SDL_SetWindowMinimumSize()

Definition at line 2210 of file SDL_video.c.

2211 {
2213  if (min_w) {
2214  *min_w = window->min_w;
2215  }
2216  if (min_h) {
2217  *min_h = window->min_h;
2218  }
2219 }

References CHECK_WINDOW_MAGIC.

◆ SDL_GetWindowOpacity()

int SDL_GetWindowOpacity ( SDL_Window window,
float *  out_opacity 
)

Get the opacity of a window.

If transparency isn't supported on this platform, opacity will be reported as 1.0f without error.

Parameters
windowThe window in question.
out_opacityOpacity (0.0f - transparent, 1.0f - opaque)
Returns
0 on success, or -1 on error (invalid window, etc).
See also
SDL_SetWindowOpacity()

Definition at line 2519 of file SDL_video.c.

2520 {
2522 
2523  if (out_opacity) {
2524  *out_opacity = window->opacity;
2525  }
2526 
2527  return 0;
2528 }

References CHECK_WINDOW_MAGIC.

◆ SDL_GetWindowPixelFormat()

Uint32 SDL_GetWindowPixelFormat ( SDL_Window window)

Get the pixel format associated with the window.

Definition at line 1198 of file SDL_video.c.

1199 {
1200  SDL_VideoDisplay *display;
1201 
1203 
1204  display = SDL_GetDisplayForWindow(window);
1205  return display->current_mode.format;
1206 }
@ SDL_PIXELFORMAT_UNKNOWN
Definition: SDL_pixels.h:173

References CHECK_WINDOW_MAGIC, SDL_VideoDisplay::current_mode, SDL_DisplayMode::format, SDL_GetDisplayForWindow(), and SDL_PIXELFORMAT_UNKNOWN.

◆ SDL_GetWindowPosition()

void SDL_GetWindowPosition ( SDL_Window window,
int x,
int y 
)

Get the position of a window.

Parameters
windowThe window to query.
xPointer to variable for storing the x position, in screen coordinates. May be NULL.
yPointer to variable for storing the y position, in screen coordinates. May be NULL.
See also
SDL_SetWindowPosition()

Definition at line 2019 of file SDL_video.c.

2020 {
2022 
2023  /* Fullscreen windows are always at their display's origin */
2024  if (window->flags & SDL_WINDOW_FULLSCREEN) {
2025  int displayIndex;
2026 
2027  if (x) {
2028  *x = 0;
2029  }
2030  if (y) {
2031  *y = 0;
2032  }
2033 
2034  /* Find the window's monitor and update to the
2035  monitor offset. */
2036  displayIndex = SDL_GetWindowDisplayIndex(window);
2037  if (displayIndex >= 0) {
2038  SDL_Rect bounds;
2039 
2040  SDL_zero(bounds);
2041 
2042  SDL_GetDisplayBounds(displayIndex, &bounds);
2043  if (x) {
2044  *x = bounds.x;
2045  }
2046  if (y) {
2047  *y = bounds.y;
2048  }
2049  }
2050  } else {
2051  if (x) {
2052  *x = window->x;
2053  }
2054  if (y) {
2055  *y = window->y;
2056  }
2057  }
2058 }

References CHECK_WINDOW_MAGIC, SDL_GetDisplayBounds(), SDL_GetWindowDisplayIndex(), SDL_WINDOW_FULLSCREEN, SDL_zero, SDL_Rect::x, and SDL_Rect::y.

◆ SDL_GetWindowSize()

void SDL_GetWindowSize ( SDL_Window window,
int w,
int h 
)

Get the size of a window's client area.

Parameters
windowThe window to query.
wPointer to variable for storing the width, in screen coordinates. May be NULL.
hPointer to variable for storing the height, in screen coordinates. May be NULL.

The window size in screen coordinates may differ from the size in pixels, if the window was created with SDL_WINDOW_ALLOW_HIGHDPI on a platform with high-dpi support (e.g. iOS or OS X). Use SDL_GL_GetDrawableSize() or SDL_GetRendererOutputSize() to get the real client area size in pixels.

See also
SDL_SetWindowSize()

Definition at line 2145 of file SDL_video.c.

2146 {
2148  if (w) {
2149  *w = window->w;
2150  }
2151  if (h) {
2152  *h = window->h;
2153  }
2154 }

References CHECK_WINDOW_MAGIC.

Referenced by SDL_GL_GetDrawableSize(), SDL_Metal_GetDrawableSize(), and SDL_Vulkan_GetDrawableSize().

◆ SDL_GetWindowSurface()

SDL_Surface* SDL_GetWindowSurface ( SDL_Window window)

Get the SDL surface associated with the window.

Returns
The window's framebuffer surface, or NULL on error.

A new surface will be created with the optimal format for the window, if necessary. This surface will be freed when the window is destroyed.

Note
You may not combine this with 3D or the rendering API on this window.
See also
SDL_UpdateWindowSurface()
SDL_UpdateWindowSurfaceRects()

Definition at line 2424 of file SDL_video.c.

2425 {
2427 
2428  if (!window->surface_valid) {
2429  if (window->surface) {
2430  window->surface->flags &= ~SDL_DONTFREE;
2431  SDL_FreeSurface(window->surface);
2432  window->surface = NULL;
2433  }
2435  if (window->surface) {
2436  window->surface_valid = SDL_TRUE;
2437  window->surface->flags |= SDL_DONTFREE;
2438  }
2439  }
2440  return window->surface;
2441 }
static SDL_Surface * SDL_CreateWindowFramebuffer(SDL_Window *window)
Definition: SDL_video.c:2396

References CHECK_WINDOW_MAGIC, NULL, SDL_CreateWindowFramebuffer(), SDL_DONTFREE, SDL_FreeSurface, and SDL_TRUE.

◆ SDL_GetWindowTitle()

const char* SDL_GetWindowTitle ( SDL_Window window)

Get the title of a window, in UTF-8 format.

See also
SDL_SetWindowTitle()

Definition at line 1877 of file SDL_video.c.

1878 {
1880 
1881  return window->title ? window->title : "";
1882 }

References CHECK_WINDOW_MAGIC.

◆ SDL_GetWindowWMInfo()

SDL_bool SDL_GetWindowWMInfo ( SDL_Window window,
SDL_SysWMinfo info 
)

This function allows access to driver-dependent window information.

Parameters
windowThe window about which information is being requested
infoThis structure must be initialized with the SDL version, and is then filled in with information about the given window.
Returns
SDL_TRUE if the function is implemented and the version member of the info struct is valid, SDL_FALSE otherwise.

You typically use this function like this:

if ( SDL_GetWindowWMInfo(window, &info) ) { ... }
#define SDL_GetWindowWMInfo
#define SDL_VERSION(x)
Macro to determine SDL version program was compiled against.
Definition: SDL_version.h:79
SDL_version version
Definition: SDL_syswm.h:218

Definition at line 3857 of file SDL_video.c.

3858 {
3860 
3861  if (!info) {
3862  SDL_InvalidParamError("info");
3863  return SDL_FALSE;
3864  }
3865  info->subsystem = SDL_SYSWM_UNKNOWN;
3866 
3867  if (!_this->GetWindowWMInfo) {
3868  SDL_Unsupported();
3869  return SDL_FALSE;
3870  }
3871  return (_this->GetWindowWMInfo(_this, window, info));
3872 }
@ SDL_SYSWM_UNKNOWN
Definition: SDL_syswm.h:129
SDL_SYSWM_TYPE subsystem
Definition: SDL_syswm.h:219
SDL_bool(* GetWindowWMInfo)(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info)
Definition: SDL_sysvideo.h:249

References _this, CHECK_WINDOW_MAGIC, SDL_VideoDevice::GetWindowWMInfo, SDL_FALSE, SDL_InvalidParamError, SDL_SYSWM_UNKNOWN, SDL_Unsupported, and SDL_SysWMinfo::subsystem.

Referenced by SDL_MessageboxValidForDriver().

◆ SDL_GL_CreateContext()

SDL_GLContext SDL_GL_CreateContext ( SDL_Window window)

Create an OpenGL context for use with an OpenGL window, and make it current.

See also
SDL_GL_DeleteContext()

Definition at line 3611 of file SDL_video.c.

3612 {
3615 
3616  if (!(window->flags & SDL_WINDOW_OPENGL)) {
3617  SDL_SetError("The specified window isn't an OpenGL window");
3618  return NULL;
3619  }
3620 
3622 
3623  /* Creating a context is assumed to make it current in the SDL driver. */
3624  if (ctx) {
3626  _this->current_glctx = ctx;
3629  }
3630  return ctx;
3631 }
#define SDL_TLSSet
void * SDL_GLContext
An opaque handle to an OpenGL context.
Definition: SDL_video.h:195
EGLContext ctx
Definition: eglext.h:208
SDL_GLContext current_glctx
Definition: SDL_sysvideo.h:374
SDL_TLSID current_glwin_tls
Definition: SDL_sysvideo.h:375
SDL_TLSID current_glctx_tls
Definition: SDL_sysvideo.h:376

References _this, CHECK_WINDOW_MAGIC, SDL_VideoDevice::current_glctx, SDL_VideoDevice::current_glctx_tls, SDL_VideoDevice::current_glwin, SDL_VideoDevice::current_glwin_tls, SDL_VideoDevice::GL_CreateContext, NULL, SDL_SetError, SDL_TLSSet, and SDL_WINDOW_OPENGL.

Referenced by ShouldUseTextureFramebuffer().

◆ SDL_GL_DeduceMaxSupportedESProfile()

void SDL_GL_DeduceMaxSupportedESProfile ( int major,
int minor 
)

Definition at line 3162 of file SDL_video.c.

3163 {
3164 /* THIS REQUIRES AN EXISTING GL CONTEXT THAT HAS BEEN MADE CURRENT. */
3165 /* Please refer to https://bugzilla.libsdl.org/show_bug.cgi?id=3725 for discussion. */
3166 #if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
3167  /* XXX This is fragile; it will break in the event of release of
3168  * new versions of OpenGL ES.
3169  */
3170  if (SDL_GL_ExtensionSupported("GL_ARB_ES3_2_compatibility")) {
3171  *major = 3;
3172  *minor = 2;
3173  } else if (SDL_GL_ExtensionSupported("GL_ARB_ES3_1_compatibility")) {
3174  *major = 3;
3175  *minor = 1;
3176  } else if (SDL_GL_ExtensionSupported("GL_ARB_ES3_compatibility")) {
3177  *major = 3;
3178  *minor = 0;
3179  } else {
3180  *major = 2;
3181  *minor = 0;
3182  }
3183 #endif
3184 }
SDL_bool SDL_GL_ExtensionSupported(const char *extension)
Return true if an OpenGL extension is supported for the current context.
Definition: SDL_video.c:3072

References SDL_GL_ExtensionSupported().

◆ SDL_GL_DeleteContext()

void SDL_GL_DeleteContext ( SDL_GLContext  context)

Delete an OpenGL context.

See also
SDL_GL_CreateContext()

Definition at line 3744 of file SDL_video.c.

3745 {
3746  if (!_this || !context) {
3747  return;
3748  }
3749 
3750  if (SDL_GL_GetCurrentContext() == context) {
3752  }
3753 
3755 }
SDL_GLContext SDL_GL_GetCurrentContext(void)
Get the currently active OpenGL context.
Definition: SDL_video.c:3677
void(* GL_DeleteContext)(_THIS, SDL_GLContext context)
Definition: SDL_sysvideo.h:265
static screen_context_t context
Definition: video.c:25

References _this, context, SDL_VideoDevice::GL_DeleteContext, NULL, SDL_GL_GetCurrentContext(), and SDL_GL_MakeCurrent().

Referenced by ShouldUseTextureFramebuffer().

◆ SDL_GL_ExtensionSupported()

SDL_bool SDL_GL_ExtensionSupported ( const char *  extension)

Return true if an OpenGL extension is supported for the current context.

Definition at line 3072 of file SDL_video.c.

3073 {
3074 #if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
3075  const GLubyte *(APIENTRY * glGetStringFunc) (GLenum);
3076  const char *extensions;
3077  const char *start;
3078  const char *where, *terminator;
3079 
3080  /* Extension names should not have spaces. */
3081  where = SDL_strchr(extension, ' ');
3082  if (where || *extension == '\0') {
3083  return SDL_FALSE;
3084  }
3085  /* See if there's an environment variable override */
3086  start = SDL_getenv(extension);
3087  if (start && *start == '0') {
3088  return SDL_FALSE;
3089  }
3090 
3091  /* Lookup the available extensions */
3092 
3093  glGetStringFunc = SDL_GL_GetProcAddress("glGetString");
3094  if (!glGetStringFunc) {
3095  return SDL_FALSE;
3096  }
3097 
3098  if (isAtLeastGL3((const char *) glGetStringFunc(GL_VERSION))) {
3099  const GLubyte *(APIENTRY * glGetStringiFunc) (GLenum, GLuint);
3100  void (APIENTRY * glGetIntegervFunc) (GLenum pname, GLint * params);
3101  GLint num_exts = 0;
3102  GLint i;
3103 
3104  glGetStringiFunc = SDL_GL_GetProcAddress("glGetStringi");
3105  glGetIntegervFunc = SDL_GL_GetProcAddress("glGetIntegerv");
3106  if ((!glGetStringiFunc) || (!glGetIntegervFunc)) {
3107  return SDL_FALSE;
3108  }
3109 
3110  #ifndef GL_NUM_EXTENSIONS
3111  #define GL_NUM_EXTENSIONS 0x821D
3112  #endif
3113  glGetIntegervFunc(GL_NUM_EXTENSIONS, &num_exts);
3114  for (i = 0; i < num_exts; i++) {
3115  const char *thisext = (const char *) glGetStringiFunc(GL_EXTENSIONS, i);
3116  if (SDL_strcmp(thisext, extension) == 0) {
3117  return SDL_TRUE;
3118  }
3119  }
3120 
3121  return SDL_FALSE;
3122  }
3123 
3124  /* Try the old way with glGetString(GL_EXTENSIONS) ... */
3125 
3126  extensions = (const char *) glGetStringFunc(GL_EXTENSIONS);
3127  if (!extensions) {
3128  return SDL_FALSE;
3129  }
3130  /*
3131  * It takes a bit of care to be fool-proof about parsing the OpenGL
3132  * extensions string. Don't be fooled by sub-strings, etc.
3133  */
3134 
3135  start = extensions;
3136 
3137  for (;;) {
3138  where = SDL_strstr(start, extension);
3139  if (!where)
3140  break;
3141 
3142  terminator = where + SDL_strlen(extension);
3143  if (where == extensions || *(where - 1) == ' ')
3144  if (*terminator == ' ' || *terminator == '\0')
3145  return SDL_TRUE;
3146 
3147  start = terminator;
3148  }
3149  return SDL_FALSE;
3150 #else
3151  return SDL_FALSE;
3152 #endif
3153 }
#define SDL_strchr
#define SDL_getenv
#define SDL_strlen
#define SDL_strstr
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
unsigned char GLubyte
Definition: SDL_opengl.h:183
#define GL_VERSION
Definition: SDL_opengl.h:715
#define APIENTRY
Definition: SDL_opengl.h:139
unsigned int GLenum
Definition: SDL_opengl.h:176
unsigned int GLuint
Definition: SDL_opengl.h:185
#define GL_EXTENSIONS
Definition: SDL_opengl.h:716
GLuint start
Definition: SDL_opengl.h:1571
int GLint
Definition: SDL_opengl.h:182
const GLfloat * params
GLenum pname
static SDL_INLINE SDL_bool isAtLeastGL3(const char *verstr)
Definition: SDL_video.c:3065
void * SDL_GL_GetProcAddress(const char *proc)
Get the address of an OpenGL function.
Definition: SDL_video.c:3025
#define GL_NUM_EXTENSIONS

References APIENTRY, GL_EXTENSIONS, GL_NUM_EXTENSIONS, GL_VERSION, i, isAtLeastGL3(), SDL_FALSE, SDL_getenv, SDL_GL_GetProcAddress(), SDL_strchr, SDL_strcmp, SDL_strlen, SDL_strstr, SDL_TRUE, and void.

Referenced by SDL_GL_DeduceMaxSupportedESProfile().

◆ SDL_GL_GetAttribute()

int SDL_GL_GetAttribute ( SDL_GLattr  attr,
int value 
)

Get the actual value for an attribute from the current context.

Returns
0 on success, or -1 if the attribute could not be retrieved. The integer at value will be modified in either case.

Definition at line 3362 of file SDL_video.c.

3363 {
3364 #if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
3365  GLenum (APIENTRY *glGetErrorFunc) (void);
3366  GLenum attrib = 0;
3367  GLenum error = 0;
3368 
3369  /*
3370  * Some queries in Core Profile desktop OpenGL 3+ contexts require
3371  * glGetFramebufferAttachmentParameteriv instead of glGetIntegerv. Note that
3372  * the enums we use for the former function don't exist in OpenGL ES 2, and
3373  * the function itself doesn't exist prior to OpenGL 3 and OpenGL ES 2.
3374  */
3375 #if SDL_VIDEO_OPENGL
3376  const GLubyte *(APIENTRY *glGetStringFunc) (GLenum name);
3377  void (APIENTRY *glGetFramebufferAttachmentParameterivFunc) (GLenum target, GLenum attachment, GLenum pname, GLint* params);
3379  GLenum attachmentattrib = 0;
3380 #endif
3381 
3382  if (!value) {
3383  return SDL_InvalidParamError("value");
3384  }
3385 
3386  /* Clear value in any case */
3387  *value = 0;
3388 
3389  if (!_this) {
3390  return SDL_UninitializedVideo();
3391  }
3392 
3393  switch (attr) {
3394  case SDL_GL_RED_SIZE:
3395 #if SDL_VIDEO_OPENGL
3396  attachmentattrib = GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE;
3397 #endif
3398  attrib = GL_RED_BITS;
3399  break;
3400  case SDL_GL_BLUE_SIZE:
3401 #if SDL_VIDEO_OPENGL
3402  attachmentattrib = GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE;
3403 #endif
3404  attrib = GL_BLUE_BITS;
3405  break;
3406  case SDL_GL_GREEN_SIZE:
3407 #if SDL_VIDEO_OPENGL
3408  attachmentattrib = GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE;
3409 #endif
3410  attrib = GL_GREEN_BITS;
3411  break;
3412  case SDL_GL_ALPHA_SIZE:
3413 #if SDL_VIDEO_OPENGL
3414  attachmentattrib = GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE;
3415 #endif
3416  attrib = GL_ALPHA_BITS;
3417  break;
3418  case SDL_GL_DOUBLEBUFFER:
3419 #if SDL_VIDEO_OPENGL
3420  attrib = GL_DOUBLEBUFFER;
3421  break;
3422 #else
3423  /* OpenGL ES 1.0 and above specifications have EGL_SINGLE_BUFFER */
3424  /* parameter which switches double buffer to single buffer. OpenGL ES */
3425  /* SDL driver must set proper value after initialization */
3427  return 0;
3428 #endif
3429  case SDL_GL_DEPTH_SIZE:
3430 #if SDL_VIDEO_OPENGL
3431  attachment = GL_DEPTH;
3432  attachmentattrib = GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE;
3433 #endif
3434  attrib = GL_DEPTH_BITS;
3435  break;
3436  case SDL_GL_STENCIL_SIZE:
3437 #if SDL_VIDEO_OPENGL
3439  attachmentattrib = GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE;
3440 #endif
3441  attrib = GL_STENCIL_BITS;
3442  break;
3443 #if SDL_VIDEO_OPENGL
3444  case SDL_GL_ACCUM_RED_SIZE:
3445  attrib = GL_ACCUM_RED_BITS;
3446  break;
3448  attrib = GL_ACCUM_GREEN_BITS;
3449  break;
3451  attrib = GL_ACCUM_BLUE_BITS;
3452  break;
3454  attrib = GL_ACCUM_ALPHA_BITS;
3455  break;
3456  case SDL_GL_STEREO:
3457  attrib = GL_STEREO;
3458  break;
3459 #else
3460  case SDL_GL_ACCUM_RED_SIZE:
3464  case SDL_GL_STEREO:
3465  /* none of these are supported in OpenGL ES */
3466  *value = 0;
3467  return 0;
3468 #endif
3470  attrib = GL_SAMPLE_BUFFERS;
3471  break;
3473  attrib = GL_SAMPLES;
3474  break;
3476 #if SDL_VIDEO_OPENGL
3477  attrib = GL_CONTEXT_RELEASE_BEHAVIOR;
3478 #else
3480 #endif
3481  break;
3482  case SDL_GL_BUFFER_SIZE:
3483  {
3484  int rsize = 0, gsize = 0, bsize = 0, asize = 0;
3485 
3486  /* There doesn't seem to be a single flag in OpenGL for this! */
3487  if (SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &rsize) < 0) {
3488  return -1;
3489  }
3490  if (SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &gsize) < 0) {
3491  return -1;
3492  }
3493  if (SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &bsize) < 0) {
3494  return -1;
3495  }
3496  if (SDL_GL_GetAttribute(SDL_GL_ALPHA_SIZE, &asize) < 0) {
3497  return -1;
3498  }
3499 
3500  *value = rsize + gsize + bsize + asize;
3501  return 0;
3502  }
3504  {
3505  /* FIXME: How do we get this information? */
3506  *value = (_this->gl_config.accelerated != 0);
3507  return 0;
3508  }
3510  {
3512  return 0;
3513  }
3515  {
3517  return 0;
3518  }
3520  {
3522  return 0;
3523  }
3524  case SDL_GL_CONTEXT_EGL:
3525  /* FIXME: SDL_GL_CONTEXT_EGL to be deprecated in SDL 2.1 */
3526  {
3528  *value = 1;
3529  }
3530  else {
3531  *value = 0;
3532  }
3533  return 0;
3534  }
3535  case SDL_GL_CONTEXT_FLAGS:
3536  {
3537  *value = _this->gl_config.flags;
3538  return 0;
3539  }
3541  {
3543  return 0;
3544  }
3546  {
3548  return 0;
3549  }
3551  {
3553  return 0;
3554  }
3556  {
3558  return 0;
3559  }
3560  default:
3561  return SDL_SetError("Unknown OpenGL attribute");
3562  }
3563 
3564 #if SDL_VIDEO_OPENGL
3565  glGetStringFunc = SDL_GL_GetProcAddress("glGetString");
3566  if (!glGetStringFunc) {
3567  return -1;
3568  }
3569 
3570  if (attachmentattrib && isAtLeastGL3((const char *) glGetStringFunc(GL_VERSION))) {
3571  glGetFramebufferAttachmentParameterivFunc = SDL_GL_GetProcAddress("glGetFramebufferAttachmentParameteriv");
3572 
3573  if (glGetFramebufferAttachmentParameterivFunc) {
3574  glGetFramebufferAttachmentParameterivFunc(GL_FRAMEBUFFER, attachment, attachmentattrib, (GLint *) value);
3575  } else {
3576  return -1;
3577  }
3578  } else
3579 #endif
3580  {
3581  void (APIENTRY *glGetIntegervFunc) (GLenum pname, GLint * params);
3582  glGetIntegervFunc = SDL_GL_GetProcAddress("glGetIntegerv");
3583  if (glGetIntegervFunc) {
3584  glGetIntegervFunc(attrib, (GLint *) value);
3585  } else {
3586  return -1;
3587  }
3588  }
3589 
3590  glGetErrorFunc = SDL_GL_GetProcAddress("glGetError");
3591  if (!glGetErrorFunc) {
3592  return -1;
3593  }
3594 
3595  error = glGetErrorFunc();
3596  if (error != GL_NO_ERROR) {
3597  if (error == GL_INVALID_ENUM) {
3598  return SDL_SetError("OpenGL error: GL_INVALID_ENUM");
3599  } else if (error == GL_INVALID_VALUE) {
3600  return SDL_SetError("OpenGL error: GL_INVALID_VALUE");
3601  }
3602  return SDL_SetError("OpenGL error: %08X", error);
3603  }
3604  return 0;
3605 #else
3606  return SDL_Unsupported();
3607 #endif /* SDL_VIDEO_OPENGL */
3608 }
#define GL_DOUBLEBUFFER
Definition: SDL_opengl.h:521
#define GL_INVALID_VALUE
Definition: SDL_opengl.h:721
#define GL_STENCIL_BITS
Definition: SDL_opengl.h:474
#define GL_SAMPLES
Definition: SDL_opengl.h:1840
#define GL_GREEN_BITS
Definition: SDL_opengl.h:514
#define GL_BACK_LEFT
Definition: SDL_opengl.h:499
#define GL_STENCIL
Definition: SDL_opengl.h:526
#define GL_ACCUM_ALPHA_BITS
Definition: SDL_opengl.h:383
#define GL_DEPTH_BITS
Definition: SDL_opengl.h:328
#define GL_SAMPLE_BUFFERS
Definition: SDL_opengl.h:1839
#define GL_NO_ERROR
Definition: SDL_opengl.h:719
#define GL_BLUE_BITS
Definition: SDL_opengl.h:515
#define GL_DEPTH
Definition: SDL_opengl.h:525
#define GL_ALPHA_BITS
Definition: SDL_opengl.h:512
#define GL_ACCUM_GREEN_BITS
Definition: SDL_opengl.h:381
#define GL_ACCUM_BLUE_BITS
Definition: SDL_opengl.h:382
#define GL_STEREO
Definition: SDL_opengl.h:522
#define GL_INVALID_ENUM
Definition: SDL_opengl.h:720
#define GL_RED_BITS
Definition: SDL_opengl.h:513
#define GL_ACCUM_RED_BITS
Definition: SDL_opengl.h:380
#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE
#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE
#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE
#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE
#define GL_FRAMEBUFFER
#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE
GLenum attachment
#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE
#define GL_CONTEXT_RELEASE_BEHAVIOR
GLenum target
int SDL_GL_GetAttribute(SDL_GLattr attr, int *value)
Get the actual value for an attribute from the current context.
Definition: SDL_video.c:3362
@ SDL_GL_FRAMEBUFFER_SRGB_CAPABLE
Definition: SDL_video.h:225
@ SDL_GL_CONTEXT_RELEASE_BEHAVIOR
Definition: SDL_video.h:226
@ SDL_GL_DOUBLEBUFFER
Definition: SDL_video.h:207
@ SDL_GL_STENCIL_SIZE
Definition: SDL_video.h:209
@ SDL_GL_CONTEXT_MAJOR_VERSION
Definition: SDL_video.h:219
@ SDL_GL_CONTEXT_EGL
Definition: SDL_video.h:221
@ SDL_GL_ACCUM_ALPHA_SIZE
Definition: SDL_video.h:213
@ SDL_GL_MULTISAMPLESAMPLES
Definition: SDL_video.h:216
@ SDL_GL_CONTEXT_MINOR_VERSION
Definition: SDL_video.h:220
@ SDL_GL_STEREO
Definition: SDL_video.h:214
@ SDL_GL_MULTISAMPLEBUFFERS
Definition: SDL_video.h:215
@ SDL_GL_ACCUM_GREEN_SIZE
Definition: SDL_video.h:211
@ SDL_GL_BLUE_SIZE
Definition: SDL_video.h:204
@ SDL_GL_SHARE_WITH_CURRENT_CONTEXT
Definition: SDL_video.h:224
@ SDL_GL_RETAINED_BACKING
Definition: SDL_video.h:218
@ SDL_GL_RED_SIZE
Definition: SDL_video.h:202
@ SDL_GL_ALPHA_SIZE
Definition: SDL_video.h:205
@ SDL_GL_BUFFER_SIZE
Definition: SDL_video.h:206
@ SDL_GL_ACCELERATED_VISUAL
Definition: SDL_video.h:217
@ SDL_GL_ACCUM_BLUE_SIZE
Definition: SDL_video.h:212
@ SDL_GL_DEPTH_SIZE
Definition: SDL_video.h:208
@ SDL_GL_ACCUM_RED_SIZE
Definition: SDL_video.h:210
@ SDL_GL_CONTEXT_FLAGS
Definition: SDL_video.h:222
@ SDL_GL_CONTEXT_PROFILE_MASK
Definition: SDL_video.h:223
@ SDL_GL_CONTEXT_NO_ERROR
Definition: SDL_video.h:228
@ SDL_GL_GREEN_SIZE
Definition: SDL_video.h:203
@ SDL_GL_CONTEXT_PROFILE_ES
Definition: SDL_video.h:235
#define GL_CONTEXT_RELEASE_BEHAVIOR_KHR
Definition: gl2ext.h:83
int framebuffer_srgb_capable
Definition: SDL_sysvideo.h:360
struct SDL_VideoDevice::@440 gl_config
int share_with_current_context
Definition: SDL_sysvideo.h:357

References _this, SDL_VideoDevice::accelerated, APIENTRY, SDL_VideoDevice::double_buffer, SDL_VideoDevice::flags, SDL_VideoDevice::framebuffer_srgb_capable, GL_ACCUM_ALPHA_BITS, GL_ACCUM_BLUE_BITS, GL_ACCUM_GREEN_BITS, GL_ACCUM_RED_BITS, GL_ALPHA_BITS, GL_BACK_LEFT, GL_BLUE_BITS, SDL_VideoDevice::gl_config, GL_CONTEXT_RELEASE_BEHAVIOR, GL_CONTEXT_RELEASE_BEHAVIOR_KHR, GL_DEPTH, GL_DEPTH_BITS, GL_DOUBLEBUFFER, GL_FRAMEBUFFER, GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE, GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE, GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE, GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE, GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE, GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE, GL_GREEN_BITS, GL_INVALID_ENUM, GL_INVALID_VALUE, GL_NO_ERROR, GL_RED_BITS, GL_SAMPLE_BUFFERS, GL_SAMPLES, GL_STENCIL, GL_STENCIL_BITS, GL_STEREO, GL_VERSION, isAtLeastGL3(), SDL_VideoDevice::major_version, SDL_VideoDevice::minor_version, SDL_VideoDevice::no_error, SDL_VideoDevice::profile_mask, SDL_VideoDevice::retained_backing, SDL_GL_ACCELERATED_VISUAL, SDL_GL_ACCUM_ALPHA_SIZE, SDL_GL_ACCUM_BLUE_SIZE, SDL_GL_ACCUM_GREEN_SIZE, SDL_GL_ACCUM_RED_SIZE, SDL_GL_ALPHA_SIZE, SDL_GL_BLUE_SIZE, SDL_GL_BUFFER_SIZE, SDL_GL_CONTEXT_EGL, SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_MAJOR_VERSION, SDL_GL_CONTEXT_MINOR_VERSION, SDL_GL_CONTEXT_NO_ERROR, SDL_GL_CONTEXT_PROFILE_ES, SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_RELEASE_BEHAVIOR, SDL_GL_DEPTH_SIZE, SDL_GL_DOUBLEBUFFER, SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, SDL_GL_GetAttribute(), SDL_GL_GetProcAddress(), SDL_GL_GREEN_SIZE, SDL_GL_MULTISAMPLEBUFFERS, SDL_GL_MULTISAMPLESAMPLES, SDL_GL_RED_SIZE, SDL_GL_RETAINED_BACKING, SDL_GL_SHARE_WITH_CURRENT_CONTEXT, SDL_GL_STENCIL_SIZE, SDL_GL_STEREO, SDL_InvalidParamError, SDL_SetError, SDL_UninitializedVideo(), SDL_Unsupported, SDL_VideoDevice::share_with_current_context, and void.

Referenced by SDL_GL_GetAttribute().

◆ SDL_GL_GetCurrentContext()

SDL_GLContext SDL_GL_GetCurrentContext ( void  )

Get the currently active OpenGL context.

Definition at line 3677 of file SDL_video.c.

3678 {
3679  if (!_this) {
3681  return NULL;
3682  }
3684 }
#define SDL_TLSGet

References _this, SDL_VideoDevice::current_glctx_tls, NULL, SDL_TLSGet, and SDL_UninitializedVideo().

Referenced by SDL_GL_DeleteContext(), SDL_GL_GetSwapInterval(), SDL_GL_MakeCurrent(), and SDL_GL_SetSwapInterval().

◆ SDL_GL_GetCurrentWindow()

SDL_Window* SDL_GL_GetCurrentWindow ( void  )

Get the currently active OpenGL window.

Definition at line 3667 of file SDL_video.c.

3668 {
3669  if (!_this) {
3671  return NULL;
3672  }
3674 }

References _this, SDL_VideoDevice::current_glwin_tls, NULL, SDL_TLSGet, and SDL_UninitializedVideo().

Referenced by SDL_GL_MakeCurrent(), and SDL_GL_SwapWindow().

◆ SDL_GL_GetDrawableSize()

void SDL_GL_GetDrawableSize ( SDL_Window window,
int w,
int h 
)

Get the size of a window's underlying drawable in pixels (for use with glViewport).

Parameters
windowWindow from which the drawable size should be queried
wPointer to variable for storing the width in pixels, may be NULL
hPointer to variable for storing the height in pixels, may be NULL

This may differ from SDL_GetWindowSize() if we're rendering to a high-DPI drawable, i.e. the window was created with SDL_WINDOW_ALLOW_HIGHDPI on a platform with high-DPI support (Apple calls this "Retina"), and not disabled by the SDL_HINT_VIDEO_HIGHDPI_DISABLED hint.

See also
SDL_GetWindowSize()
SDL_CreateWindow()

Definition at line 3686 of file SDL_video.c.

3687 {
3689 
3690  if (_this->GL_GetDrawableSize) {
3692  } else {
3694  }
3695 }
void SDL_GetWindowSize(SDL_Window *window, int *w, int *h)
Get the size of a window's client area.
Definition: SDL_video.c:2145
void(* GL_GetDrawableSize)(_THIS, SDL_Window *window, int *w, int *h)
Definition: SDL_sysvideo.h:261

References _this, CHECK_WINDOW_MAGIC, SDL_VideoDevice::GL_GetDrawableSize, and SDL_GetWindowSize().

◆ SDL_GL_GetProcAddress()

void* SDL_GL_GetProcAddress ( const char *  proc)

Get the address of an OpenGL function.

Definition at line 3025 of file SDL_video.c.

3026 {
3027  void *func;
3028 
3029  if (!_this) {
3031  return NULL;
3032  }
3033  func = NULL;
3034  if (_this->GL_GetProcAddress) {
3035  if (_this->gl_config.driver_loaded) {
3036  func = _this->GL_GetProcAddress(_this, proc);
3037  } else {
3038  SDL_SetError("No GL driver has been loaded");
3039  }
3040  } else {
3041  SDL_SetError("No dynamic GL support in current SDL video driver (%s)", _this->name);
3042  }
3043  return func;
3044 }
GLenum func
void *(* GL_GetProcAddress)(_THIS, const char *proc)
Definition: SDL_sysvideo.h:257

References _this, SDL_VideoDevice::driver_loaded, SDL_VideoDevice::gl_config, SDL_VideoDevice::GL_GetProcAddress, SDL_VideoDevice::name, NULL, SDL_SetError, and SDL_UninitializedVideo().

Referenced by SDL_GL_ExtensionSupported(), SDL_GL_GetAttribute(), and ShouldUseTextureFramebuffer().

◆ SDL_GL_GetSwapInterval()

int SDL_GL_GetSwapInterval ( void  )

Get the swap interval for the current OpenGL context.

Returns
0 if there is no vertical retrace synchronization, 1 if the buffer swap is synchronized with the vertical retrace, and -1 if late swaps happen immediately instead of waiting for the next retrace. If the system can't determine the swap interval, or there isn't a valid current context, this will return 0 as a safe default.
See also
SDL_GL_SetSwapInterval()

Definition at line 3712 of file SDL_video.c.

3713 {
3714  if (!_this) {
3715  return 0;
3716  } else if (SDL_GL_GetCurrentContext() == NULL) {
3717  return 0;
3718  } else if (_this->GL_GetSwapInterval) {
3719  return _this->GL_GetSwapInterval(_this);
3720  } else {
3721  return 0;
3722  }
3723 }
int(* GL_GetSwapInterval)(_THIS)
Definition: SDL_sysvideo.h:263

References _this, SDL_VideoDevice::GL_GetSwapInterval, NULL, and SDL_GL_GetCurrentContext().

◆ SDL_GL_LoadLibrary()

int SDL_GL_LoadLibrary ( const char *  path)

Dynamically load an OpenGL library.

Parameters
pathThe platform dependent OpenGL library name, or NULL to open the default OpenGL library.
Returns
0 on success, or -1 if the library couldn't be loaded.

This should be done after initializing the video driver, but before creating any OpenGL windows. If no OpenGL library is loaded, the default library will be loaded upon creation of the first OpenGL window.

Note
If you do this, you need to retrieve all of the GL functions used in your program from the dynamic library using SDL_GL_GetProcAddress().
See also
SDL_GL_GetProcAddress()
SDL_GL_UnloadLibrary()

Definition at line 2996 of file SDL_video.c.

2997 {
2998  int retval;
2999 
3000  if (!_this) {
3001  return SDL_UninitializedVideo();
3002  }
3003  if (_this->gl_config.driver_loaded) {
3004  if (path && SDL_strcmp(path, _this->gl_config.driver_path) != 0) {
3005  return SDL_SetError("OpenGL library already loaded");
3006  }
3007  retval = 0;
3008  } else {
3009  if (!_this->GL_LoadLibrary) {
3010  return SDL_SetError("No dynamic GL support in current SDL video driver (%s)", _this->name);
3011  }
3013  }
3014  if (retval == 0) {
3016  } else {
3017  if (_this->GL_UnloadLibrary) {
3019  }
3020  }
3021  return (retval);
3022 }
GLsizei const GLchar *const * path
char driver_path[256]
Definition: SDL_sysvideo.h:364
void(* GL_UnloadLibrary)(_THIS)
Definition: SDL_sysvideo.h:258
int(* GL_LoadLibrary)(_THIS, const char *path)
Definition: SDL_sysvideo.h:256

References _this, SDL_VideoDevice::driver_loaded, SDL_VideoDevice::driver_path, SDL_VideoDevice::gl_config, SDL_VideoDevice::GL_LoadLibrary, SDL_VideoDevice::GL_UnloadLibrary, SDL_VideoDevice::name, retval, SDL_SetError, SDL_strcmp, and SDL_UninitializedVideo().

Referenced by SDL_CreateWindow(), and SDL_RecreateWindow().

◆ SDL_GL_MakeCurrent()

int SDL_GL_MakeCurrent ( SDL_Window window,
SDL_GLContext  context 
)

Set up an OpenGL context for rendering into an OpenGL window.

Note
The context must have been created with a compatible window.

Definition at line 3634 of file SDL_video.c.

3635 {
3636  int retval;
3637 
3638  if (window == SDL_GL_GetCurrentWindow() &&
3640  /* We're already current. */
3641  return 0;
3642  }
3643 
3644  if (!ctx) {
3645  window = NULL;
3646  } else if (window) {
3648 
3649  if (!(window->flags & SDL_WINDOW_OPENGL)) {
3650  return SDL_SetError("The specified window isn't an OpenGL window");
3651  }
3652  } else if (!_this->gl_allow_no_surface) {
3653  return SDL_SetError("Use of OpenGL without a window is not supported on this platform");
3654  }
3655 
3657  if (retval == 0) {
3659  _this->current_glctx = ctx;
3662  }
3663  return retval;
3664 }
SDL_Window * SDL_GL_GetCurrentWindow(void)
Get the currently active OpenGL window.
Definition: SDL_video.c:3667
int(* GL_MakeCurrent)(_THIS, SDL_Window *window, SDL_GLContext context)
Definition: SDL_sysvideo.h:260
SDL_bool gl_allow_no_surface
Definition: SDL_sysvideo.h:381

References _this, CHECK_WINDOW_MAGIC, SDL_VideoDevice::current_glctx, SDL_VideoDevice::current_glctx_tls, SDL_VideoDevice::current_glwin, SDL_VideoDevice::current_glwin_tls, SDL_VideoDevice::gl_allow_no_surface, SDL_VideoDevice::GL_MakeCurrent, NULL, retval, SDL_GL_GetCurrentContext(), SDL_GL_GetCurrentWindow(), SDL_SetError, SDL_TLSSet, and SDL_WINDOW_OPENGL.

Referenced by SDL_DestroyWindow(), and SDL_GL_DeleteContext().

◆ SDL_GL_ResetAttributes()

void SDL_GL_ResetAttributes ( void  )

Reset all previously set OpenGL context attributes to their default values.

Definition at line 3187 of file SDL_video.c.

3188 {
3189  if (!_this) {
3190  return;
3191  }
3192 
3193  _this->gl_config.red_size = 3;
3194  _this->gl_config.green_size = 3;
3195  _this->gl_config.blue_size = 2;
3196  _this->gl_config.alpha_size = 0;
3198  _this->gl_config.depth_size = 16;
3205  _this->gl_config.stereo = 0;
3209  _this->gl_config.accelerated = -1; /* accelerated or not, both are fine */
3210 
3211 #if SDL_VIDEO_OPENGL
3215 #elif SDL_VIDEO_OPENGL_ES2
3219 #elif SDL_VIDEO_OPENGL_ES
3223 #endif
3224 
3229  }
3230 
3231  _this->gl_config.flags = 0;
3233  _this->gl_config.no_error = 0;
3236 
3238 }
@ SDL_GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH
Definition: SDL_video.h:249
@ SDL_GL_CONTEXT_RESET_NO_NOTIFICATION
Definition: SDL_video.h:254
void(* GL_DefaultProfileConfig)(_THIS, int *mask, int *major, int *minor)
Definition: SDL_sysvideo.h:266

References _this, SDL_VideoDevice::accelerated, SDL_VideoDevice::accum_alpha_size, SDL_VideoDevice::accum_blue_size, SDL_VideoDevice::accum_green_size, SDL_VideoDevice::accum_red_size, SDL_VideoDevice::alpha_size, SDL_VideoDevice::blue_size, SDL_VideoDevice::buffer_size, SDL_VideoDevice::depth_size, SDL_VideoDevice::double_buffer, SDL_VideoDevice::flags, SDL_VideoDevice::framebuffer_srgb_capable, SDL_VideoDevice::gl_config, SDL_VideoDevice::GL_DefaultProfileConfig, SDL_VideoDevice::green_size, SDL_VideoDevice::major_version, SDL_VideoDevice::minor_version, SDL_VideoDevice::multisamplebuffers, SDL_VideoDevice::multisamplesamples, SDL_VideoDevice::no_error, SDL_VideoDevice::profile_mask, SDL_VideoDevice::red_size, SDL_VideoDevice::release_behavior, SDL_VideoDevice::reset_notification, SDL_VideoDevice::retained_backing, SDL_GL_CONTEXT_PROFILE_ES, SDL_GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH, SDL_GL_CONTEXT_RESET_NO_NOTIFICATION, SDL_VideoDevice::share_with_current_context, SDL_VideoDevice::stencil_size, and SDL_VideoDevice::stereo.

Referenced by SDL_VideoInit().

◆ SDL_GL_SetAttribute()

int SDL_GL_SetAttribute ( SDL_GLattr  attr,
int  value 
)

Set an OpenGL window attribute before window creation.

Returns
0 on success, or -1 if the attribute could not be set.

Definition at line 3241 of file SDL_video.c.

3242 {
3243 #if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
3244  int retval;
3245 
3246  if (!_this) {
3247  return SDL_UninitializedVideo();
3248  }
3249  retval = 0;
3250  switch (attr) {
3251  case SDL_GL_RED_SIZE:
3253  break;
3254  case SDL_GL_GREEN_SIZE:
3256  break;
3257  case SDL_GL_BLUE_SIZE:
3259  break;
3260  case SDL_GL_ALPHA_SIZE:
3262  break;
3263  case SDL_GL_DOUBLEBUFFER:
3265  break;
3266  case SDL_GL_BUFFER_SIZE:
3268  break;
3269  case SDL_GL_DEPTH_SIZE:
3271  break;
3272  case SDL_GL_STENCIL_SIZE:
3274  break;
3275  case SDL_GL_ACCUM_RED_SIZE:
3277  break;
3280  break;
3283  break;
3286  break;
3287  case SDL_GL_STEREO:
3289  break;
3292  break;
3295  break;
3298  break;
3301  break;
3304  break;
3307  break;
3308  case SDL_GL_CONTEXT_EGL:
3309  /* FIXME: SDL_GL_CONTEXT_EGL to be deprecated in SDL 2.1 */
3310  if (value != 0) {
3312  } else {
3314  };
3315  break;
3316  case SDL_GL_CONTEXT_FLAGS:
3321  retval = SDL_SetError("Unknown OpenGL context flag %d", value);
3322  break;
3323  }
3325  break;
3327  if (value != 0 &&
3331  retval = SDL_SetError("Unknown OpenGL context profile %d", value);
3332  break;
3333  }
3335  break;
3338  break;
3341  break;
3344  break;
3347  break;
3350  break;
3351  default:
3352  retval = SDL_SetError("Unknown OpenGL attribute");
3353  break;
3354  }
3355  return retval;
3356 #else
3357  return SDL_Unsupported();
3358 #endif /* SDL_VIDEO_OPENGL */
3359 }
int SDL_GL_SetAttribute(SDL_GLattr attr, int value)
Set an OpenGL window attribute before window creation.
Definition: SDL_video.c:3241
@ SDL_GL_CONTEXT_RESET_NOTIFICATION
Definition: SDL_video.h:227
@ SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG
Definition: SDL_video.h:241
@ SDL_GL_CONTEXT_RESET_ISOLATION_FLAG
Definition: SDL_video.h:243
@ SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG
Definition: SDL_video.h:242
@ SDL_GL_CONTEXT_DEBUG_FLAG
Definition: SDL_video.h:240
@ SDL_GL_CONTEXT_PROFILE_COMPATIBILITY
Definition: SDL_video.h:234
@ SDL_GL_CONTEXT_PROFILE_CORE
Definition: SDL_video.h:233

References _this, SDL_VideoDevice::accelerated, SDL_VideoDevice::accum_alpha_size, SDL_VideoDevice::accum_blue_size, SDL_VideoDevice::accum_green_size, SDL_VideoDevice::accum_red_size, SDL_VideoDevice::alpha_size, SDL_VideoDevice::blue_size, SDL_VideoDevice::buffer_size, SDL_VideoDevice::depth_size, SDL_VideoDevice::double_buffer, SDL_VideoDevice::flags, SDL_VideoDevice::framebuffer_srgb_capable, SDL_VideoDevice::gl_config, SDL_VideoDevice::green_size, SDL_VideoDevice::major_version, SDL_VideoDevice::minor_version, SDL_VideoDevice::multisamplebuffers, SDL_VideoDevice::multisamplesamples, SDL_VideoDevice::no_error, SDL_VideoDevice::profile_mask, SDL_VideoDevice::red_size, SDL_VideoDevice::release_behavior, SDL_VideoDevice::reset_notification, SDL_VideoDevice::retained_backing, retval, SDL_GL_ACCELERATED_VISUAL, SDL_GL_ACCUM_ALPHA_SIZE, SDL_GL_ACCUM_BLUE_SIZE, SDL_GL_ACCUM_GREEN_SIZE, SDL_GL_ACCUM_RED_SIZE, SDL_GL_ALPHA_SIZE, SDL_GL_BLUE_SIZE, SDL_GL_BUFFER_SIZE, SDL_GL_CONTEXT_DEBUG_FLAG, SDL_GL_CONTEXT_EGL, SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG, SDL_GL_CONTEXT_MAJOR_VERSION, SDL_GL_CONTEXT_MINOR_VERSION, SDL_GL_CONTEXT_NO_ERROR, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY, SDL_GL_CONTEXT_PROFILE_CORE, SDL_GL_CONTEXT_PROFILE_ES, SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_RELEASE_BEHAVIOR, SDL_GL_CONTEXT_RESET_ISOLATION_FLAG, SDL_GL_CONTEXT_RESET_NOTIFICATION, SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG, SDL_GL_DEPTH_SIZE, SDL_GL_DOUBLEBUFFER, SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, SDL_GL_GREEN_SIZE, SDL_GL_MULTISAMPLEBUFFERS, SDL_GL_MULTISAMPLESAMPLES, SDL_GL_RED_SIZE, SDL_GL_RETAINED_BACKING, SDL_GL_SetAttribute(), SDL_GL_SHARE_WITH_CURRENT_CONTEXT, SDL_GL_STENCIL_SIZE, SDL_GL_STEREO, SDL_SetError, SDL_UninitializedVideo(), SDL_Unsupported, SDL_VideoDevice::share_with_current_context, SDL_VideoDevice::stencil_size, and SDL_VideoDevice::stereo.

Referenced by SDL_GL_SetAttribute().

◆ SDL_GL_SetSwapInterval()

int SDL_GL_SetSwapInterval ( int  interval)

Set the swap interval for the current OpenGL context.

Parameters
interval0 for immediate updates, 1 for updates synchronized with the vertical retrace. If the system supports it, you may specify -1 to allow late swaps to happen immediately instead of waiting for the next retrace.
Returns
0 on success, or -1 if setting the swap interval is not supported.
See also
SDL_GL_GetSwapInterval()

Definition at line 3698 of file SDL_video.c.

3699 {
3700  if (!_this) {
3701  return SDL_UninitializedVideo();
3702  } else if (SDL_GL_GetCurrentContext() == NULL) {
3703  return SDL_SetError("No OpenGL context has been made current");
3704  } else if (_this->GL_SetSwapInterval) {
3705  return _this->GL_SetSwapInterval(_this, interval);
3706  } else {
3707  return SDL_SetError("Setting the swap interval is not supported");
3708  }
3709 }
int(* GL_SetSwapInterval)(_THIS, int interval)
Definition: SDL_sysvideo.h:262

References _this, SDL_VideoDevice::GL_SetSwapInterval, NULL, SDL_GL_GetCurrentContext(), SDL_SetError, and SDL_UninitializedVideo().

◆ SDL_GL_SwapWindow()

void SDL_GL_SwapWindow ( SDL_Window window)

Swap the OpenGL buffers for a window, if double-buffering is supported.

Definition at line 3726 of file SDL_video.c.

3727 {
3729 
3730  if (!(window->flags & SDL_WINDOW_OPENGL)) {
3731  SDL_SetError("The specified window isn't an OpenGL window");
3732  return;
3733  }
3734 
3735  if (SDL_GL_GetCurrentWindow() != window) {
3736  SDL_SetError("The specified window has not been made current");
3737  return;
3738  }
3739 
3741 }
int(* GL_SwapWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:264

References _this, CHECK_WINDOW_MAGIC, SDL_VideoDevice::GL_SwapWindow, SDL_GL_GetCurrentWindow(), SDL_SetError, and SDL_WINDOW_OPENGL.

◆ SDL_GL_UnloadLibrary()

void SDL_GL_UnloadLibrary ( void  )

Unload the OpenGL library previously loaded by SDL_GL_LoadLibrary().

See also
SDL_GL_LoadLibrary()

Definition at line 3047 of file SDL_video.c.

3048 {
3049  if (!_this) {
3051  return;
3052  }
3053  if (_this->gl_config.driver_loaded > 0) {
3054  if (--_this->gl_config.driver_loaded > 0) {
3055  return;
3056  }
3057  if (_this->GL_UnloadLibrary) {
3059  }
3060  }
3061 }

References _this, SDL_VideoDevice::driver_loaded, SDL_VideoDevice::gl_config, SDL_VideoDevice::GL_UnloadLibrary, and SDL_UninitializedVideo().

Referenced by SDL_DestroyWindow(), and SDL_RecreateWindow().

◆ SDL_HasScreenKeyboardSupport()

SDL_bool SDL_HasScreenKeyboardSupport ( void  )

Returns whether the platform has some screen keyboard support.

Returns
SDL_TRUE if some keyboard support is available else SDL_FALSE.
Note
Not all screen keyboard functions are supported on all platforms.
See also
SDL_IsScreenKeyboardShown()

Definition at line 3931 of file SDL_video.c.

3932 {
3935  }
3936  return SDL_FALSE;
3937 }
SDL_bool(* HasScreenKeyboardSupport)(_THIS)
Definition: SDL_sysvideo.h:302

References _this, SDL_VideoDevice::HasScreenKeyboardSupport, and SDL_FALSE.

Referenced by SDL_VideoInit().

◆ SDL_HasWindows()

SDL_bool SDL_HasWindows ( void  )

Definition at line 1822 of file SDL_video.c.

1823 {
1824  return (_this && _this->windows != NULL);
1825 }

References _this, NULL, and SDL_VideoDevice::windows.

Referenced by SDL_PrivateJoystickShouldIgnoreEvent().

◆ SDL_HideWindow()

void SDL_HideWindow ( SDL_Window window)

Hide a window.

See also
SDL_ShowWindow()

Definition at line 2279 of file SDL_video.c.

2280 {
2282 
2283  if (!(window->flags & SDL_WINDOW_SHOWN)) {
2284  return;
2285  }
2286 
2287  window->is_hiding = SDL_TRUE;
2289 
2290  if (_this->HideWindow) {
2292  }
2293  window->is_hiding = SDL_FALSE;
2295 }
@ SDL_WINDOW_SHOWN
Definition: SDL_video.h:101
@ SDL_WINDOWEVENT_HIDDEN
Definition: SDL_video.h:150
int SDL_SendWindowEvent(SDL_Window *window, Uint8 windowevent, int data1, int data2)
void(* HideWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:225

References _this, CHECK_WINDOW_MAGIC, SDL_VideoDevice::HideWindow, SDL_FALSE, SDL_SendWindowEvent(), SDL_TRUE, SDL_UpdateFullscreenMode(), SDL_WINDOW_SHOWN, and SDL_WINDOWEVENT_HIDDEN.

Referenced by SDL_DestroyWindow(), and SDL_RecreateWindow().

◆ SDL_IsScreenKeyboardShown()

SDL_bool SDL_IsScreenKeyboardShown ( SDL_Window window)

Returns whether the screen keyboard is shown for given window.

Parameters
windowThe window for which screen keyboard should be queried.
Returns
SDL_TRUE if screen keyboard is shown else SDL_FALSE.
See also
SDL_HasScreenKeyboardSupport()

Definition at line 3940 of file SDL_video.c.

3941 {
3942  if (window && _this && _this->IsScreenKeyboardShown) {
3944  }
3945  return SDL_FALSE;
3946 }
SDL_bool(* IsScreenKeyboardShown)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:305

References _this, SDL_VideoDevice::IsScreenKeyboardShown, and SDL_FALSE.

◆ SDL_IsScreenSaverEnabled()

SDL_bool SDL_IsScreenSaverEnabled ( void  )

Returns whether the screensaver is currently enabled (default off).

See also
SDL_EnableScreenSaver()
SDL_DisableScreenSaver()

Definition at line 2907 of file SDL_video.c.

2908 {
2909  if (!_this) {
2910  return SDL_TRUE;
2911  }
2913 }

References _this, SDL_FALSE, SDL_TRUE, and SDL_VideoDevice::suspend_screensaver.

◆ SDL_IsTextInputActive()

SDL_bool SDL_IsTextInputActive ( void  )

Return whether or not Unicode text input events are enabled.

See also
SDL_StartTextInput()
SDL_StopTextInput()

Definition at line 3896 of file SDL_video.c.

3897 {
3899 }
@ SDL_TEXTINPUT
Definition: SDL_events.h:101

References SDL_ENABLE, SDL_GetEventState, and SDL_TEXTINPUT.

◆ SDL_IsVideoContextExternal()

SDL_bool SDL_IsVideoContextExternal ( void  )

Definition at line 688 of file SDL_video.c.

689 {
691 }
#define SDL_HINT_VIDEO_EXTERNAL_CONTEXT
A variable controlling whether the graphics context is externally managed.
Definition: SDL_hints.h:180

References SDL_FALSE, SDL_GetHintBoolean, and SDL_HINT_VIDEO_EXTERNAL_CONTEXT.

Referenced by SDL_CreateWindow().

◆ SDL_MaximizeWindow()

void SDL_MaximizeWindow ( SDL_Window window)

Make a window as large as possible.

See also
SDL_RestoreWindow()

Definition at line 2311 of file SDL_video.c.

2312 {
2314 
2315  if (window->flags & SDL_WINDOW_MAXIMIZED) {
2316  return;
2317  }
2318 
2319  /* !!! FIXME: should this check if the window is resizable? */
2320 
2321  if (_this->MaximizeWindow) {
2323  }
2324 }
void(* MaximizeWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:227

References _this, CHECK_WINDOW_MAGIC, SDL_VideoDevice::MaximizeWindow, and SDL_WINDOW_MAXIMIZED.

Referenced by SDL_FinishWindowCreation().

◆ SDL_MessageboxValidForDriver()

static SDL_bool SDL_MessageboxValidForDriver ( const SDL_MessageBoxData messageboxdata,
SDL_SYSWM_TYPE  drivertype 
)
static

Definition at line 3974 of file SDL_video.c.

3975 {
3976  SDL_SysWMinfo info;
3977  SDL_Window *window = messageboxdata->window;
3978 
3979  if (!window) {
3980  return SDL_TRUE;
3981  }
3982 
3983  SDL_VERSION(&info.version);
3984  if (!SDL_GetWindowWMInfo(window, &info)) {
3985  return SDL_TRUE;
3986  } else {
3987  return (info.subsystem == drivertype);
3988  }
3989 }
SDL_bool SDL_GetWindowWMInfo(SDL_Window *window, struct SDL_SysWMinfo *info)
This function allows access to driver-dependent window information.
Definition: SDL_video.c:3857
SDL_Window * window

References SDL_GetWindowWMInfo(), SDL_TRUE, SDL_VERSION, SDL_SysWMinfo::subsystem, SDL_SysWMinfo::version, and SDL_MessageBoxData::window.

Referenced by SDL_ShowMessageBox().

◆ SDL_Metal_CreateView()

SDL_MetalView SDL_Metal_CreateView ( SDL_Window window)

Create a CAMetalLayer-backed NSView/UIView and attach it to the specified window.

On macOS, this does not associate a MTLDevice with the CAMetalLayer on its own. It is up to user code to do that.

The returned handle can be casted directly to a NSView or UIView. To access the backing CAMetalLayer, call SDL_Metal_GetLayer().

Note
window must be created with the SDL_WINDOW_METAL flag.
See also
SDL_Metal_DestroyView
SDL_Metal_GetLayer

Definition at line 4334 of file SDL_video.c.

4335 {
4337 
4338  if (!(window->flags & SDL_WINDOW_METAL)) {
4339  SDL_SetError("The specified window isn't a Metal window");
4340  return NULL;
4341  }
4342 
4343  if (_this->Metal_CreateView) {
4344  return _this->Metal_CreateView(_this, window);
4345  } else {
4346  SDL_SetError("Metal is not supported.");
4347  return NULL;
4348  }
4349 }

References _this, CHECK_WINDOW_MAGIC, SDL_VideoDevice::Metal_CreateView, NULL, SDL_SetError, and SDL_WINDOW_METAL.

◆ SDL_Metal_DestroyView()

void SDL_Metal_DestroyView ( SDL_MetalView  view)

Destroy an existing SDL_MetalView object.

This should be called before SDL_DestroyWindow, if SDL_Metal_CreateView was called after SDL_CreateWindow.

See also
SDL_Metal_CreateView

Definition at line 4352 of file SDL_video.c.

4353 {
4354  if (_this && view && _this->Metal_DestroyView) {
4355  _this->Metal_DestroyView(_this, view);
4356  }
4357 }
void(* Metal_DestroyView)(_THIS, SDL_MetalView view)
Definition: SDL_sysvideo.h:283

References _this, and SDL_VideoDevice::Metal_DestroyView.

◆ SDL_Metal_GetDrawableSize()

void SDL_Metal_GetDrawableSize ( SDL_Window window,
int w,
int h 
)

Get the size of a window's underlying drawable in pixels (for use with setting viewport, scissor & etc).

Parameters
windowSDL_Window from which the drawable size should be queried
wPointer to variable for storing the width in pixels, may be NULL
hPointer to variable for storing the height in pixels, may be NULL

This may differ from SDL_GetWindowSize() if we're rendering to a high-DPI drawable, i.e. the window was created with SDL_WINDOW_ALLOW_HIGHDPI on a platform with high-DPI support (Apple calls this "Retina"), and not disabled by the SDL_HINT_VIDEO_HIGHDPI_DISABLED hint.

Note
On macOS high-DPI support must be enabled for an application by setting NSHighResolutionCapable to true in its Info.plist.
See also
SDL_GetWindowSize()
SDL_CreateWindow()

Definition at line 4375 of file SDL_video.c.

4376 {
4378 
4381  } else {
4383  }
4384 }
void(* Metal_GetDrawableSize)(_THIS, SDL_Window *window, int *w, int *h)
Definition: SDL_sysvideo.h:285

References _this, CHECK_WINDOW_MAGIC, SDL_VideoDevice::Metal_GetDrawableSize, and SDL_GetWindowSize().

◆ SDL_Metal_GetLayer()

void* SDL_Metal_GetLayer ( SDL_MetalView  view)

Get a pointer to the backing CAMetalLayer for the given view.

See also
SDL_MetalCreateView

Definition at line 4360 of file SDL_video.c.

4361 {
4362  if (_this && _this->Metal_GetLayer) {
4363  if (view) {
4364  return _this->Metal_GetLayer(_this, view);
4365  } else {
4366  SDL_InvalidParamError("view");
4367  return NULL;
4368  }
4369  } else {
4370  SDL_SetError("Metal is not supported.");
4371  return NULL;
4372  }
4373 }
void *(* Metal_GetLayer)(_THIS, SDL_MetalView view)
Definition: SDL_sysvideo.h:284

References _this, SDL_VideoDevice::Metal_GetLayer, NULL, SDL_InvalidParamError, and SDL_SetError.

◆ SDL_MinimizeWindow()

void SDL_MinimizeWindow ( SDL_Window window)

Minimize a window to an iconic representation.

See also
SDL_RestoreWindow()

Definition at line 2336 of file SDL_video.c.

2337 {
2339 
2340  if (window->flags & SDL_WINDOW_MINIMIZED) {
2341  return;
2342  }
2343 
2344  if (!CanMinimizeWindow(window)) {
2345  return;
2346  }
2347 
2349 
2350  if (_this->MinimizeWindow) {
2352  }
2353 }
static SDL_bool CanMinimizeWindow(SDL_Window *window)
Definition: SDL_video.c:2327

References _this, CanMinimizeWindow(), CHECK_WINDOW_MAGIC, SDL_VideoDevice::MinimizeWindow, SDL_FALSE, SDL_UpdateFullscreenMode(), and SDL_WINDOW_MINIMIZED.

Referenced by SDL_FinishWindowCreation(), SDL_OnWindowFocusLost(), and SDL_UpdateFullscreenMode().

◆ SDL_OnApplicationDidBecomeActive()

void SDL_OnApplicationDidBecomeActive ( void  )

Definition at line 4208 of file SDL_video.c.

4209 {
4211 
4212  if (_this) {
4213  SDL_Window *window;
4214  for (window = _this->windows; window != NULL; window = window->next) {
4217  }
4218  }
4219 }
int SDL_SendAppEvent(SDL_EventType eventType)
Definition: SDL_events.c:1035
@ SDL_APP_DIDENTERFOREGROUND
Definition: SDL_events.h:83
@ SDL_WINDOWEVENT_FOCUS_GAINED
Definition: SDL_video.h:165
@ SDL_WINDOWEVENT_RESTORED
Definition: SDL_video.h:161

References _this, NULL, SDL_APP_DIDENTERFOREGROUND, SDL_SendAppEvent(), SDL_SendWindowEvent(), SDL_WINDOWEVENT_FOCUS_GAINED, SDL_WINDOWEVENT_RESTORED, and SDL_VideoDevice::windows.

◆ SDL_OnApplicationDidEnterBackground()

void SDL_OnApplicationDidEnterBackground ( void  )

Definition at line 4198 of file SDL_video.c.

4199 {
4201 }
@ SDL_APP_DIDENTERBACKGROUND
Definition: SDL_events.h:75

References SDL_APP_DIDENTERBACKGROUND, and SDL_SendAppEvent().

◆ SDL_OnApplicationDidReceiveMemoryWarning()

void SDL_OnApplicationDidReceiveMemoryWarning ( void  )

Definition at line 4181 of file SDL_video.c.

4182 {
4184 }
@ SDL_APP_LOWMEMORY
Definition: SDL_events.h:67

References SDL_APP_LOWMEMORY, and SDL_SendAppEvent().

◆ SDL_OnApplicationWillEnterForeground()

void SDL_OnApplicationWillEnterForeground ( void  )

Definition at line 4203 of file SDL_video.c.

4204 {
4206 }
@ SDL_APP_WILLENTERFOREGROUND
Definition: SDL_events.h:79

References SDL_APP_WILLENTERFOREGROUND, and SDL_SendAppEvent().

◆ SDL_OnApplicationWillResignActive()

void SDL_OnApplicationWillResignActive ( void  )

Definition at line 4186 of file SDL_video.c.

4187 {
4188  if (_this) {
4189  SDL_Window *window;
4190  for (window = _this->windows; window != NULL; window = window->next) {
4193  }
4194  }
4196 }
@ SDL_APP_WILLENTERBACKGROUND
Definition: SDL_events.h:71
@ SDL_WINDOWEVENT_FOCUS_LOST
Definition: SDL_video.h:166
@ SDL_WINDOWEVENT_MINIMIZED
Definition: SDL_video.h:159

References _this, NULL, SDL_APP_WILLENTERBACKGROUND, SDL_SendAppEvent(), SDL_SendWindowEvent(), SDL_WINDOWEVENT_FOCUS_LOST, SDL_WINDOWEVENT_MINIMIZED, and SDL_VideoDevice::windows.

◆ SDL_OnApplicationWillTerminate()

void SDL_OnApplicationWillTerminate ( void  )

Definition at line 4176 of file SDL_video.c.

4177 {
4179 }
@ SDL_APP_TERMINATING
Definition: SDL_events.h:63

References SDL_APP_TERMINATING, and SDL_SendAppEvent().

◆ SDL_OnWindowEnter()

void SDL_OnWindowEnter ( SDL_Window window)

Definition at line 2739 of file SDL_video.c.

2740 {
2741  if (_this->OnWindowEnter) {
2743  }
2744 }
void(* OnWindowEnter)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:240

References _this, and SDL_VideoDevice::OnWindowEnter.

Referenced by SDL_SendWindowEvent().

◆ SDL_OnWindowFocusGained()

void SDL_OnWindowFocusGained ( SDL_Window window)

Definition at line 2752 of file SDL_video.c.

2753 {
2754  SDL_Mouse *mouse = SDL_GetMouse();
2755 
2756  if (window->gamma && _this->SetWindowGammaRamp) {
2758  }
2759 
2760  if (mouse && mouse->relative_mode) {
2763  }
2764 
2766 }
#define SDL_WarpMouseInWindow
SDL_Mouse * SDL_GetMouse(void)
Definition: SDL_mouse.c:175
void SDL_UpdateWindowGrab(SDL_Window *window)
Definition: SDL_video.c:2636
SDL_bool relative_mode
Definition: SDL_mouse_c.h:87
int(* SetWindowGammaRamp)(_THIS, SDL_Window *window, const Uint16 *ramp)
Definition: SDL_sysvideo.h:233

References _this, SDL_Mouse::relative_mode, SDL_GetMouse(), SDL_SetMouseFocus(), SDL_UpdateWindowGrab(), SDL_WarpMouseInWindow, and SDL_VideoDevice::SetWindowGammaRamp.

Referenced by SDL_SendWindowEvent().

◆ SDL_OnWindowFocusLost()

void SDL_OnWindowFocusLost ( SDL_Window window)

Definition at line 2796 of file SDL_video.c.

2797 {
2798  if (window->gamma && _this->SetWindowGammaRamp) {
2799  _this->SetWindowGammaRamp(_this, window, window->saved_gamma);
2800  }
2801 
2803 
2806  }
2807 }
static SDL_bool ShouldMinimizeOnFocusLoss(SDL_Window *window)
Definition: SDL_video.c:2769

References _this, SDL_MinimizeWindow(), SDL_UpdateWindowGrab(), SDL_VideoDevice::SetWindowGammaRamp, and ShouldMinimizeOnFocusLoss().

Referenced by SDL_SendWindowEvent().

◆ SDL_OnWindowHidden()

void SDL_OnWindowHidden ( SDL_Window window)

Definition at line 2704 of file SDL_video.c.

2705 {
2707 }

References SDL_FALSE, and SDL_UpdateFullscreenMode().

Referenced by SDL_SendWindowEvent().

◆ SDL_OnWindowLeave()

void SDL_OnWindowLeave ( SDL_Window window)

Definition at line 2747 of file SDL_video.c.

2748 {
2749 }

Referenced by SDL_SendWindowEvent().

◆ SDL_OnWindowMinimized()

void SDL_OnWindowMinimized ( SDL_Window window)

Definition at line 2717 of file SDL_video.c.

2718 {
2720 }

References SDL_FALSE, and SDL_UpdateFullscreenMode().

Referenced by SDL_SendWindowEvent().

◆ SDL_OnWindowResized()

void SDL_OnWindowResized ( SDL_Window window)

Definition at line 2710 of file SDL_video.c.

2711 {
2712  window->surface_valid = SDL_FALSE;
2714 }
@ SDL_WINDOWEVENT_SIZE_CHANGED
Definition: SDL_video.h:156

References SDL_FALSE, SDL_SendWindowEvent(), and SDL_WINDOWEVENT_SIZE_CHANGED.

Referenced by SDL_SendWindowEvent(), SDL_SetWindowSize(), and SDL_UpdateFullscreenMode().

◆ SDL_OnWindowRestored()

void SDL_OnWindowRestored ( SDL_Window window)

Definition at line 2723 of file SDL_video.c.

2724 {
2725  /*
2726  * FIXME: Is this fine to just remove this, or should it be preserved just
2727  * for the fullscreen case? In principle it seems like just hiding/showing
2728  * windows shouldn't affect the stacking order; maybe the right fix is to
2729  * re-decouple OnWindowShown and OnWindowRestored.
2730  */
2731  /*SDL_RaiseWindow(window);*/
2732 
2733  if (FULLSCREEN_VISIBLE(window)) {
2735  }
2736 }

References FULLSCREEN_VISIBLE, SDL_TRUE, and SDL_UpdateFullscreenMode().

Referenced by SDL_OnWindowShown(), and SDL_SendWindowEvent().

◆ SDL_OnWindowShown()

void SDL_OnWindowShown ( SDL_Window window)

Definition at line 2698 of file SDL_video.c.

2699 {
2701 }
void SDL_OnWindowRestored(SDL_Window *window)
Definition: SDL_video.c:2723

References SDL_OnWindowRestored().

Referenced by SDL_SendWindowEvent().

◆ SDL_RaiseWindow()

void SDL_RaiseWindow ( SDL_Window window)

Raise a window above other windows and set the input focus.

Definition at line 2298 of file SDL_video.c.

2299 {
2301 
2302  if (!(window->flags & SDL_WINDOW_SHOWN)) {
2303  return;
2304  }
2305  if (_this->RaiseWindow) {
2307  }
2308 }
void(* RaiseWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:226

References _this, CHECK_WINDOW_MAGIC, SDL_VideoDevice::RaiseWindow, and SDL_WINDOW_SHOWN.

Referenced by SDL_ShowMessageBox().

◆ SDL_RecreateWindow()

int SDL_RecreateWindow ( SDL_Window window,
Uint32  flags 
)

Definition at line 1673 of file SDL_video.c.

1674 {
1675  SDL_bool loaded_opengl = SDL_FALSE;
1676  SDL_bool need_gl_unload = SDL_FALSE;
1677  SDL_bool need_gl_load = SDL_FALSE;
1678  SDL_bool loaded_vulkan = SDL_FALSE;
1679  SDL_bool need_vulkan_unload = SDL_FALSE;
1680  SDL_bool need_vulkan_load = SDL_FALSE;
1681 
1683  return SDL_SetError("OpenGL support is either not configured in SDL "
1684  "or not available in current SDL video driver "
1685  "(%s) or platform", _this->name);
1686  }
1687 
1688  if (window->flags & SDL_WINDOW_FOREIGN) {
1689  /* Can't destroy and re-create foreign windows, hrm */
1691  } else {
1693  }
1694 
1695  /* Restore video mode, etc. */
1697 
1698  /* Tear down the old native window */
1699  if (window->surface) {
1700  window->surface->flags &= ~SDL_DONTFREE;
1701  SDL_FreeSurface(window->surface);
1702  window->surface = NULL;
1703  window->surface_valid = SDL_FALSE;
1704  }
1707  }
1710  }
1711 
1712  if ((window->flags & SDL_WINDOW_OPENGL) != (flags & SDL_WINDOW_OPENGL)) {
1713  if (flags & SDL_WINDOW_OPENGL) {
1714  need_gl_load = SDL_TRUE;
1715  } else {
1716  need_gl_unload = SDL_TRUE;
1717  }
1718  } else if (window->flags & SDL_WINDOW_OPENGL) {
1719  need_gl_unload = SDL_TRUE;
1720  need_gl_load = SDL_TRUE;
1721  }
1722 
1723  if ((window->flags & SDL_WINDOW_METAL) != (flags & SDL_WINDOW_METAL)) {
1724  if (flags & SDL_WINDOW_METAL) {
1725  need_gl_load = SDL_TRUE;
1726  } else {
1727  need_gl_unload = SDL_TRUE;
1728  }
1729  } else if (window->flags & SDL_WINDOW_METAL) {
1730  need_gl_unload = SDL_TRUE;
1731  need_gl_load = SDL_TRUE;
1732  }
1733 
1734  if ((window->flags & SDL_WINDOW_VULKAN) != (flags & SDL_WINDOW_VULKAN)) {
1735  if (flags & SDL_WINDOW_VULKAN) {
1736  need_vulkan_load = SDL_TRUE;
1737  } else {
1738  need_vulkan_unload = SDL_TRUE;
1739  }
1740  } else if (window->flags & SDL_WINDOW_VULKAN) {
1741  need_vulkan_unload = SDL_TRUE;
1742  need_vulkan_load = SDL_TRUE;
1743  }
1744 
1746  SDL_SetError("Vulkan and OpenGL not supported on same window");
1747  return -1;
1748  }
1749 
1750  if ((flags & SDL_WINDOW_METAL) && (flags & SDL_WINDOW_OPENGL)) {
1751  SDL_SetError("Metal and OpenGL not supported on same window");
1752  return -1;
1753  }
1754 
1755  if ((flags & SDL_WINDOW_METAL) && (flags & SDL_WINDOW_VULKAN)) {
1756  SDL_SetError("Metal and Vulkan not supported on same window");
1757  return -1;
1758  }
1759 
1760  if (need_gl_unload) {
1762  }
1763 
1764  if (need_vulkan_unload) {
1766  }
1767 
1768  if (need_gl_load) {
1769  if (SDL_GL_LoadLibrary(NULL) < 0) {
1770  return -1;
1771  }
1772  loaded_opengl = SDL_TRUE;
1773  }
1774 
1775  if (need_vulkan_load) {
1776  if (SDL_Vulkan_LoadLibrary(NULL) < 0) {
1777  return -1;
1778  }
1779  loaded_vulkan = SDL_TRUE;
1780  }
1781 
1782  window->flags = ((flags & CREATE_FLAGS) | SDL_WINDOW_HIDDEN);
1783  window->last_fullscreen_flags = window->flags;
1784  window->is_destroying = SDL_FALSE;
1785 
1787  if (_this->CreateSDLWindow(_this, window) < 0) {
1788  if (loaded_opengl) {
1790  window->flags &= ~SDL_WINDOW_OPENGL;
1791  }
1792  if (loaded_vulkan) {
1794  window->flags &= ~SDL_WINDOW_VULKAN;
1795  }
1796  return -1;
1797  }
1798  }
1799 
1800  if (flags & SDL_WINDOW_FOREIGN) {
1801  window->flags |= SDL_WINDOW_FOREIGN;
1802  }
1803 
1804  if (_this->SetWindowTitle && window->title) {
1806  }
1807 
1808  if (_this->SetWindowIcon && window->icon) {
1810  }
1811 
1812  if (window->hit_test) {
1814  }
1815 
1817 
1818  return 0;
1819 }
SDL_bool
Definition: SDL_stdinc.h:168
void(* SetWindowIcon)(_THIS, SDL_Window *window, SDL_Surface *icon)
Definition: SDL_sysvideo.h:215
int(* SetWindowHitTest)(SDL_Window *window, SDL_bool enabled)
Definition: SDL_sysvideo.h:316
void(* SetWindowTitle)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:214

References _this, CREATE_FLAGS, SDL_VideoDevice::CreateSDLWindow, SDL_VideoDevice::DestroyWindow, SDL_VideoDevice::DestroyWindowFramebuffer, SDL_VideoDevice::GL_CreateContext, SDL_VideoDevice::name, NULL, SDL_DONTFREE, SDL_FALSE, SDL_FinishWindowCreation(), SDL_FreeSurface, SDL_GL_LoadLibrary(), SDL_GL_UnloadLibrary(), SDL_HideWindow(), SDL_SetError, SDL_TRUE, SDL_Vulkan_LoadLibrary(), SDL_Vulkan_UnloadLibrary(), SDL_WINDOW_FOREIGN, SDL_WINDOW_HIDDEN, SDL_WINDOW_METAL, SDL_WINDOW_OPENGL, SDL_WINDOW_VULKAN, SDL_VideoDevice::SetWindowHitTest, SDL_VideoDevice::SetWindowIcon, and SDL_VideoDevice::SetWindowTitle.

◆ SDL_RestoreMousePosition()

static void SDL_RestoreMousePosition ( SDL_Window window)
static

Definition at line 1209 of file SDL_video.c.

1210 {
1211  int x, y;
1212 
1213  if (window == SDL_GetMouseFocus()) {
1214  SDL_GetMouseState(&x, &y);
1216  }
1217 }
#define SDL_GetMouseState

References SDL_GetMouseFocus, SDL_GetMouseState, and SDL_WarpMouseInWindow.

Referenced by SDL_UpdateFullscreenMode().

◆ SDL_RestoreWindow()

void SDL_RestoreWindow ( SDL_Window window)

Restore the size and position of a minimized or maximized window.

See also
SDL_MaximizeWindow()
SDL_MinimizeWindow()

Definition at line 2356 of file SDL_video.c.

2357 {
2359 
2360  if (!(window->flags & (SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED))) {
2361  return;
2362  }
2363 
2364  if (_this->RestoreWindow) {
2366  }
2367 }
void(* RestoreWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:229

References _this, CHECK_WINDOW_MAGIC, SDL_VideoDevice::RestoreWindow, SDL_WINDOW_MAXIMIZED, and SDL_WINDOW_MINIMIZED.

◆ SDL_SetDisplayModeForDisplay()

static int SDL_SetDisplayModeForDisplay ( SDL_VideoDisplay display,
const SDL_DisplayMode mode 
)
static

Definition at line 1013 of file SDL_video.c.

1014 {
1015  SDL_DisplayMode display_mode;
1016  SDL_DisplayMode current_mode;
1017 
1018  if (mode) {
1019  display_mode = *mode;
1020 
1021  /* Default to the current mode */
1022  if (!display_mode.format) {
1023  display_mode.format = display->current_mode.format;
1024  }
1025  if (!display_mode.w) {
1026  display_mode.w = display->current_mode.w;
1027  }
1028  if (!display_mode.h) {
1029  display_mode.h = display->current_mode.h;
1030  }
1031  if (!display_mode.refresh_rate) {
1032  display_mode.refresh_rate = display->current_mode.refresh_rate;
1033  }
1034 
1035  /* Get a good video mode, the closest one possible */
1036  if (!SDL_GetClosestDisplayModeForDisplay(display, &display_mode, &display_mode)) {
1037  return SDL_SetError("No video mode large enough for %dx%d",
1038  display_mode.w, display_mode.h);
1039  }
1040  } else {
1041  display_mode = display->desktop_mode;
1042  }
1043 
1044  /* See if there's anything left to do */
1045  current_mode = display->current_mode;
1046  if (SDL_memcmp(&display_mode, &current_mode, sizeof(display_mode)) == 0) {
1047  return 0;
1048  }
1049 
1050  /* Actually change the display mode */
1051  if (!_this->SetDisplayMode) {
1052  return SDL_SetError("SDL video driver doesn't support changing display mode");
1053  }
1054  if (_this->SetDisplayMode(_this, display, &display_mode) < 0) {
1055  return -1;
1056  }
1057  display->current_mode = display_mode;
1058  return 0;
1059 }
#define SDL_memcmp
int(* SetDisplayMode)(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
Definition: SDL_sysvideo.h:206

References _this, SDL_VideoDisplay::current_mode, SDL_VideoDisplay::desktop_mode, SDL_DisplayMode::format, SDL_DisplayMode::h, SDL_DisplayMode::refresh_rate, SDL_GetClosestDisplayModeForDisplay(), SDL_memcmp, SDL_SetError, SDL_VideoDevice::SetDisplayMode, and SDL_DisplayMode::w.

Referenced by SDL_SetWindowDisplayMode(), and SDL_UpdateFullscreenMode().

◆ SDL_SetTextInputRect()

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 keyboard placement.

See also
SDL_StartTextInput()

Definition at line 3923 of file SDL_video.c.

3924 {
3925  if (_this && _this->SetTextInputRect) {
3927  }
3928 }
void(* SetTextInputRect)(_THIS, SDL_Rect *rect)
Definition: SDL_sysvideo.h:299

References _this, rect, and SDL_VideoDevice::SetTextInputRect.

◆ SDL_SetWindowBordered()

void SDL_SetWindowBordered ( SDL_Window window,
SDL_bool  bordered 
)

Set the border state of a window.

This will add or remove the window's SDL_WINDOW_BORDERLESS flag and add or remove the border from the actual window. This is a no-op if the window's border already matches the requested state.

Parameters
windowThe window of which to change the border state.
borderedSDL_FALSE to remove border, SDL_TRUE to add border.
Note
You can't change the border state of a fullscreen window.
See also
SDL_GetWindowFlags()

Definition at line 2061 of file SDL_video.c.

2062 {
2064  if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
2065  const int want = (bordered != SDL_FALSE); /* normalize the flag. */
2066  const int have = ((window->flags & SDL_WINDOW_BORDERLESS) == 0);
2067  if ((want != have) && (_this->SetWindowBordered)) {
2068  if (want) {
2069  window->flags &= ~SDL_WINDOW_BORDERLESS;
2070  } else {
2071  window->flags |= SDL_WINDOW_BORDERLESS;
2072  }
2074  }
2075  }
2076 }
@ SDL_WINDOW_BORDERLESS
Definition: SDL_video.h:103
void(* SetWindowBordered)(_THIS, SDL_Window *window, SDL_bool bordered)
Definition: SDL_sysvideo.h:230

References _this, CHECK_WINDOW_MAGIC, SDL_FALSE, SDL_WINDOW_BORDERLESS, SDL_WINDOW_FULLSCREEN, and SDL_VideoDevice::SetWindowBordered.

◆ SDL_SetWindowBrightness()

int SDL_SetWindowBrightness ( SDL_Window window,
float  brightness 
)

Set the brightness (gamma correction) for a window.

Returns
0 on success, or -1 if setting the brightness isn't supported.
See also
SDL_GetWindowBrightness()
SDL_SetWindowGammaRamp()

Definition at line 2471 of file SDL_video.c.

2472 {
2473  Uint16 ramp[256];
2474  int status;
2475 
2477 
2478  SDL_CalculateGammaRamp(brightness, ramp);
2479  status = SDL_SetWindowGammaRamp(window, ramp, ramp, ramp);
2480  if (status == 0) {
2481  window->brightness = brightness;
2482  }
2483  return status;
2484 }
#define SDL_CalculateGammaRamp
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:2557

References CHECK_WINDOW_MAGIC, SDL_CalculateGammaRamp, and SDL_SetWindowGammaRamp().

◆ SDL_SetWindowData()

void* SDL_SetWindowData ( SDL_Window window,
const char *  name,
void userdata 
)

Associate an arbitrary named pointer with a window.

Parameters
windowThe window to associate with the pointer.
nameThe name of the pointer.
userdataThe associated pointer.
Returns
The previous value associated with 'name'
Note
The name is case-sensitive.
See also
SDL_GetWindowData()

Definition at line 1907 of file SDL_video.c.

1908 {
1909  SDL_WindowUserData *prev, *data;
1910 
1912 
1913  /* Input validation */
1914  if (name == NULL || name[0] == '\0') {
1915  SDL_InvalidParamError("name");
1916  return NULL;
1917  }
1918 
1919  /* See if the named data already exists */
1920  prev = NULL;
1921  for (data = window->data; data; prev = data, data = data->next) {
1922  if (data->name && SDL_strcmp(data->name, name) == 0) {
1923  void *last_value = data->data;
1924 
1925  if (userdata) {
1926  /* Set the new value */
1927  data->data = userdata;
1928  } else {
1929  /* Delete this value */
1930  if (prev) {
1931  prev->next = data->next;
1932  } else {
1933  window->data = data->next;
1934  }
1935  SDL_free(data->name);
1936  SDL_free(data);
1937  }
1938  return last_value;
1939  }
1940  }
1941 
1942  /* Add new data to the window */
1943  if (userdata) {
1944  data = (SDL_WindowUserData *)SDL_malloc(sizeof(*data));
1945  data->name = SDL_strdup(name);
1946  data->data = userdata;
1947  data->next = window->data;
1948  window->data = data;
1949  }
1950  return NULL;
1951 }
struct SDL_WindowUserData * next
Definition: SDL_sysvideo.h:70

References CHECK_WINDOW_MAGIC, SDL_WindowUserData::data, SDL_WindowUserData::next, NULL, SDL_free, SDL_InvalidParamError, SDL_malloc, SDL_strcmp, and SDL_strdup.

Referenced by SDL_CreateWindowTexture(), and SDL_DestroyWindowTexture().

◆ SDL_SetWindowDisplayMode()

int SDL_SetWindowDisplayMode ( SDL_Window window,
const SDL_DisplayMode mode 
)

Set the display mode used when a fullscreen window is visible.

By default the window's dimensions and the desktop format and refresh rate are used.

Parameters
windowThe window for which the display mode should be set.
modeThe mode to use, or NULL for the default mode.
Returns
0 on success, or -1 if setting the display mode failed.
See also
SDL_GetWindowDisplayMode()
SDL_SetWindowFullscreen()

Definition at line 1141 of file SDL_video.c.

1142 {
1144 
1145  if (mode) {
1146  window->fullscreen_mode = *mode;
1147  } else {
1148  SDL_zero(window->fullscreen_mode);
1149  }
1150 
1152  SDL_DisplayMode fullscreen_mode;
1153  if (SDL_GetWindowDisplayMode(window, &fullscreen_mode) == 0) {
1155  }
1156  }
1157  return 0;
1158 }
static int SDL_SetDisplayModeForDisplay(SDL_VideoDisplay *display, const SDL_DisplayMode *mode)
Definition: SDL_video.c:1013
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:1161

References CHECK_WINDOW_MAGIC, FULLSCREEN_VISIBLE, SDL_GetDisplayForWindow(), SDL_GetWindowDisplayMode(), SDL_SetDisplayModeForDisplay(), SDL_WINDOW_FULLSCREEN_DESKTOP, and SDL_zero.

◆ SDL_SetWindowFullscreen()

int SDL_SetWindowFullscreen ( SDL_Window window,
Uint32  flags 
)

Set a window's fullscreen state.

Returns
0 on success, or -1 if setting the display mode failed.
See also
SDL_SetWindowDisplayMode()
SDL_GetWindowDisplayMode()

Definition at line 2370 of file SDL_video.c.

2371 {
2372  Uint32 oldflags;
2374 
2376 
2377  if (flags == (window->flags & FULLSCREEN_MASK)) {
2378  return 0;
2379  }
2380 
2381  /* clear the previous flags and OR in the new ones */
2382  oldflags = window->flags & FULLSCREEN_MASK;
2383  window->flags &= ~FULLSCREEN_MASK;
2384  window->flags |= flags;
2385 
2387  return 0;
2388  }
2389 
2390  window->flags &= ~FULLSCREEN_MASK;
2391  window->flags |= oldflags;
2392  return -1;
2393 }
#define FULLSCREEN_MASK
Definition: SDL_video.c:152

References CHECK_WINDOW_MAGIC, FULLSCREEN_MASK, FULLSCREEN_VISIBLE, and SDL_UpdateFullscreenMode().

Referenced by SDL_FinishWindowCreation().

◆ SDL_SetWindowGammaRamp()

int SDL_SetWindowGammaRamp ( SDL_Window window,
const Uint16 red,
const Uint16 green,
const Uint16 blue 
)

Set the gamma ramp for a window.

Parameters
windowThe window for which the gamma ramp should be set.
redThe translation table for the red channel, or NULL.
greenThe translation table for the green channel, or NULL.
blueThe translation table for the blue channel, or NULL.
Returns
0 on success, or -1 if gamma ramps are unsupported.

Set the gamma translation table for the red, green, and blue channels of the video hardware. Each table is an array of 256 16-bit quantities, representing a mapping between the input and output for that channel. The input is the index into the array, and the output is the 16-bit gamma value at that index, scaled to the output color precision.

See also
SDL_GetWindowGammaRamp()

Definition at line 2557 of file SDL_video.c.

2560 {
2562 
2563  if (!_this->SetWindowGammaRamp) {
2564  return SDL_Unsupported();
2565  }
2566 
2567  if (!window->gamma) {
2568  if (SDL_GetWindowGammaRamp(window, NULL, NULL, NULL) < 0) {
2569  return -1;
2570  }
2571  SDL_assert(window->gamma != NULL);
2572  }
2573 
2574  if (red) {
2575  SDL_memcpy(&window->gamma[0*256], red, 256*sizeof(Uint16));
2576  }
2577  if (green) {
2578  SDL_memcpy(&window->gamma[1*256], green, 256*sizeof(Uint16));
2579  }
2580  if (blue) {
2581  SDL_memcpy(&window->gamma[2*256], blue, 256*sizeof(Uint16));
2582  }
2583  if (window->flags & SDL_WINDOW_INPUT_FOCUS) {
2584  return _this->SetWindowGammaRamp(_this, window, window->gamma);
2585  } else {
2586  return 0;
2587  }
2588 }
int SDL_GetWindowGammaRamp(SDL_Window *window, Uint16 *red, Uint16 *green, Uint16 *blue)
Get the gamma ramp for a window.
Definition: SDL_video.c:2591

References _this, CHECK_WINDOW_MAGIC, NULL, red, SDL_assert, SDL_GetWindowGammaRamp(), SDL_memcpy, SDL_Unsupported, SDL_WINDOW_INPUT_FOCUS, and SDL_VideoDevice::SetWindowGammaRamp.

Referenced by SDL_SetWindowBrightness().

◆ SDL_SetWindowGrab()

void SDL_SetWindowGrab ( SDL_Window window,
SDL_bool  grabbed 
)

Set a window's input grab mode.

Parameters
windowThe window for which the input grab mode should be set.
grabbedThis is SDL_TRUE to grab input, and SDL_FALSE to release input.

If the caller enables a grab while another window is currently grabbed, the other window loses its grab in favor of the caller's window.

See also
SDL_GetWindowGrab()

Definition at line 2667 of file SDL_video.c.

2668 {
2670 
2671  if (!!grabbed == !!(window->flags & SDL_WINDOW_INPUT_GRABBED)) {
2672  return;
2673  }
2674  if (grabbed) {
2675  window->flags |= SDL_WINDOW_INPUT_GRABBED;
2676  } else {
2677  window->flags &= ~SDL_WINDOW_INPUT_GRABBED;
2678  }
2680 }

References CHECK_WINDOW_MAGIC, SDL_UpdateWindowGrab(), and SDL_WINDOW_INPUT_GRABBED.

Referenced by SDL_FinishWindowCreation().

◆ SDL_SetWindowHitTest()

int SDL_SetWindowHitTest ( SDL_Window window,
SDL_HitTest  callback,
void callback_data 
)

Provide a callback that decides if a window region has special properties.

Normally windows are dragged and resized by decorations provided by the system window manager (a title bar, borders, etc), but for some apps, it makes sense to drag them from somewhere else inside the window itself; for example, one might have a borderless window that wants to be draggable from any part, or simulate its own title bar, etc.

This function lets the app provide a callback that designates pieces of a given window as special. This callback is run during event processing if we need to tell the OS to treat a region of the window specially; the use of this callback is known as "hit testing."

Mouse input may not be delivered to your application if it is within a special area; the OS will often apply that input to moving the window or resizing the window and not deliver it to the application.

Specifying NULL for a callback disables hit-testing. Hit-testing is disabled by default.

Platforms that don't support this functionality will return -1 unconditionally, even if you're attempting to disable hit-testing.

Your callback may fire at any time, and its firing does not indicate any specific behavior (for example, on Windows, this certainly might fire when the OS is deciding whether to drag your window, but it fires for lots of other reasons, too, some unrelated to anything you probably care about and when the mouse isn't actually at the location it is testing). Since this can fire at any time, you should try to keep your callback efficient, devoid of allocations, etc.

Parameters
windowThe window to set hit-testing on.
callbackThe callback to call when doing a hit-test.
callback_dataAn app-defined void pointer passed to the callback.
Returns
0 on success, -1 on error (including unsupported).

Definition at line 4145 of file SDL_video.c.

4146 {
4148 
4149  if (!_this->SetWindowHitTest) {
4150  return SDL_Unsupported();
4151  } else if (_this->SetWindowHitTest(window, callback != NULL) == -1) {
4152  return -1;
4153  }
4154 
4155  window->hit_test = callback;
4156  window->hit_test_data = userdata;
4157 
4158  return 0;
4159 }
static Uint32 callback(Uint32 interval, void *param)
Definition: testtimer.c:34

References _this, callback(), CHECK_WINDOW_MAGIC, NULL, SDL_Unsupported, and SDL_VideoDevice::SetWindowHitTest.

◆ SDL_SetWindowIcon()

void SDL_SetWindowIcon ( SDL_Window window,
SDL_Surface icon 
)

Set the icon for a window.

Parameters
windowThe window for which the icon should be set.
iconThe icon for the window.

Definition at line 1885 of file SDL_video.c.

1886 {
1888 
1889  if (!icon) {
1890  return;
1891  }
1892 
1893  SDL_FreeSurface(window->icon);
1894 
1895  /* Convert the icon into ARGB8888 */
1897  if (!window->icon) {
1898  return;
1899  }
1900 
1901  if (_this->SetWindowIcon) {
1903  }
1904 }
#define SDL_ConvertSurfaceFormat
@ SDL_PIXELFORMAT_ARGB8888
Definition: SDL_pixels.h:257

References _this, CHECK_WINDOW_MAGIC, SDL_ConvertSurfaceFormat, SDL_FreeSurface, SDL_PIXELFORMAT_ARGB8888, and SDL_VideoDevice::SetWindowIcon.

◆ SDL_SetWindowInputFocus()

int SDL_SetWindowInputFocus ( SDL_Window window)

Explicitly sets input focus to the window.

You almost certainly want SDL_RaiseWindow() instead of this function. Use this with caution, as you might give focus to a window that's completely obscured by other windows.

Parameters
windowThe window that should get the input focus
Returns
0 on success, or -1 otherwise.
See also
SDL_RaiseWindow()

Definition at line 2544 of file SDL_video.c.

2545 {
2547 
2548  if (!_this->SetWindowInputFocus) {
2549  return SDL_Unsupported();
2550  }
2551 
2553 }
int(* SetWindowInputFocus)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:223

References _this, CHECK_WINDOW_MAGIC, SDL_Unsupported, and SDL_VideoDevice::SetWindowInputFocus.

◆ SDL_SetWindowMaximumSize()

void SDL_SetWindowMaximumSize ( SDL_Window window,
int  max_w,
int  max_h 
)

Set the maximum size of a window's client area.

Parameters
windowThe window to set a new maximum size.
max_wThe maximum width of the window, must be >0
max_hThe maximum height of the window, must be >0
Note
You can't change the maximum size of a fullscreen window, it automatically matches the size of the display mode.
See also
SDL_GetWindowMaximumSize()
SDL_SetWindowMinimumSize()

Definition at line 2222 of file SDL_video.c.

2223 {
2225  if (max_w <= 0) {
2226  SDL_InvalidParamError("max_w");
2227  return;
2228  }
2229  if (max_h <= 0) {
2230  SDL_InvalidParamError("max_h");
2231  return;
2232  }
2233 
2234  if (max_w < window->min_w || max_h < window->min_h) {
2235  SDL_SetError("SDL_SetWindowMaximumSize(): Tried to set maximum size smaller than minimum size");
2236  return;
2237  }
2238 
2239  window->max_w = max_w;
2240  window->max_h = max_h;
2241 
2242  if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
2243  if (_this->SetWindowMaximumSize) {
2245  }
2246  /* Ensure that window is not larger than maximal size */
2247  SDL_SetWindowSize(window, SDL_min(window->w, window->max_w), SDL_min(window->h, window->max_h));
2248  }
2249 }
#define SDL_min(x, y)
Definition: SDL_stdinc.h:412
void SDL_SetWindowSize(SDL_Window *window, int w, int h)
Set the size of a window's client area.
Definition: SDL_video.c:2097
void(* SetWindowMaximumSize)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:219

References _this, CHECK_WINDOW_MAGIC, SDL_InvalidParamError, SDL_min, SDL_SetError, SDL_SetWindowSize(), SDL_WINDOW_FULLSCREEN, and SDL_VideoDevice::SetWindowMaximumSize.

◆ SDL_SetWindowMinimumSize()

void SDL_SetWindowMinimumSize ( SDL_Window window,
int  min_w,
int  min_h 
)

Set the minimum size of a window's client area.

Parameters
windowThe window to set a new minimum size.
min_wThe minimum width of the window, must be >0
min_hThe minimum height of the window, must be >0
Note
You can't change the minimum size of a fullscreen window, it automatically matches the size of the display mode.
See also
SDL_GetWindowMinimumSize()
SDL_SetWindowMaximumSize()

Definition at line 2179 of file SDL_video.c.

2180 {
2182  if (min_w <= 0) {
2183  SDL_InvalidParamError("min_w");
2184  return;
2185  }
2186  if (min_h <= 0) {
2187  SDL_InvalidParamError("min_h");
2188  return;
2189  }
2190 
2191  if ((window->max_w && min_w > window->max_w) ||
2192  (window->max_h && min_h > window->max_h)) {
2193  SDL_SetError("SDL_SetWindowMinimumSize(): Tried to set minimum size larger than maximum size");
2194  return;
2195  }
2196 
2197  window->min_w = min_w;
2198  window->min_h = min_h;
2199 
2200  if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
2201  if (_this->SetWindowMinimumSize) {
2203  }
2204  /* Ensure that window is not smaller than minimal size */
2205  SDL_SetWindowSize(window, SDL_max(window->w, window->min_w), SDL_max(window->h, window->min_h));
2206  }
2207 }
#define SDL_max(x, y)
Definition: SDL_stdinc.h:413
void(* SetWindowMinimumSize)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:218

References _this, CHECK_WINDOW_MAGIC, SDL_InvalidParamError, SDL_max, SDL_SetError, SDL_SetWindowSize(), SDL_WINDOW_FULLSCREEN, and SDL_VideoDevice::SetWindowMinimumSize.

◆ SDL_SetWindowModalFor()

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)

Parameters
modal_windowThe window that should be modal
parent_windowThe parent window
Returns
0 on success, or -1 otherwise.

Definition at line 2531 of file SDL_video.c.

2532 {
2533  CHECK_WINDOW_MAGIC(modal_window, -1);
2534  CHECK_WINDOW_MAGIC(parent_window, -1);
2535 
2536  if (!_this->SetWindowModalFor) {
2537  return SDL_Unsupported();
2538  }
2539 
2540  return _this->SetWindowModalFor(_this, modal_window, parent_window);
2541 }
int(* SetWindowModalFor)(_THIS, SDL_Window *modal_window, SDL_Window *parent_window)
Definition: SDL_sysvideo.h:222

References _this, CHECK_WINDOW_MAGIC, SDL_Unsupported, and SDL_VideoDevice::SetWindowModalFor.

◆ SDL_SetWindowOpacity()

int SDL_SetWindowOpacity ( SDL_Window window,
float  opacity 
)

Set the opacity for a window.

Parameters
windowThe window which will be made transparent or opaque
opacityOpacity (0.0f - transparent, 1.0f - opaque) This will be clamped internally between 0.0f and 1.0f.
Returns
0 on success, or -1 if setting the opacity isn't supported.
See also
SDL_GetWindowOpacity()

Definition at line 2495 of file SDL_video.c.

2496 {
2497  int retval;
2499 
2500  if (!_this->SetWindowOpacity) {
2501  return SDL_Unsupported();
2502  }
2503 
2504  if (opacity < 0.0f) {
2505  opacity = 0.0f;
2506  } else if (opacity > 1.0f) {
2507  opacity = 1.0f;
2508  }
2509 
2510  retval = _this->SetWindowOpacity(_this, window, opacity);
2511  if (retval == 0) {
2512  window->opacity = opacity;
2513  }
2514 
2515  return retval;
2516 }
int(* SetWindowOpacity)(_THIS, SDL_Window *window, float opacity)
Definition: SDL_sysvideo.h:221

References _this, CHECK_WINDOW_MAGIC, retval, SDL_Unsupported, and SDL_VideoDevice::SetWindowOpacity.

◆ SDL_SetWindowPosition()

void SDL_SetWindowPosition ( SDL_Window window,
int  x,
int  y 
)

Set the position of a window.

Parameters
windowThe window to reposition.
xThe x coordinate of the window in screen coordinates, or SDL_WINDOWPOS_CENTERED or SDL_WINDOWPOS_UNDEFINED.
yThe y coordinate of the window in screen coordinates, or SDL_WINDOWPOS_CENTERED or SDL_WINDOWPOS_UNDEFINED.
Note
The window coordinate origin is the upper left of the display.
See also
SDL_GetWindowPosition()

Definition at line 1975 of file SDL_video.c.

1976 {
1978 
1980  int displayIndex = (x & 0xFFFF);
1981  SDL_Rect bounds;
1982  if (displayIndex >= _this->num_displays) {
1983  displayIndex = 0;
1984  }
1985 
1986  SDL_zero(bounds);
1987 
1988  SDL_GetDisplayBounds(displayIndex, &bounds);
1989  if (SDL_WINDOWPOS_ISCENTERED(x)) {
1990  x = bounds.x + (bounds.w - window->w) / 2;
1991  }
1992  if (SDL_WINDOWPOS_ISCENTERED(y)) {
1993  y = bounds.y + (bounds.h - window->h) / 2;
1994  }
1995  }
1996 
1997  if ((window->flags & SDL_WINDOW_FULLSCREEN)) {
1998  if (!SDL_WINDOWPOS_ISUNDEFINED(x)) {
1999  window->windowed.x = x;
2000  }
2001  if (!SDL_WINDOWPOS_ISUNDEFINED(y)) {
2002  window->windowed.y = y;
2003  }
2004  } else {
2005  if (!SDL_WINDOWPOS_ISUNDEFINED(x)) {
2006  window->x = x;
2007  }
2008  if (!SDL_WINDOWPOS_ISUNDEFINED(y)) {
2009  window->y = y;
2010  }
2011 
2012  if (_this->SetWindowPosition) {
2014  }
2015  }
2016 }
void(* SetWindowPosition)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:216

References _this, CHECK_WINDOW_MAGIC, SDL_Rect::h, SDL_VideoDevice::num_displays, SDL_GetDisplayBounds(), SDL_WINDOW_FULLSCREEN, SDL_WINDOWPOS_ISCENTERED, SDL_WINDOWPOS_ISUNDEFINED, SDL_zero, SDL_VideoDevice::SetWindowPosition, SDL_Rect::w, SDL_Rect::x, and SDL_Rect::y.

◆ SDL_SetWindowResizable()

void SDL_SetWindowResizable ( SDL_Window window,
SDL_bool  resizable 
)

Set the user-resizable state of a window.

This will add or remove the window's SDL_WINDOW_RESIZABLE flag and allow/disallow user resizing of the window. This is a no-op if the window's resizable state already matches the requested state.

Parameters
windowThe window of which to change the resizable state.
resizableSDL_TRUE to allow resizing, SDL_FALSE to disallow.
Note
You can't change the resizable state of a fullscreen window.
See also
SDL_GetWindowFlags()

Definition at line 2079 of file SDL_video.c.

2080 {
2082  if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
2083  const int want = (resizable != SDL_FALSE); /* normalize the flag. */
2084  const int have = ((window->flags & SDL_WINDOW_RESIZABLE) != 0);
2085  if ((want != have) && (_this->SetWindowResizable)) {
2086  if (want) {
2087  window->flags |= SDL_WINDOW_RESIZABLE;
2088  } else {
2089  window->flags &= ~SDL_WINDOW_RESIZABLE;
2090  }
2092  }
2093  }
2094 }
@ SDL_WINDOW_RESIZABLE
Definition: SDL_video.h:104
void(* SetWindowResizable)(_THIS, SDL_Window *window, SDL_bool resizable)
Definition: SDL_sysvideo.h:231

References _this, CHECK_WINDOW_MAGIC, SDL_FALSE, SDL_WINDOW_FULLSCREEN, SDL_WINDOW_RESIZABLE, and SDL_VideoDevice::SetWindowResizable.

◆ SDL_SetWindowSize()

void SDL_SetWindowSize ( SDL_Window window,
int  w,
int  h 
)

Set the size of a window's client area.

Parameters
windowThe window to resize.
wThe width of the window, in screen coordinates. Must be >0.
hThe height of the window, in screen coordinates. Must be >0.
Note
Fullscreen windows automatically match the size of the display mode, and you should use SDL_SetWindowDisplayMode() to change their size.

The window size in screen coordinates may differ from the size in pixels, if the window was created with SDL_WINDOW_ALLOW_HIGHDPI on a platform with high-dpi support (e.g. iOS or OS X). Use SDL_GL_GetDrawableSize() or SDL_GetRendererOutputSize() to get the real client area size in pixels.

See also
SDL_GetWindowSize()
SDL_SetWindowDisplayMode()

Definition at line 2097 of file SDL_video.c.

2098 {
2100  if (w <= 0) {
2101  SDL_InvalidParamError("w");
2102  return;
2103  }
2104  if (h <= 0) {
2105  SDL_InvalidParamError("h");
2106  return;
2107  }
2108 
2109  /* Make sure we don't exceed any window size limits */
2110  if (window->min_w && w < window->min_w) {
2111  w = window->min_w;
2112  }
2113  if (window->max_w && w > window->max_w) {
2114  w = window->max_w;
2115  }
2116  if (window->min_h && h < window->min_h) {
2117  h = window->min_h;
2118  }
2119  if (window->max_h && h > window->max_h) {
2120  h = window->max_h;
2121  }
2122 
2123  window->windowed.w = w;
2124  window->windowed.h = h;
2125 
2126  if (window->flags & SDL_WINDOW_FULLSCREEN) {
2128  window->last_fullscreen_flags = 0;
2130  }
2131  } else {
2132  window->w = w;
2133  window->h = h;
2134  if (_this->SetWindowSize) {
2136  }
2137  if (window->w == w && window->h == h) {
2138  /* We didn't get a SDL_WINDOWEVENT_RESIZED event (by design) */
2140  }
2141  }
2142 }
void SDL_OnWindowResized(SDL_Window *window)
Definition: SDL_video.c:2710
void(* SetWindowSize)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:217

References _this, CHECK_WINDOW_MAGIC, FULLSCREEN_VISIBLE, SDL_InvalidParamError, SDL_OnWindowResized(), SDL_TRUE, SDL_UpdateFullscreenMode(), SDL_WINDOW_FULLSCREEN, SDL_WINDOW_FULLSCREEN_DESKTOP, and SDL_VideoDevice::SetWindowSize.

Referenced by SDL_SetWindowMaximumSize(), and SDL_SetWindowMinimumSize().

◆ SDL_SetWindowTitle()

void SDL_SetWindowTitle ( SDL_Window window,
const char *  title 
)

Set the title of a window, in UTF-8 format.

See also
SDL_GetWindowTitle()

Definition at line 1860 of file SDL_video.c.

1861 {
1863 
1864  if (title == window->title) {
1865  return;
1866  }
1867  SDL_free(window->title);
1868 
1869  window->title = SDL_strdup(title ? title : "");
1870 
1871  if (_this->SetWindowTitle) {
1873  }
1874 }

References _this, CHECK_WINDOW_MAGIC, SDL_free, SDL_strdup, and SDL_VideoDevice::SetWindowTitle.

Referenced by SDL_CreateWindow().

◆ SDL_ShouldAllowTopmost()

SDL_bool SDL_ShouldAllowTopmost ( void  )

Definition at line 4139 of file SDL_video.c.

4140 {
4142 }
#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:739

References SDL_GetHintBoolean, SDL_HINT_ALLOW_TOPMOST, and SDL_TRUE.

◆ SDL_ShowMessageBox()

int SDL_ShowMessageBox ( const SDL_MessageBoxData messageboxdata,
int buttonid 
)

Create a modal message box.

Parameters
messageboxdataThe SDL_MessageBoxData structure with title, text, etc.
buttonidThe pointer to which user id of hit button should be copied.
Returns
-1 on error, otherwise 0 and buttonid contains user id of button hit or -1 if dialog was closed.
Note
This function should be called on the thread that created the parent window, or on the main thread if the messagebox has no parent. It will block execution of that thread until the user clicks a button or closes the messagebox.

Definition at line 3993 of file SDL_video.c.

3994 {
3995  int dummybutton;
3996  int retval = -1;
3997  SDL_bool relative_mode;
3998  int show_cursor_prev;
3999  SDL_bool mouse_captured;
4000  SDL_Window *current_window;
4001  SDL_MessageBoxData mbdata;
4002 
4003  if (!messageboxdata) {
4004  return SDL_InvalidParamError("messageboxdata");
4005  } else if (messageboxdata->numbuttons < 0) {
4006  return SDL_SetError("Invalid number of buttons");
4007  }
4008 
4009  current_window = SDL_GetKeyboardFocus();
4010  mouse_captured = current_window && ((SDL_GetWindowFlags(current_window) & SDL_WINDOW_MOUSE_CAPTURE) != 0);
4011  relative_mode = SDL_GetRelativeMouseMode();
4014  show_cursor_prev = SDL_ShowCursor(1);
4016 
4017  if (!buttonid) {
4018  buttonid = &dummybutton;
4019  }
4020 
4021  SDL_memcpy(&mbdata, messageboxdata, sizeof(*messageboxdata));
4022  if (!mbdata.title) mbdata.title = "";
4023  if (!mbdata.message) mbdata.message = "";
4024  messageboxdata = &mbdata;
4025 
4026  if (_this && _this->ShowMessageBox) {
4027  retval = _this->ShowMessageBox(_this, messageboxdata, buttonid);
4028  }
4029 
4030  /* It's completely fine to call this function before video is initialized */
4031 #if SDL_VIDEO_DRIVER_ANDROID
4032  if (retval == -1 &&
4033  Android_ShowMessageBox(messageboxdata, buttonid) == 0) {
4034  retval = 0;
4035  }
4036 #endif
4037 #if SDL_VIDEO_DRIVER_WINDOWS
4038  if (retval == -1 &&
4040  WIN_ShowMessageBox(messageboxdata, buttonid) == 0) {
4041  retval = 0;
4042  }
4043 #endif
4044 #if SDL_VIDEO_DRIVER_WINRT
4045  if (retval == -1 &&
4046  SDL_MessageboxValidForDriver(messageboxdata, SDL_SYSWM_WINRT) &&
4047  WINRT_ShowMessageBox(messageboxdata, buttonid) == 0) {
4048  retval = 0;
4049  }
4050 #endif
4051 #if SDL_VIDEO_DRIVER_COCOA
4052  if (retval == -1 &&
4053  SDL_MessageboxValidForDriver(messageboxdata, SDL_SYSWM_COCOA) &&
4054  Cocoa_ShowMessageBox(messageboxdata, buttonid) == 0) {
4055  retval = 0;
4056  }
4057 #endif
4058 #if SDL_VIDEO_DRIVER_UIKIT
4059  if (retval == -1 &&
4060  SDL_MessageboxValidForDriver(messageboxdata, SDL_SYSWM_UIKIT) &&
4061  UIKit_ShowMessageBox(messageboxdata, buttonid) == 0) {
4062  retval = 0;
4063  }
4064 #endif
4065 #if SDL_VIDEO_DRIVER_X11
4066  if (retval == -1 &&
4067  SDL_MessageboxValidForDriver(messageboxdata, SDL_SYSWM_X11) &&
4068  X11_ShowMessageBox(messageboxdata, buttonid) == 0) {
4069  retval = 0;
4070  }
4071 #endif
4072 #if SDL_VIDEO_DRIVER_HAIKU
4073  if (retval == -1 &&
4074  SDL_MessageboxValidForDriver(messageboxdata, SDL_SYSWM_HAIKU) &&
4075  HAIKU_ShowMessageBox(messageboxdata, buttonid) == 0) {
4076  retval = 0;
4077  }
4078 #endif
4079 #if SDL_VIDEO_DRIVER_OS2
4080  if (retval == -1 &&
4081  SDL_MessageboxValidForDriver(messageboxdata, SDL_SYSWM_OS2) &&
4082  OS2_ShowMessageBox(messageboxdata, buttonid) == 0) {
4083  retval = 0;
4084  }
4085 #endif
4086  if (retval == -1) {
4087  SDL_SetError("No message system available");
4088  }
4089 
4090  if (current_window) {
4091  SDL_RaiseWindow(current_window);
4092  if (mouse_captured) {
4094  }
4095  }
4096 
4097  SDL_ShowCursor(show_cursor_prev);
4098  SDL_SetRelativeMouseMode(relative_mode);
4099 
4100  return retval;
4101 }
#define SDL_ShowCursor
#define SDL_SetRelativeMouseMode
#define SDL_CaptureMouse
#define SDL_GetRelativeMouseMode
void SDL_ResetKeyboard(void)
Definition: SDL_keyboard.c:576
@ SDL_SYSWM_X11
Definition: SDL_syswm.h:131
@ SDL_SYSWM_OS2
Definition: SDL_syswm.h:140
@ SDL_SYSWM_HAIKU
Definition: SDL_syswm.h:141
@ SDL_SYSWM_WINDOWS
Definition: SDL_syswm.h:130
@ SDL_SYSWM_UIKIT
Definition: SDL_syswm.h:134
@ SDL_SYSWM_COCOA
Definition: SDL_syswm.h:133
@ SDL_SYSWM_WINRT
Definition: SDL_syswm.h:137
Uint32 SDL_GetWindowFlags(SDL_Window *window)
Get the window flags.
Definition: SDL_video.c:1852
static SDL_bool SDL_MessageboxValidForDriver(const SDL_MessageBoxData *messageboxdata, SDL_SYSWM_TYPE drivertype)
Definition: SDL_video.c:3974
void SDL_RaiseWindow(SDL_Window *window)
Raise a window above other windows and set the input focus.
Definition: SDL_video.c:2298
@ SDL_WINDOW_MOUSE_CAPTURE
Definition: SDL_video.h:115
MessageBox structure containing title, text, window, etc.
const char * title
const char * message
int(* ShowMessageBox)(_THIS, const SDL_MessageBoxData *messageboxdata, int *buttonid)
Definition: SDL_sysvideo.h:313

References _this, SDL_MessageBoxData::message, SDL_MessageBoxData::numbuttons, retval, SDL_CaptureMouse, SDL_FALSE, SDL_GetKeyboardFocus, SDL_GetRelativeMouseMode, SDL_GetWindowFlags(), SDL_InvalidParamError, SDL_memcpy, SDL_MessageboxValidForDriver(), SDL_RaiseWindow(), SDL_ResetKeyboard(), SDL_SetError, SDL_SetRelativeMouseMode, SDL_ShowCursor, SDL_SYSWM_COCOA, SDL_SYSWM_HAIKU, SDL_SYSWM_OS2, SDL_SYSWM_UIKIT, SDL_SYSWM_WINDOWS, SDL_SYSWM_WINRT, SDL_SYSWM_X11, SDL_TRUE, SDL_WINDOW_MOUSE_CAPTURE, SDL_VideoDevice::ShowMessageBox, and SDL_MessageBoxData::title.

Referenced by SDL_ShowSimpleMessageBox().

◆ SDL_ShowSimpleMessageBox()

int SDL_ShowSimpleMessageBox ( Uint32  flags,
const char *  title,
const char *  message,
SDL_Window window 
)

Create a simple modal message box.

Parameters
flagsSDL_MessageBoxFlags
titleUTF-8 title text
messageUTF-8 message text
windowThe parent window, or NULL for no parent
Returns
0 on success, -1 on error
See also
SDL_ShowMessageBox

Definition at line 4104 of file SDL_video.c.

4105 {
4106 #ifdef __EMSCRIPTEN__
4107  /* !!! FIXME: propose a browser API for this, get this #ifdef out of here? */
4108  /* Web browsers don't (currently) have an API for a custom message box
4109  that can block, but for the most common case (SDL_ShowSimpleMessageBox),
4110  we can use the standard Javascript alert() function. */
4111  if (!title) title = "";
4112  if (!message) message = "";
4113  EM_ASM_({
4114  alert(UTF8ToString($0) + "\n\n" + UTF8ToString($1));
4115  }, title, message);
4116  return 0;
4117 #else
4120 
4121  SDL_zero(data);
4122  data.flags = flags;
4123  data.title = title;
4124  data.message = message;
4125  data.numbuttons = 1;
4126  data.buttons = &button;
4127  data.window = window;
4128 
4129  SDL_zero(button);
4132  button.text = "OK";
4133 
4134  return SDL_ShowMessageBox(&data, NULL);
4135 #endif
4136 }
@ SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT
@ SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT
GLuint GLsizei const GLchar * message
int SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
Create a modal message box.
Definition: SDL_video.c:3993
Individual button data.
SDL_Texture * button

References button, NULL, SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT, SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, SDL_ShowMessageBox(), and SDL_zero.

◆ SDL_ShowWindow()

void SDL_ShowWindow ( SDL_Window window)

Show a window.

See also
SDL_HideWindow()

Definition at line 2264 of file SDL_video.c.

2265 {
2267 
2268  if (window->flags & SDL_WINDOW_SHOWN) {
2269  return;
2270  }
2271 
2272  if (_this->ShowWindow) {
2274  }
2276 }
@ SDL_WINDOWEVENT_SHOWN
Definition: SDL_video.h:149
void(* ShowWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:224

References _this, CHECK_WINDOW_MAGIC, SDL_SendWindowEvent(), SDL_WINDOW_SHOWN, SDL_WINDOWEVENT_SHOWN, and SDL_VideoDevice::ShowWindow.

Referenced by SDL_FinishWindowCreation().

◆ SDL_StartTextInput()

void SDL_StartTextInput ( void  )

Start accepting Unicode text input events. This function will show the on-screen keyboard if supported.

See also
SDL_StopTextInput()
SDL_SetTextInputRect()
SDL_HasScreenKeyboardSupport()

Definition at line 3875 of file SDL_video.c.

3876 {
3877  SDL_Window *window;
3878 
3879  /* First, enable text events */
3882 
3883  /* Then show the on-screen keyboard, if any */
3885  if (window && _this && _this->ShowScreenKeyboard) {
3887  }
3888 
3889  /* Finally start the text input system */
3890  if (_this && _this->StartTextInput) {
3892  }
3893 }
#define SDL_EventState
@ SDL_TEXTEDITING
Definition: SDL_events.h:100
SDL_Window * SDL_GetFocusWindow(void)
Definition: SDL_video.c:2812
void(* StartTextInput)(_THIS)
Definition: SDL_sysvideo.h:297
void(* ShowScreenKeyboard)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:303

References _this, SDL_ENABLE, SDL_EventState, SDL_GetFocusWindow(), SDL_TEXTEDITING, SDL_TEXTINPUT, SDL_VideoDevice::ShowScreenKeyboard, and SDL_VideoDevice::StartTextInput.

Referenced by SDL_VideoInit().

◆ SDL_StopTextInput()

void SDL_StopTextInput ( void  )

Stop receiving any text input events. This function will hide the on-screen keyboard if supported.

See also
SDL_StartTextInput()
SDL_HasScreenKeyboardSupport()

Definition at line 3902 of file SDL_video.c.

3903 {
3904  SDL_Window *window;
3905 
3906  /* Stop the text input system */
3907  if (_this && _this->StopTextInput) {
3909  }
3910 
3911  /* Hide the on-screen keyboard, if any */
3913  if (window && _this && _this->HideScreenKeyboard) {
3915  }
3916 
3917  /* Finally disable text events */
3920 }
#define SDL_DISABLE
Definition: SDL_events.h:794
void(* HideScreenKeyboard)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:304
void(* StopTextInput)(_THIS)
Definition: SDL_sysvideo.h:298

References _this, SDL_VideoDevice::HideScreenKeyboard, SDL_DISABLE, SDL_EventState, SDL_GetFocusWindow(), SDL_TEXTEDITING, SDL_TEXTINPUT, and SDL_VideoDevice::StopTextInput.

◆ SDL_ToggleDragAndDropSupport()

void SDL_ToggleDragAndDropSupport ( void  )

Definition at line 1412 of file SDL_video.c.

1413 {
1414  if (_this && _this->AcceptDragAndDrop) {
1416  SDL_Window *window;
1417  for (window = _this->windows; window; window = window->next) {
1419  }
1420  }
1421 }
GLboolean enable

References _this, SDL_VideoDevice::AcceptDragAndDrop, IsAcceptingDragAndDrop(), SDL_Window::next, and SDL_VideoDevice::windows.

Referenced by SDL_EventState().

◆ SDL_UninitializedVideo()

◆ SDL_UpdateFullscreenMode()

static int SDL_UpdateFullscreenMode ( SDL_Window window,
SDL_bool  fullscreen 
)
static

Definition at line 1224 of file SDL_video.c.

1225 {
1226  SDL_VideoDisplay *display;
1227  SDL_Window *other;
1228 
1230 
1231  /* if we are in the process of hiding don't go back to fullscreen */
1232  if (window->is_hiding && fullscreen) {
1233  return 0;
1234  }
1235 
1236 #ifdef __MACOSX__
1237  /* if the window is going away and no resolution change is necessary,
1238  do nothing, or else we may trigger an ugly double-transition
1239  */
1240  if (SDL_strcmp(_this->name, "cocoa") == 0) { /* don't do this for X11, etc */
1241  if (window->is_destroying && (window->last_fullscreen_flags & FULLSCREEN_MASK) == SDL_WINDOW_FULLSCREEN_DESKTOP)
1242  return 0;
1243 
1244  /* If we're switching between a fullscreen Space and "normal" fullscreen, we need to get back to normal first. */
1245  if (fullscreen && ((window->last_fullscreen_flags & FULLSCREEN_MASK) == SDL_WINDOW_FULLSCREEN_DESKTOP) && ((window->flags & FULLSCREEN_MASK) == SDL_WINDOW_FULLSCREEN)) {
1246  if (!Cocoa_SetWindowFullscreenSpace(window, SDL_FALSE)) {
1247  return -1;
1248  }
1249  } else if (fullscreen && ((window->last_fullscreen_flags & FULLSCREEN_MASK) == SDL_WINDOW_FULLSCREEN) && ((window->flags & FULLSCREEN_MASK) == SDL_WINDOW_FULLSCREEN_DESKTOP)) {
1250  display = SDL_GetDisplayForWindow(window);
1252  if (_this->SetWindowFullscreen) {
1254  }
1255  }
1256 
1257  if (Cocoa_SetWindowFullscreenSpace(window, fullscreen)) {
1258  if (Cocoa_IsWindowInFullscreenSpace(window) != fullscreen) {
1259  return -1;
1260  }
1261  window->last_fullscreen_flags = window->flags;
1262  return 0;
1263  }
1264  }
1265 #elif __WINRT__ && (NTDDI_VERSION < NTDDI_WIN10)
1266  /* HACK: WinRT 8.x apps can't choose whether or not they are fullscreen
1267  or not. The user can choose this, via OS-provided UI, but this can't
1268  be set programmatically.
1269 
1270  Just look at what SDL's WinRT video backend code detected with regards
1271  to fullscreen (being active, or not), and figure out a return/error code
1272  from that.
1273  */
1274  if (fullscreen == !(WINRT_DetectWindowFlags(window) & FULLSCREEN_MASK)) {
1275  /* Uh oh, either:
1276  1. fullscreen was requested, and we're already windowed
1277  2. windowed-mode was requested, and we're already fullscreen
1278 
1279  WinRT 8.x can't resolve either programmatically, so we're
1280  giving up.
1281  */
1282  return -1;
1283  } else {
1284  /* Whatever was requested, fullscreen or windowed mode, is already
1285  in-place.
1286  */
1287  return 0;
1288  }
1289 #endif
1290 
1291  display = SDL_GetDisplayForWindow(window);
1292 
1293  if (fullscreen) {
1294  /* Hide any other fullscreen windows */
1295  if (display->fullscreen_window &&
1296  display->fullscreen_window != window) {
1298  }
1299  }
1300 
1301  /* See if anything needs to be done now */
1302  if ((display->fullscreen_window == window) == fullscreen) {
1303  if ((window->last_fullscreen_flags & FULLSCREEN_MASK) == (window->flags & FULLSCREEN_MASK)) {
1304  return 0;
1305  }
1306  }
1307 
1308  /* See if there are any fullscreen windows */
1309  for (other = _this->windows; other; other = other->next) {
1310  SDL_bool setDisplayMode = SDL_FALSE;
1311 
1312  if (other == window) {
1313  setDisplayMode = fullscreen;
1314  } else if (FULLSCREEN_VISIBLE(other) &&
1315  SDL_GetDisplayForWindow(other) == display) {
1316  setDisplayMode = SDL_TRUE;
1317  }
1318 
1319  if (setDisplayMode) {
1320  SDL_DisplayMode fullscreen_mode;
1321 
1322  SDL_zero(fullscreen_mode);
1323 
1324  if (SDL_GetWindowDisplayMode(other, &fullscreen_mode) == 0) {
1325  SDL_bool resized = SDL_TRUE;
1326 
1327  if (other->w == fullscreen_mode.w && other->h == fullscreen_mode.h) {
1328  resized = SDL_FALSE;
1329  }
1330 
1331  /* only do the mode change if we want exclusive fullscreen */
1333  if (SDL_SetDisplayModeForDisplay(display, &fullscreen_mode) < 0) {
1334  return -1;
1335  }
1336  } else {
1337  if (SDL_SetDisplayModeForDisplay(display, NULL) < 0) {
1338  return -1;
1339  }
1340  }
1341 
1342  if (_this->SetWindowFullscreen) {
1343  _this->SetWindowFullscreen(_this, other, display, SDL_TRUE);
1344  }
1345  display->fullscreen_window = other;
1346 
1347  /* Generate a mode change event here */
1348  if (resized) {
1349 #ifndef ANDROID
1350  // Android may not resize the window to exactly what our fullscreen mode is, especially on
1351  // windowed Android environments like the Chromebook or Samsung DeX. Given this, we shouldn't
1352  // use fullscreen_mode.w and fullscreen_mode.h, but rather get our current native size. As such,
1353  // Android's SetWindowFullscreen will generate the window event for us with the proper final size.
1354 
1356  fullscreen_mode.w, fullscreen_mode.h);
1357 #endif
1358  } else {
1359  SDL_OnWindowResized(other);
1360  }
1361 
1362  SDL_RestoreMousePosition(other);
1363 
1364  window->last_fullscreen_flags = window->flags;
1365  return 0;
1366  }
1367  }
1368  }
1369 
1370  /* Nope, restore the desktop mode */
1372 
1373  if (_this->SetWindowFullscreen) {
1375  }
1376  display->fullscreen_window = NULL;
1377 
1378  /* Generate a mode change event here */
1380 
1381  /* Restore the cursor position */
1383 
1384  window->last_fullscreen_flags = window->flags;
1385  return 0;
1386 }
static void SDL_RestoreMousePosition(SDL_Window *window)
Definition: SDL_video.c:1209
@ SDL_WINDOWEVENT_RESIZED
Definition: SDL_video.h:155
Uint32 WINRT_DetectWindowFlags(SDL_Window *window)
void(* SetWindowFullscreen)(_THIS, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen)
Definition: SDL_sysvideo.h:232

References _this, CHECK_WINDOW_MAGIC, FULLSCREEN_MASK, FULLSCREEN_VISIBLE, SDL_VideoDisplay::fullscreen_window, SDL_DisplayMode::h, SDL_Window::h, SDL_VideoDevice::name, SDL_Window::next, NULL, SDL_FALSE, SDL_GetDisplayForWindow(), SDL_GetWindowDisplayMode(), SDL_MinimizeWindow(), SDL_OnWindowResized(), SDL_RestoreMousePosition(), SDL_SendWindowEvent(), SDL_SetDisplayModeForDisplay(), SDL_strcmp, SDL_TRUE, SDL_WINDOW_FULLSCREEN, SDL_WINDOW_FULLSCREEN_DESKTOP, SDL_WINDOWEVENT_RESIZED, SDL_zero, SDL_VideoDevice::SetWindowFullscreen, SDL_DisplayMode::w, SDL_Window::w, SDL_VideoDevice::windows, and WINRT_DetectWindowFlags().

Referenced by SDL_CreateWindow(), SDL_HideWindow(), SDL_MinimizeWindow(), SDL_OnWindowHidden(), SDL_OnWindowMinimized(), SDL_OnWindowRestored(), SDL_SetWindowFullscreen(), and SDL_SetWindowSize().

◆ SDL_UpdateWindowGrab()

void SDL_UpdateWindowGrab ( SDL_Window window)

Definition at line 2636 of file SDL_video.c.

2637 {
2638  SDL_Window *grabbed_window;
2639  SDL_bool grabbed;
2640  if ((SDL_GetMouse()->relative_mode || (window->flags & SDL_WINDOW_INPUT_GRABBED)) &&
2641  (window->flags & SDL_WINDOW_INPUT_FOCUS)) {
2642  grabbed = SDL_TRUE;
2643  } else {
2644  grabbed = SDL_FALSE;
2645  }
2646 
2647  grabbed_window = _this->grabbed_window;
2648  if (grabbed) {
2649  if (grabbed_window && (grabbed_window != window)) {
2650  /* stealing a grab from another window! */
2651  grabbed_window->flags &= ~SDL_WINDOW_INPUT_GRABBED;
2652  if (_this->SetWindowGrab) {
2653  _this->SetWindowGrab(_this, grabbed_window, SDL_FALSE);
2654  }
2655  }
2657  } else if (grabbed_window == window) {
2658  _this->grabbed_window = NULL; /* ungrabbing. */
2659  }
2660 
2661  if (_this->SetWindowGrab) {
2662  _this->SetWindowGrab(_this, window, grabbed);
2663  }
2664 }
void(* SetWindowGrab)(_THIS, SDL_Window *window, SDL_bool grabbed)
Definition: SDL_sysvideo.h:235

References _this, SDL_Window::flags, SDL_VideoDevice::grabbed_window, NULL, SDL_FALSE, SDL_GetMouse(), SDL_TRUE, SDL_WINDOW_INPUT_FOCUS, SDL_WINDOW_INPUT_GRABBED, and SDL_VideoDevice::SetWindowGrab.

Referenced by SDL_OnWindowFocusGained(), SDL_OnWindowFocusLost(), SDL_SetRelativeMouseMode(), and SDL_SetWindowGrab().

◆ SDL_UpdateWindowSurface()

int SDL_UpdateWindowSurface ( SDL_Window window)

Copy the window surface to the screen.

Returns
0 on success, or -1 on error.
See also
SDL_GetWindowSurface()
SDL_UpdateWindowSurfaceRects()

Definition at line 2444 of file SDL_video.c.

2445 {
2446  SDL_Rect full_rect;
2447 
2449 
2450  full_rect.x = 0;
2451  full_rect.y = 0;
2452  full_rect.w = window->w;
2453  full_rect.h = window->h;
2454  return SDL_UpdateWindowSurfaceRects(window, &full_rect, 1);
2455 }
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:2458

References CHECK_WINDOW_MAGIC, SDL_Rect::h, SDL_UpdateWindowSurfaceRects(), SDL_Rect::w, SDL_Rect::x, and SDL_Rect::y.

◆ SDL_UpdateWindowSurfaceRects()

int SDL_UpdateWindowSurfaceRects ( SDL_Window window,
const SDL_Rect rects,
int  numrects 
)

Copy a number of rectangles on the window surface to the screen.

Returns
0 on success, or -1 on error.
See also
SDL_GetWindowSurface()
SDL_UpdateWindowSurface()

Definition at line 2458 of file SDL_video.c.

2460 {
2462 
2463  if (!window->surface_valid) {
2464  return SDL_SetError("Window surface is invalid, please call SDL_GetWindowSurface() to get a new surface");
2465  }
2466 
2467  return _this->UpdateWindowFramebuffer(_this, window, rects, numrects);
2468 }
EGLSurface EGLint * rects
Definition: eglext.h:282

References _this, CHECK_WINDOW_MAGIC, SDL_SetError, and SDL_VideoDevice::UpdateWindowFramebuffer.

Referenced by SDL_UpdateWindowSurface().

◆ SDL_UpdateWindowTexture()

static int SDL_UpdateWindowTexture ( SDL_VideoDevice unused,
SDL_Window window,
const SDL_Rect rects,
int  numrects 
)
static

Definition at line 374 of file SDL_video.c.

375 {
377  SDL_Rect rect;
378  void *src;
379 
381  if (!data || !data->texture) {
382  return SDL_SetError("No window texture data");
383  }
384 
385  /* Update a single rect that contains subrects for best DMA performance */
386  if (SDL_GetSpanEnclosingRect(window->w, window->h, numrects, rects, &rect)) {
387  src = (void *)((Uint8 *)data->pixels +
388  rect.y * data->pitch +
389  rect.x * data->bytes_per_pixel);
390  if (SDL_UpdateTexture(data->texture, &rect, src, data->pitch) < 0) {
391  return -1;
392  }
393 
394  if (SDL_RenderCopy(data->renderer, data->texture, NULL, NULL) < 0) {
395  return -1;
396  }
397 
398  SDL_RenderPresent(data->renderer);
399  }
400  return 0;
401 }
#define SDL_RenderPresent
#define SDL_UpdateTexture
#define SDL_RenderCopy
GLenum src
SDL_bool SDL_GetSpanEnclosingRect(int width, int height, int numrects, const SDL_Rect *rects, SDL_Rect *span)
Definition: SDL_rect.c:468
uint8_t Uint8
Definition: SDL_stdinc.h:185

References NULL, rect, SDL_GetSpanEnclosingRect(), SDL_GetWindowData(), SDL_RenderCopy, SDL_RenderPresent, SDL_SetError, SDL_UpdateTexture, SDL_WINDOWTEXTUREDATA, SDL_Rect::x, and SDL_Rect::y.

Referenced by SDL_VideoInit().

◆ SDL_VideoInit()

int SDL_VideoInit ( const char *  driver_name)

Initialize the video subsystem, optionally specifying a video driver.

Parameters
driver_nameInitialize a specific driver by name, or NULL for the default video driver.
Returns
0 on success, -1 on error

This function initializes the video subsystem; setting up a connection to the window manager, etc, and determines the available display modes and pixel formats, but does not initialize a window or graphics mode.

See also
SDL_VideoQuit()

Definition at line 469 of file SDL_video.c.

470 {
471  SDL_VideoDevice *video;
472  int index;
473  int i;
474 
475  /* Check to make sure we don't overwrite '_this' */
476  if (_this != NULL) {
477  SDL_VideoQuit();
478  }
479 
480 #if !SDL_TIMERS_DISABLED
481  SDL_TicksInit();
482 #endif
483 
484  /* Start the event loop */
486  SDL_KeyboardInit() < 0 ||
487  SDL_MouseInit() < 0 ||
488  SDL_TouchInit() < 0) {
489  return -1;
490  }
491 
492  /* Select the proper video driver */
493  index = 0;
494  video = NULL;
495  if (driver_name == NULL) {
496  driver_name = SDL_getenv("SDL_VIDEODRIVER");
497  }
498  if (driver_name != NULL) {
499  for (i = 0; bootstrap[i]; ++i) {
500  if (SDL_strncasecmp(bootstrap[i]->name, driver_name, SDL_strlen(driver_name)) == 0) {
501  video = bootstrap[i]->create(index);
502  break;
503  }
504  }
505  } else {
506  for (i = 0; bootstrap[i]; ++i) {
507  video = bootstrap[i]->create(index);
508  if (video != NULL) {
509  break;
510  }
511  }
512  }
513  if (video == NULL) {
514  if (driver_name) {
515  return SDL_SetError("%s not available", driver_name);
516  }
517  return SDL_SetError("No available video device");
518  }
519  _this = video;
520  _this->name = bootstrap[i]->name;
521  _this->next_object_id = 1;
522 
523 
524  /* Set some very sane GL defaults */
528 
531 
532  /* Initialize the video subsystem */
533  if (_this->VideoInit(_this) < 0) {
534  SDL_VideoQuit();
535  return -1;
536  }
537 
538  /* Make sure some displays were added */
539  if (_this->num_displays == 0) {
540  SDL_VideoQuit();
541  return SDL_SetError("The video driver did not add any displays");
542  }
543 
544  /* Add the renderer framebuffer emulation if desired */
549  }
550 
551  /* Disable the screen saver by default. This is a change from <= 2.0.1,
552  but most things using SDL are games or media players; you wouldn't
553  want a screensaver to trigger if you're playing exclusively with a
554  joystick, or passively watching a movie. Things that use SDL but
555  function more like a normal desktop app should explicitly reenable the
556  screensaver. */
559  }
560 
561  /* If we don't use a screen keyboard, turn on text input by default,
562  otherwise programs that expect to get text events without enabling
563  UNICODE input won't get any events.
564 
565  Actually, come to think of it, you needed to call SDL_EnableUNICODE(1)
566  in SDL 1.2 before you got text input events. Hmm...
567  */
570  }
571 
572  /* We're ready to go! */
573  return 0;
574 }
#define SDL_INIT_EVENTS
Definition: SDL.h:86
#define SDL_TLSCreate
#define SDL_InitSubSystem
#define SDL_strncasecmp
#define SDL_HINT_VIDEO_ALLOW_SCREENSAVER
A variable controlling whether the screensaver is enabled.
Definition: SDL_hints.h:165
int SDL_KeyboardInit(void)
Definition: SDL_keyboard.c:566
int SDL_MouseInit(void)
Definition: SDL_mouse.c:132
void SDL_TicksInit(void)
int SDL_TouchInit(void)
Definition: SDL_touch.c:45
SDL_bool SDL_HasScreenKeyboardSupport(void)
Returns whether the platform has some screen keyboard support.
Definition: SDL_video.c:3931
static SDL_bool ShouldUseTextureFramebuffer()
Definition: SDL_video.c:174
static void SDL_DestroyWindowTexture(SDL_VideoDevice *unused, SDL_Window *window)
Definition: SDL_video.c:404
static int SDL_CreateWindowTexture(SDL_VideoDevice *unused, SDL_Window *window, Uint32 *format, void **pixels, int *pitch)
Definition: SDL_video.c:264
void SDL_DisableScreenSaver()
Prevent the screen from being blanked by a screensaver.
Definition: SDL_video.c:2931
void SDL_StartTextInput(void)
Start accepting Unicode text input events. This function will show the on-screen keyboard if supporte...
Definition: SDL_video.c:3875
void SDL_GL_ResetAttributes()
Reset all previously set OpenGL context attributes to their default values.
Definition: SDL_video.c:3187
static int SDL_UpdateWindowTexture(SDL_VideoDevice *unused, SDL_Window *window, const SDL_Rect *rects, int numrects)
Definition: SDL_video.c:374
void SDL_VideoQuit(void)
Shuts down the video subsystem.
Definition: SDL_video.c:2946
int(* VideoInit)(_THIS)
Definition: SDL_sysvideo.h:162
SDL_VideoDevice *(* create)(int devindex)
Definition: SDL_sysvideo.h:416

References _this, bootstrap, VideoBootStrap::create, SDL_VideoDevice::CreateWindowFramebuffer, SDL_VideoDevice::current_glctx_tls, SDL_VideoDevice::current_glwin_tls, SDL_VideoDevice::DestroyWindowFramebuffer, SDL_VideoDevice::dll_handle, SDL_VideoDevice::driver_loaded, SDL_VideoDevice::gl_config, i, SDL_VideoDevice::name, VideoBootStrap::name, SDL_VideoDevice::next_object_id, NULL, SDL_VideoDevice::num_displays, SDL_CreateWindowTexture(), SDL_DestroyWindowTexture(), SDL_DisableScreenSaver(), SDL_FALSE, SDL_getenv, SDL_GetHintBoolean, SDL_GL_ResetAttributes(), SDL_HasScreenKeyboardSupport(), SDL_HINT_VIDEO_ALLOW_SCREENSAVER, SDL_INIT_EVENTS, SDL_InitSubSystem, SDL_KeyboardInit(), SDL_MouseInit(), SDL_SetError, SDL_StartTextInput(), SDL_strlen, SDL_strncasecmp, SDL_TicksInit(), SDL_TLSCreate, SDL_TouchInit(), SDL_UpdateWindowTexture(), SDL_VideoQuit(), ShouldUseTextureFramebuffer(), SDL_VideoDevice::UpdateWindowFramebuffer, and SDL_VideoDevice::VideoInit.

◆ SDL_VideoQuit()

void SDL_VideoQuit ( void  )

Shuts down the video subsystem.

This function closes all windows, and restores the original video mode.

See also
SDL_VideoInit()

Definition at line 2946 of file SDL_video.c.

2947 {
2948  int i, j;
2949 
2950  if (!_this) {
2951  return;
2952  }
2953 
2954  /* Halt event processing before doing anything else */
2955  SDL_TouchQuit();
2956  SDL_MouseQuit();
2957  SDL_KeyboardQuit();
2959 
2961 
2962  /* Clean up the system video */
2963  while (_this->windows) {
2965  }
2966  _this->VideoQuit(_this);
2967 
2968  for (i = 0; i < _this->num_displays; ++i) {
2969  SDL_VideoDisplay *display = &_this->displays[i];
2970  for (j = display->num_display_modes; j--;) {
2971  SDL_free(display->display_modes[j].driverdata);
2972  display->display_modes[j].driverdata = NULL;
2973  }
2974  SDL_free(display->display_modes);
2975  display->display_modes = NULL;
2976  SDL_free(display->desktop_mode.driverdata);
2977  display->desktop_mode.driverdata = NULL;
2978  SDL_free(display->driverdata);
2979  display->driverdata = NULL;
2980  }
2981  if (_this->displays) {
2982  for (i = 0; i < _this->num_displays; ++i) {
2984  }
2986  _this->displays = NULL;
2987  _this->num_displays = 0;
2988  }
2991  _this->free(_this);
2992  _this = NULL;
2993 }
#define SDL_QuitSubSystem
void SDL_KeyboardQuit(void)
Definition: SDL_keyboard.c:891
void SDL_MouseQuit(void)
Definition: SDL_mouse.c:659
void SDL_TouchQuit(void)
Definition: SDL_touch.c:464
void SDL_EnableScreenSaver()
Allow the screen to be blanked by a screensaver.
Definition: SDL_video.c:2916
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(* VideoQuit)(_THIS)
Definition: SDL_sysvideo.h:168
void(* free)(_THIS)
Definition: SDL_sysvideo.h:409
char * clipboard_text
Definition: SDL_sysvideo.h:331

References _this, SDL_VideoDevice::clipboard_text, SDL_VideoDisplay::desktop_mode, SDL_VideoDisplay::display_modes, SDL_VideoDevice::displays, SDL_DisplayMode::driverdata, SDL_VideoDisplay::driverdata, SDL_VideoDevice::free, i, j, SDL_VideoDisplay::name, NULL, SDL_VideoDisplay::num_display_modes, SDL_VideoDevice::num_displays, SDL_DestroyWindow(), SDL_EnableScreenSaver(), SDL_free, SDL_INIT_EVENTS, SDL_KeyboardQuit(), SDL_MouseQuit(), SDL_QuitSubSystem, SDL_TouchQuit(), SDL_VideoDevice::VideoQuit, and SDL_VideoDevice::windows.

Referenced by SDL_VideoInit().

◆ SDL_Vulkan_CreateSurface()

SDL_bool SDL_Vulkan_CreateSurface ( SDL_Window window,
VkInstance  instance,
VkSurfaceKHR *  surface 
)

Create a Vulkan rendering surface for a window.

Parameters
[in]windowSDL_Window to which to attach the rendering surface.
[in]instancehandle to the Vulkan instance to use.
[out]surfacepointer to a VkSurfaceKHR handle to receive the handle of the newly created surface.
Returns
SDL_TRUE on success, SDL_FALSE on error.
VkInstance instance;
// create instance and window
// create the Vulkan surface
VkSurfaceKHR surface;
handle_error();
#define SDL_Vulkan_CreateSurface
EGLSurface surface
Definition: eglext.h:248
Note
window should have been created with the SDL_WINDOW_VULKAN flag.
instance should have been created with the extensions returned by SDL_Vulkan_CreateSurface() enabled.
See also
SDL_Vulkan_GetInstanceExtensions()

Definition at line 4298 of file SDL_video.c.

4301 {
4303 
4304  if (!(window->flags & SDL_WINDOW_VULKAN)) {
4306  return SDL_FALSE;
4307  }
4308 
4309  if (!instance) {
4310  SDL_InvalidParamError("instance");
4311  return SDL_FALSE;
4312  }
4313 
4314  if (!surface) {
4315  SDL_InvalidParamError("surface");
4316  return SDL_FALSE;
4317  }
4318 
4319  return _this->Vulkan_CreateSurface(_this, window, instance, surface);
4320 }
#define NOT_A_VULKAN_WINDOW
Definition: SDL_video.c:4221

References _this, CHECK_WINDOW_MAGIC, NOT_A_VULKAN_WINDOW, SDL_FALSE, SDL_InvalidParamError, SDL_SetError, SDL_WINDOW_VULKAN, and SDL_VideoDevice::Vulkan_CreateSurface.

◆ SDL_Vulkan_GetDrawableSize()

void SDL_Vulkan_GetDrawableSize ( SDL_Window window,
int w,
int h 
)

Get the size of a window's underlying drawable in pixels (for use with setting viewport, scissor & etc).

Parameters
windowSDL_Window from which the drawable size should be queried
wPointer to variable for storing the width in pixels, may be NULL
hPointer to variable for storing the height in pixels, may be NULL

This may differ from SDL_GetWindowSize() if we're rendering to a high-DPI drawable, i.e. the window was created with SDL_WINDOW_ALLOW_HIGHDPI on a platform with high-DPI support (Apple calls this "Retina"), and not disabled by the SDL_HINT_VIDEO_HIGHDPI_DISABLED hint.

Note
On macOS high-DPI support must be enabled for an application by setting NSHighResolutionCapable to true in its Info.plist.
See also
SDL_GetWindowSize()
SDL_CreateWindow()

Definition at line 4322 of file SDL_video.c.

4323 {
4325 
4328  } else {
4330  }
4331 }
void(* Vulkan_GetDrawableSize)(_THIS, SDL_Window *window, int *w, int *h)
Definition: SDL_sysvideo.h:276

References _this, CHECK_WINDOW_MAGIC, SDL_GetWindowSize(), and SDL_VideoDevice::Vulkan_GetDrawableSize.

◆ SDL_Vulkan_GetInstanceExtensions()

SDL_bool SDL_Vulkan_GetInstanceExtensions ( SDL_Window window,
unsigned *  count,
const char **  names 
)

Definition at line 4278 of file SDL_video.c.

4279 {
4280  if (window) {
4282 
4283  if (!(window->flags & SDL_WINDOW_VULKAN))
4284  {
4286  return SDL_FALSE;
4287  }
4288  }
4289 
4290  if (!count) {
4291  SDL_InvalidParamError("count");
4292  return SDL_FALSE;
4293  }
4294 
4296 }
GLuint GLuint GLsizei count
Definition: SDL_opengl.h:1571
GLuint GLuint * names
SDL_bool(* Vulkan_GetInstanceExtensions)(_THIS, SDL_Window *window, unsigned *count, const char **names)
Definition: SDL_sysvideo.h:274

References _this, CHECK_WINDOW_MAGIC, NOT_A_VULKAN_WINDOW, SDL_FALSE, SDL_InvalidParamError, SDL_SetError, SDL_WINDOW_VULKAN, and SDL_VideoDevice::Vulkan_GetInstanceExtensions.

◆ SDL_Vulkan_GetVkGetInstanceProcAddr()

void* SDL_Vulkan_GetVkGetInstanceProcAddr ( void  )

Get the address of the vkGetInstanceProcAddr function.

Note
This should be called after either calling SDL_Vulkan_LoadLibrary or creating an SDL_Window with the SDL_WINDOW_VULKAN flag.

Definition at line 4249 of file SDL_video.c.

4250 {
4251  if (!_this) {
4253  return NULL;
4254  }
4256  SDL_SetError("No Vulkan loader has been loaded");
4257  return NULL;
4258  }
4260 }
struct SDL_VideoDevice::@441 vulkan_config
PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr
Definition: SDL_sysvideo.h:387

References _this, SDL_VideoDevice::loader_loaded, NULL, SDL_SetError, SDL_UninitializedVideo(), SDL_VideoDevice::vkGetInstanceProcAddr, and SDL_VideoDevice::vulkan_config.

◆ SDL_Vulkan_LoadLibrary()

int SDL_Vulkan_LoadLibrary ( const char *  path)

Dynamically load a Vulkan loader library.

Parameters
[in]pathThe platform dependent Vulkan loader library name, or NULL.
Returns
0 on success, or -1 if the library couldn't be loaded.

If path is NULL SDL will use the value of the environment variable SDL_VULKAN_LIBRARY, if set, otherwise it loads the default Vulkan loader library.

This should be called after initializing the video driver, but before creating any Vulkan windows. If no Vulkan loader library is loaded, the default library will be loaded upon creation of the first Vulkan window.

Note
It is fairly common for Vulkan applications to link with libvulkan instead of explicitly loading it at run time. This will work with SDL provided the application links to a dynamic library and both it and SDL use the same search path.
If you specify a non-NULL path, an application should retrieve all of the Vulkan functions it uses from the dynamic library using SDL_Vulkan_GetVkGetInstanceProcAddr() unless you can guarantee path points to the same vulkan loader library the application linked to.
On Apple devices, if path is NULL, SDL will attempt to find the vkGetInstanceProcAddr address within all the mach-o images of the current process. This is because it is fairly common for Vulkan applications to link with libvulkan (and historically MoltenVK was provided as a static library). If it is not found then, on macOS, SDL will attempt to load vulkan.framework/vulkan, libvulkan.1.dylib, followed by libvulkan.dylib, in that order. On iOS SDL will attempt to load libvulkan.dylib only. Applications using a dynamic framework or .dylib must ensure it is included in its application bundle.
On non-Apple devices, application linking with a static libvulkan is not supported. Either do not link to the Vulkan loader or link to a dynamic library version.
This function will fail if there are no working Vulkan drivers installed.
See also
SDL_Vulkan_GetVkGetInstanceProcAddr()
SDL_Vulkan_UnloadLibrary()

Definition at line 4223 of file SDL_video.c.

4224 {
4225  int retval;
4226  if (!_this) {
4228  return -1;
4229  }
4232  return SDL_SetError("Vulkan loader library already loaded");
4233  }
4234  retval = 0;
4235  } else {
4236  if (!_this->Vulkan_LoadLibrary) {
4237  return SDL_SetError("Vulkan support is either not configured in SDL "
4238  "or not available in current SDL video driver "
4239  "(%s) or platform", _this->name);
4240  }
4242  }
4243  if (retval == 0) {
4245  }
4246  return retval;
4247 }
int(* Vulkan_LoadLibrary)(_THIS, const char *path)
Definition: SDL_sysvideo.h:272
char loader_path[256]
Definition: SDL_sysvideo.h:390

References _this, SDL_VideoDevice::loader_loaded, SDL_VideoDevice::loader_path, SDL_VideoDevice::name, retval, SDL_SetError, SDL_strcmp, SDL_UninitializedVideo(), SDL_VideoDevice::vulkan_config, and SDL_VideoDevice::Vulkan_LoadLibrary.

Referenced by SDL_CreateWindow(), and SDL_RecreateWindow().

◆ SDL_Vulkan_UnloadLibrary()

void SDL_Vulkan_UnloadLibrary ( void  )

Unload the Vulkan loader library previously loaded by SDL_Vulkan_LoadLibrary().

See also
SDL_Vulkan_LoadLibrary()

Definition at line 4262 of file SDL_video.c.

4263 {
4264  if (!_this) {
4266  return;
4267  }
4268  if (_this->vulkan_config.loader_loaded > 0) {
4269  if (--_this->vulkan_config.loader_loaded > 0) {
4270  return;
4271  }
4272  if (_this->Vulkan_UnloadLibrary) {
4274  }
4275  }
4276 }
void(* Vulkan_UnloadLibrary)(_THIS)
Definition: SDL_sysvideo.h:273

References _this, SDL_VideoDevice::loader_loaded, SDL_UninitializedVideo(), SDL_VideoDevice::vulkan_config, and SDL_VideoDevice::Vulkan_UnloadLibrary.

Referenced by SDL_DestroyWindow(), and SDL_RecreateWindow().

◆ ShouldMinimizeOnFocusLoss()

static SDL_bool ShouldMinimizeOnFocusLoss ( SDL_Window window)
static

Definition at line 2769 of file SDL_video.c.

2770 {
2771  if (!(window->flags & SDL_WINDOW_FULLSCREEN) || window->is_destroying) {
2772  return SDL_FALSE;
2773  }
2774 
2775 #ifdef __MACOSX__
2776  if (SDL_strcmp(_this->name, "cocoa") == 0) { /* don't do this for X11, etc */
2777  if (Cocoa_IsWindowInFullscreenSpace(window)) {
2778  return SDL_FALSE;
2779  }
2780  }
2781 #endif
2782 
2783 #ifdef __ANDROID__
2784  {
2787  return SDL_FALSE;
2788  }
2789  }
2790 #endif
2791 
2793 }
SDL_bool Android_JNI_ShouldMinimizeOnFocusLoss(void)
#define SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS
Minimize your SDL_Window if it loses key focus when in fullscreen mode. Defaults to false.
Definition: SDL_hints.h:377

References _this, Android_JNI_ShouldMinimizeOnFocusLoss(), SDL_VideoDevice::name, SDL_FALSE, SDL_GetHintBoolean, SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, SDL_strcmp, and SDL_WINDOW_FULLSCREEN.

Referenced by SDL_OnWindowFocusLost().

◆ ShouldUseTextureFramebuffer()

static SDL_bool ShouldUseTextureFramebuffer ( )
static

Definition at line 174 of file SDL_video.c.

175 {
176  const char *hint;
177 
178  /* If there's no native framebuffer support then there's no option */
180  return SDL_TRUE;
181  }
182 
183  /* If this is the dummy driver there is no texture support */
184  if (_this->is_dummy) {
185  return SDL_FALSE;
186  }
187 
188  /* If the user has specified a software renderer we can't use a
189  texture framebuffer, or renderer creation will go recursive.
190  */
192  if (hint && SDL_strcasecmp(hint, "software") == 0) {
193  return SDL_FALSE;
194  }
195 
196  /* See if the user or application wants a specific behavior */
198  if (hint) {
199  if (*hint == '0' || SDL_strcasecmp(hint, "false") == 0) {
200  return SDL_FALSE;
201  } else {
202  return SDL_TRUE;
203  }
204  }
205 
206  /* Each platform has different performance characteristics */
207 #if defined(__WIN32__)
208  /* GDI BitBlt() is way faster than Direct3D dynamic textures right now.
209  */
210  return SDL_FALSE;
211 
212 #elif defined(__MACOSX__)
213  /* Mac OS X uses OpenGL as the native fast path (for cocoa and X11) */
214  return SDL_TRUE;
215 
216 #elif defined(__LINUX__)
217  /* Properly configured OpenGL drivers are faster than MIT-SHM */
218 #if SDL_VIDEO_OPENGL
219  /* Ugh, find a way to cache this value! */
220  {
223  SDL_bool hasAcceleratedOpenGL = SDL_FALSE;
224 
225  window = SDL_CreateWindow("OpenGL test", -32, -32, 32, 32, SDL_WINDOW_OPENGL|SDL_WINDOW_HIDDEN);
226  if (window) {
228  if (context) {
229  const GLubyte *(APIENTRY * glGetStringFunc) (GLenum);
230  const char *vendor = NULL;
231 
232  glGetStringFunc = SDL_GL_GetProcAddress("glGetString");
233  if (glGetStringFunc) {
234  vendor = (const char *) glGetStringFunc(GL_VENDOR);
235  }
236  /* Add more vendors here at will... */
237  if (vendor &&
238  (SDL_strstr(vendor, "ATI Technologies") ||
239  SDL_strstr(vendor, "NVIDIA"))) {
240  hasAcceleratedOpenGL = SDL_TRUE;
241  }
243  }
245  }
246  return hasAcceleratedOpenGL;
247  }
248 #elif SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
249  /* Let's be optimistic about this! */
250  return SDL_TRUE;
251 #else
252  return SDL_FALSE;
253 #endif
254 
255 #else
256  /* Play it safe, assume that if there is a framebuffer driver that it's
257  optimized for the current platform.
258  */
259  return SDL_FALSE;
260 #endif
261 }
#define SDL_HINT_RENDER_DRIVER
A variable specifying which render driver to use.
Definition: SDL_hints.h:85
#define GL_VENDOR
Definition: SDL_opengl.h:713
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:3611
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:1446
void SDL_GL_DeleteContext(SDL_GLContext context)
Delete an OpenGL context.
Definition: SDL_video.c:3744

References _this, APIENTRY, context, SDL_VideoDevice::CreateWindowFramebuffer, GL_VENDOR, SDL_VideoDevice::is_dummy, NULL, SDL_CreateWindow(), SDL_DestroyWindow(), SDL_FALSE, SDL_GetHint, SDL_GL_CreateContext(), SDL_GL_DeleteContext(), SDL_GL_GetProcAddress(), SDL_HINT_FRAMEBUFFER_ACCELERATION, SDL_HINT_RENDER_DRIVER, SDL_strcasecmp, SDL_strstr, SDL_TRUE, SDL_WINDOW_HIDDEN, and SDL_WINDOW_OPENGL.

Referenced by SDL_VideoInit().

Variable Documentation

◆ _this

SDL_VideoDevice* _this = NULL
static

Definition at line 126 of file SDL_video.c.

Referenced by CanMinimizeWindow(), PrepareDragAndDropSupport(), SDL_AddVideoDisplay(), SDL_CreateWindow(), SDL_CreateWindowFramebuffer(), SDL_CreateWindowFrom(), SDL_DelVideoDisplay(), SDL_DestroyWindow(), SDL_DisableScreenSaver(), SDL_EnableScreenSaver(), SDL_GetClipboardText(), SDL_GetClosestDisplayMode(), SDL_GetCurrentDisplayMode(), SDL_GetCurrentVideoDriver(), SDL_GetDesktopDisplayMode(), SDL_GetDisplay(), SDL_GetDisplayBounds(), SDL_GetDisplayDPI(), SDL_GetDisplayDriverData(), SDL_GetDisplayForWindow(), SDL_GetDisplayMode(), SDL_GetDisplayName(), SDL_GetDisplayOrientation(), SDL_GetDisplayUsableBounds(), SDL_GetFocusWindow(), SDL_GetGrabbedWindow(), SDL_GetIndexOfDisplay(), SDL_GetNumDisplayModes(), SDL_GetNumDisplayModesForDisplay(), SDL_GetNumVideoDisplays(), SDL_GetVideoDevice(), SDL_GetWindowBordersSize(), SDL_GetWindowDisplayIndex(), SDL_GetWindowFromID(), SDL_GetWindowGammaRamp(), SDL_GetWindowGrab(), SDL_GetWindowWMInfo(), SDL_GL_CreateContext(), SDL_GL_DeleteContext(), SDL_GL_GetAttribute(), SDL_GL_GetCurrentContext(), SDL_GL_GetCurrentWindow(), SDL_GL_GetDrawableSize(), SDL_GL_GetProcAddress(), SDL_GL_GetSwapInterval(), SDL_GL_LoadLibrary(), SDL_GL_MakeCurrent(), SDL_GL_ResetAttributes(), SDL_GL_SetAttribute(), SDL_GL_SetSwapInterval(), SDL_GL_SwapWindow(), SDL_GL_UnloadLibrary(), SDL_HasClipboardText(), SDL_HasScreenKeyboardSupport(), SDL_HasWindows(), SDL_HideWindow(), SDL_IsScreenKeyboardShown(), SDL_IsScreenSaverEnabled(), SDL_MaximizeWindow(), SDL_Metal_CreateView(), SDL_Metal_DestroyView(), SDL_Metal_GetDrawableSize(), SDL_Metal_GetLayer(), SDL_MinimizeWindow(), SDL_OnApplicationDidBecomeActive(), SDL_OnApplicationWillResignActive(), SDL_OnWindowEnter(), SDL_OnWindowFocusGained(), SDL_OnWindowFocusLost(), SDL_PumpEvents(), SDL_RaiseWindow(), SDL_RecreateWindow(), SDL_RestoreWindow(), SDL_SetClipboardText(), SDL_SetDisplayModeForDisplay(), SDL_SetTextInputRect(), SDL_SetWindowBordered(), SDL_SetWindowGammaRamp(), SDL_SetWindowHitTest(), SDL_SetWindowIcon(), SDL_SetWindowInputFocus(), SDL_SetWindowMaximumSize(), SDL_SetWindowMinimumSize(), SDL_SetWindowModalFor(), SDL_SetWindowOpacity(), SDL_SetWindowPosition(), SDL_SetWindowResizable(), SDL_SetWindowSize(), SDL_SetWindowTitle(), SDL_ShowMessageBox(), SDL_ShowWindow(), SDL_StartTextInput(), SDL_StopTextInput(), SDL_ToggleDragAndDropSupport(), SDL_UpdateFullscreenMode(), SDL_UpdateWindowGrab(), SDL_UpdateWindowSurfaceRects(), SDL_VideoInit(), SDL_VideoQuit(), SDL_Vulkan_CreateSurface(), SDL_Vulkan_GetDrawableSize(), SDL_Vulkan_GetInstanceExtensions(), SDL_Vulkan_GetVkGetInstanceProcAddr(), SDL_Vulkan_LoadLibrary(), SDL_Vulkan_UnloadLibrary(), ShouldMinimizeOnFocusLoss(), ShouldUseTextureFramebuffer(), and videoInit().

◆ bootstrap

VideoBootStrap* bootstrap[]
static

Definition at line 60 of file SDL_video.c.

Referenced by SDL_GetNumVideoDrivers(), SDL_GetVideoDriver(), and SDL_VideoInit().