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)
#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.
const char * SDL_GetVideoDriver (int index)
 Get the name of a built in video driver.
int SDL_VideoInit (const char *driver_name)
 Initialize the video subsystem, optionally specifying a video driver.
const char * SDL_GetCurrentVideoDriver ()
 Returns the name of the currently initialized video driver.
SDL_VideoDeviceSDL_GetVideoDevice (void)
int SDL_AddBasicVideoDisplay (const SDL_DisplayMode *desktop_mode)
int SDL_AddVideoDisplay (const SDL_VideoDisplay *display)
int SDL_GetNumVideoDisplays (void)
 Returns the number of available video displays.
int SDL_GetIndexOfDisplay (SDL_VideoDisplay *display)
voidSDL_GetDisplayDriverData (int displayIndex)
const char * SDL_GetDisplayName (int displayIndex)
 Get the name of a display in UTF-8 encoding.
int SDL_GetDisplayBounds (int displayIndex, SDL_Rect *rect)
 Get the desktop area represented by a display, with the primary display located at 0,0.
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.
int SDL_GetDisplayDPI (int displayIndex, float *ddpi, float *hdpi, float *vdpi)
 Get the dots/pixels-per-inch for a display.
SDL_DisplayOrientation SDL_GetDisplayOrientation (int displayIndex)
 Get the orientation of a display.
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.
int SDL_GetDisplayMode (int displayIndex, int index, SDL_DisplayMode *mode)
 Fill in information about a specific display mode.
int SDL_GetDesktopDisplayMode (int displayIndex, SDL_DisplayMode *mode)
 Fill in information about the desktop display mode.
int SDL_GetCurrentDisplayMode (int displayIndex, SDL_DisplayMode *mode)
 Fill in information about the current display mode.
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.
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.
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.
int SDL_GetWindowDisplayMode (SDL_Window *window, SDL_DisplayMode *mode)
 Fill in information about the display mode used when a fullscreen window is visible.
Uint32 SDL_GetWindowPixelFormat (SDL_Window *window)
 Get the pixel format associated with the window.
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.
SDL_WindowSDL_CreateWindowFrom (const void *data)
 Create an SDL window from an existing native window.
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.
SDL_WindowSDL_GetWindowFromID (Uint32 id)
 Get a window from a stored ID, or NULL if it doesn't exist.
Uint32 SDL_GetWindowFlags (SDL_Window *window)
 Get the window flags.
void SDL_SetWindowTitle (SDL_Window *window, const char *title)
 Set the title of a window, in UTF-8 format.
const char * SDL_GetWindowTitle (SDL_Window *window)
 Get the title of a window, in UTF-8 format.
void SDL_SetWindowIcon (SDL_Window *window, SDL_Surface *icon)
 Set the icon for a window.
voidSDL_SetWindowData (SDL_Window *window, const char *name, void *userdata)
 Associate an arbitrary named pointer with a window.
voidSDL_GetWindowData (SDL_Window *window, const char *name)
 Retrieve the data pointer associated with a window.
void SDL_SetWindowPosition (SDL_Window *window, int x, int y)
 Set the position of a window.
void SDL_GetWindowPosition (SDL_Window *window, int *x, int *y)
 Get the position of a window.
void SDL_SetWindowBordered (SDL_Window *window, SDL_bool bordered)
 Set the border state of a window.
void SDL_SetWindowResizable (SDL_Window *window, SDL_bool resizable)
 Set the user-resizable state of a window.
void SDL_SetWindowSize (SDL_Window *window, int w, int h)
 Set the size of a window's client area.
void SDL_GetWindowSize (SDL_Window *window, int *w, int *h)
 Get the size of a window's client area.
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.
void SDL_SetWindowMinimumSize (SDL_Window *window, int min_w, int min_h)
 Set the minimum size of a window's client area.
void SDL_GetWindowMinimumSize (SDL_Window *window, int *min_w, int *min_h)
 Get the minimum size of a window's client area.
void SDL_SetWindowMaximumSize (SDL_Window *window, int max_w, int max_h)
 Set the maximum size of a window's client area.
void SDL_GetWindowMaximumSize (SDL_Window *window, int *max_w, int *max_h)
 Get the maximum size of a window's client area.
void SDL_ShowWindow (SDL_Window *window)
 Show a window.
void SDL_HideWindow (SDL_Window *window)
 Hide a window.
void SDL_RaiseWindow (SDL_Window *window)
 Raise a window above other windows and set the input focus.
void SDL_MaximizeWindow (SDL_Window *window)
 Make a window as large as possible.
void SDL_MinimizeWindow (SDL_Window *window)
 Minimize a window to an iconic representation.
void SDL_RestoreWindow (SDL_Window *window)
 Restore the size and position of a minimized or maximized window.
int SDL_SetWindowFullscreen (SDL_Window *window, Uint32 flags)
 Set a window's fullscreen state.
static SDL_SurfaceSDL_CreateWindowFramebuffer (SDL_Window *window)
SDL_SurfaceSDL_GetWindowSurface (SDL_Window *window)
 Get the SDL surface associated with the window.
int SDL_UpdateWindowSurface (SDL_Window *window)
 Copy the window surface to the screen.
int SDL_UpdateWindowSurfaceRects (SDL_Window *window, const SDL_Rect *rects, int numrects)
 Copy a number of rectangles on the window surface to the screen.
int SDL_SetWindowBrightness (SDL_Window *window, float brightness)
 Set the brightness (gamma correction) for a window.
float SDL_GetWindowBrightness (SDL_Window *window)
 Get the brightness (gamma correction) for a window.
int SDL_SetWindowOpacity (SDL_Window *window, float opacity)
 Set the opacity for a window.
int SDL_GetWindowOpacity (SDL_Window *window, float *out_opacity)
 Get the opacity of a window.
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)
int SDL_SetWindowInputFocus (SDL_Window *window)
 Explicitly sets input focus to the window.
int SDL_SetWindowGammaRamp (SDL_Window *window, const Uint16 *red, const Uint16 *green, const Uint16 *blue)
 Set the gamma ramp for a window.
int SDL_GetWindowGammaRamp (SDL_Window *window, Uint16 *red, Uint16 *green, Uint16 *blue)
 Get the gamma ramp for a window.
void SDL_UpdateWindowGrab (SDL_Window *window)
void SDL_SetWindowGrab (SDL_Window *window, SDL_bool grabbed)
 Set a window's input grab mode.
SDL_bool SDL_GetWindowGrab (SDL_Window *window)
 Get a window's input grab mode.
SDL_WindowSDL_GetGrabbedWindow (void)
 Get the window that currently has an input grab enabled.
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.
SDL_bool SDL_IsScreenSaverEnabled ()
 Returns whether the screensaver is currently enabled (default off).
void SDL_EnableScreenSaver ()
 Allow the screen to be blanked by a screensaver.
void SDL_DisableScreenSaver ()
 Prevent the screen from being blanked by a screensaver.
void SDL_VideoQuit (void)
 Shuts down the video subsystem.
int SDL_GL_LoadLibrary (const char *path)
 Dynamically load an OpenGL library.
voidSDL_GL_GetProcAddress (const char *proc)
 Get the address of an OpenGL function.
void SDL_GL_UnloadLibrary (void)
 Unload the OpenGL library previously loaded by SDL_GL_LoadLibrary().
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.
void SDL_GL_DeduceMaxSupportedESProfile (int *major, int *minor)
void SDL_GL_ResetAttributes ()
 Reset all previously set OpenGL context attributes to their default values.
int SDL_GL_SetAttribute (SDL_GLattr attr, int value)
 Set an OpenGL window attribute before window creation.
int SDL_GL_GetAttribute (SDL_GLattr attr, int *value)
 Get the actual value for an attribute from the current context.
SDL_GLContext SDL_GL_CreateContext (SDL_Window *window)
 Create an OpenGL context for use with an OpenGL window, and make it current.
int SDL_GL_MakeCurrent (SDL_Window *window, SDL_GLContext ctx)
 Set up an OpenGL context for rendering into an OpenGL window.
SDL_WindowSDL_GL_GetCurrentWindow (void)
 Get the currently active OpenGL window.
SDL_GLContext SDL_GL_GetCurrentContext (void)
 Get the currently active OpenGL context.
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).
int SDL_GL_SetSwapInterval (int interval)
 Set the swap interval for the current OpenGL context.
int SDL_GL_GetSwapInterval (void)
 Get the swap interval for the current OpenGL context.
void SDL_GL_SwapWindow (SDL_Window *window)
 Swap the OpenGL buffers for a window, if double-buffering is supported.
void SDL_GL_DeleteContext (SDL_GLContext context)
 Delete an OpenGL context.
SDL_bool SDL_GetWindowWMInfo (SDL_Window *window, struct SDL_SysWMinfo *info)
 This function allows access to driver-dependent window information.
void SDL_StartTextInput (void)
 Start accepting Unicode text input events. This function will show the on-screen keyboard if supported.
SDL_bool SDL_IsTextInputActive (void)
 Return whether or not Unicode text input events are enabled.
void SDL_StopTextInput (void)
 Stop receiving any text input events. This function will hide the on-screen keyboard if supported.
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.
SDL_bool SDL_HasScreenKeyboardSupport (void)
 Returns whether the platform has some screen keyboard support.
SDL_bool SDL_IsScreenKeyboardShown (SDL_Window *window)
 Returns whether the screen keyboard is shown for given window.
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.
int SDL_ShowSimpleMessageBox (Uint32 flags, const char *title, const char *message, SDL_Window *window)
 Create a simple modal message box.
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.
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.
voidSDL_Vulkan_GetVkGetInstanceProcAddr (void)
 Get the address of the vkGetInstanceProcAddr function.
void SDL_Vulkan_UnloadLibrary (void)
 Unload the Vulkan loader library previously loaded by SDL_Vulkan_LoadLibrary().
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.
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).

Variables

static VideoBootStrapbootstrap []
static SDL_VideoDevice_this = NULL

Macro Definition Documentation

#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; \
}

Definition at line 134 of file SDL_video.c.

Referenced by SDL_GetClosestDisplayMode(), SDL_GetCurrentDisplayMode(), SDL_GetDesktopDisplayMode(), SDL_GetDisplay(), SDL_GetDisplayBounds(), SDL_GetDisplayDPI(), SDL_GetDisplayDriverData(), SDL_GetDisplayMode(), SDL_GetDisplayName(), SDL_GetDisplayOrientation(), SDL_GetDisplayUsableBounds(), and SDL_GetNumDisplayModes().

#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; \
}

Definition at line 123 of file SDL_video.c.

Referenced by SDL_DestroyWindow(), SDL_GetWindowBordersSize(), SDL_GetWindowBrightness(), SDL_GetWindowData(), SDL_GetWindowDisplayIndex(), SDL_GetWindowDisplayMode(), SDL_GetWindowFlags(), SDL_GetWindowGammaRamp(), SDL_GetWindowGrab(), SDL_GetWindowID(), SDL_GetWindowMaximumSize(), SDL_GetWindowMinimumSize(), SDL_GetWindowOpacity(), SDL_GetWindowPixelFormat(), SDL_GetWindowPosition(), SDL_GetWindowSize(), SDL_GetWindowSurface(), SDL_GetWindowTitle(), SDL_GetWindowWMInfo(), SDL_GL_CreateContext(), SDL_GL_GetDrawableSize(), SDL_GL_MakeCurrent(), SDL_GL_SwapWindow(), SDL_HideWindow(), SDL_MaximizeWindow(), SDL_MinimizeWindow(), SDL_RaiseWindow(), SDL_RestoreWindow(), SDL_SetWindowBordered(), SDL_SetWindowBrightness(), SDL_SetWindowData(), SDL_SetWindowDisplayMode(), SDL_SetWindowFullscreen(), SDL_SetWindowGammaRamp(), SDL_SetWindowGrab(), SDL_SetWindowHitTest(), SDL_SetWindowIcon(), SDL_SetWindowInputFocus(), SDL_SetWindowMaximumSize(), SDL_SetWindowMinimumSize(), SDL_SetWindowModalFor(), SDL_SetWindowOpacity(), SDL_SetWindowPosition(), SDL_SetWindowResizable(), SDL_SetWindowSize(), SDL_SetWindowTitle(), SDL_ShowWindow(), SDL_UpdateFullscreenMode(), SDL_UpdateWindowSurface(), SDL_UpdateWindowSurfaceRects(), SDL_Vulkan_CreateSurface(), SDL_Vulkan_GetDrawableSize(), and SDL_Vulkan_GetInstanceExtensions().

#define FULLSCREEN_MASK   (SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_FULLSCREEN)

Definition at line 147 of file SDL_video.c.

Referenced by SDL_SetWindowFullscreen(), and SDL_UpdateFullscreenMode().

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

Definition at line 4049 of file SDL_video.c.

Referenced by SDL_Vulkan_CreateSurface(), and SDL_Vulkan_GetInstanceExtensions().

#define SDL_WINDOWTEXTUREDATA   "_SDL_WindowTextureData"

Function Documentation

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

Definition at line 419 of file SDL_video.c.

References SDL_DisplayMode::format, SDL_DisplayMode::h, SDL_DisplayMode::refresh_rate, SDL_BITSPERPIXEL, SDL_PIXELLAYOUT, and SDL_DisplayMode::w.

Referenced by SDL_AddDisplayMode(), and SDL_GetNumDisplayModesForDisplay().

{
const SDL_DisplayMode *a = (const SDL_DisplayMode *) A;
const SDL_DisplayMode *b = (const SDL_DisplayMode *) B;
if (a == b) {
return 0;
} else if (a->w != b->w) {
return b->w - a->w;
} else if (a->h != b->h) {
return b->h - a->h;
} else if (SDL_PIXELLAYOUT(a->format) != SDL_PIXELLAYOUT(b->format)) {
} else if (a->refresh_rate != b->refresh_rate) {
return b->refresh_rate - a->refresh_rate;
}
return 0;
}
static SDL_INLINE SDL_bool IsAcceptingDragAndDrop ( void  )
static
static SDL_INLINE SDL_bool isAtLeastGL3 ( const char *  verstr)
static

Definition at line 2922 of file SDL_video.c.

References SDL_atoi.

Referenced by SDL_GL_ExtensionSupported(), and SDL_GL_GetAttribute().

{
return (verstr && (SDL_atoi(verstr) >= 3));
}
static SDL_INLINE void PrepareDragAndDropSupport ( SDL_Window window)
static
int SDL_AddBasicVideoDisplay ( const SDL_DisplayMode desktop_mode)

Definition at line 592 of file SDL_video.c.

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

{
SDL_zero(display);
if (desktop_mode) {
display.desktop_mode = *desktop_mode;
}
display.current_mode = display.desktop_mode;
return SDL_AddVideoDisplay(&display);
}
SDL_bool SDL_AddDisplayMode ( SDL_VideoDisplay display,
const SDL_DisplayMode mode 
)

Definition at line 754 of file SDL_video.c.

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.

{
int i, nmodes;
/* Make sure we don't already have the mode in the list */
modes = display->display_modes;
nmodes = display->num_display_modes;
for (i = 0; i < nmodes; ++i) {
if (cmpmodes(mode, &modes[i]) == 0) {
return SDL_FALSE;
}
}
/* Go ahead and add the new mode */
if (nmodes == display->max_display_modes) {
modes =
SDL_realloc(modes,
(display->max_display_modes + 32) * sizeof(*modes));
if (!modes) {
return SDL_FALSE;
}
display->display_modes = modes;
display->max_display_modes += 32;
}
modes[nmodes] = *mode;
display->num_display_modes++;
/* Re-sort video modes */
return SDL_TRUE;
}
int SDL_AddVideoDisplay ( const SDL_VideoDisplay display)

Definition at line 606 of file SDL_video.c.

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

Referenced by SDL_AddBasicVideoDisplay(), and videoInit().

{
SDL_VideoDisplay *displays;
int index = -1;
displays =
(_this->num_displays + 1) * sizeof(*displays));
if (displays) {
index = _this->num_displays++;
displays[index] = *display;
displays[index].device = _this;
_this->displays = displays;
if (display->name) {
displays[index].name = SDL_strdup(display->name);
} else {
char name[32];
SDL_itoa(index, name, 10);
displays[index].name = SDL_strdup(name);
}
} else {
}
return index;
}
float SDL_ComputeDiagonalDPI ( int  hpix,
int  vpix,
float  hinches,
float  vinches 
)

Definition at line 3990 of file SDL_video.c.

References SDL_sqrt.

{
float den2 = hinches * hinches + vinches * vinches;
if (den2 <= 0.0f) {
return 0.0f;
}
return (float)(SDL_sqrt((double)hpix * (double)hpix + (double)vpix * (double)vpix) /
SDL_sqrt((double)den2));
}
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.
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.

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 1408 of file SDL_video.c.

References SDL_Window::brightness, CREATE_FLAGS, SDL_VideoDevice::CreateSDLWindow, SDL_Window::flags, FULLSCREEN_VISIBLE, SDL_VideoDevice::GL_CreateContext, SDL_Rect::h, SDL_Window::h, SDL_Window::id, SDL_Window::is_destroying, SDL_VideoDevice::is_dummy, SDL_Window::last_fullscreen_flags, SDL_Window::magic, SDL_VideoDevice::name, SDL_Window::next, SDL_VideoDevice::next_object_id, NULL, SDL_Window::opacity, 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_OutOfMemory, SDL_SetError, SDL_SetWindowTitle, SDL_UpdateFullscreenMode(), SDL_VideoInit, SDL_Vulkan_LoadLibrary, SDL_WINDOW_ALLOW_HIGHDPI, SDL_WINDOW_FULLSCREEN, SDL_WINDOW_HIDDEN, 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_Window::w, SDL_VideoDevice::window_magic, SDL_Window::windowed, SDL_VideoDevice::windows, SDL_Rect::x, SDL_Window::x, SDL_Rect::y, and SDL_Window::y.

{
if (!_this) {
/* Initialize the video system if needed */
if (SDL_VideoInit(NULL) < 0) {
return NULL;
}
}
if ((((flags & SDL_WINDOW_UTILITY) != 0) + ((flags & SDL_WINDOW_TOOLTIP) != 0) + ((flags & SDL_WINDOW_POPUP_MENU) != 0)) > 1) {
SDL_SetError("Conflicting window flags specified");
return NULL;
}
/* Some platforms can't create zero-sized windows */
if (w < 1) {
w = 1;
}
if (h < 1) {
h = 1;
}
/* Some platforms blow up if the windows are too large. Raise it later? */
if ((w > 16384) || (h > 16384)) {
SDL_SetError("Window is too large.");
return NULL;
}
/* Some platforms have OpenGL enabled by default */
#if (SDL_VIDEO_OPENGL && __MACOSX__) || __IPHONEOS__ || __ANDROID__ || __NACL__
}
#endif
SDL_SetError("OpenGL support is either not configured in SDL "
"or not available in current SDL video driver "
"(%s) or platform", _this->name);
return NULL;
}
return NULL;
}
}
if (flags & SDL_WINDOW_VULKAN) {
SDL_SetError("Vulkan support is either not configured in SDL "
"or not available in current SDL video driver "
"(%s) or platform", _this->name);
return NULL;
}
if (flags & SDL_WINDOW_OPENGL) {
SDL_SetError("Vulkan and OpenGL not supported on same window");
return NULL;
}
return NULL;
}
}
/* Unless the user has specified the high-DPI disabling hint, respect the
* SDL_WINDOW_ALLOW_HIGHDPI flag.
*/
flags &= ~SDL_WINDOW_ALLOW_HIGHDPI;
}
}
window = (SDL_Window *)SDL_calloc(1, sizeof(*window));
if (!window) {
return NULL;
}
window->magic = &_this->window_magic;
window->id = _this->next_object_id++;
window->x = x;
window->y = y;
window->w = w;
window->h = h;
int displayIndex;
SDL_Rect bounds;
displayIndex = SDL_GetIndexOfDisplay(display);
SDL_GetDisplayBounds(displayIndex, &bounds);
window->x = bounds.x + (bounds.w - w) / 2;
}
window->y = bounds.y + (bounds.h - h) / 2;
}
}
window->windowed.x = window->x;
window->windowed.y = window->y;
window->windowed.w = window->w;
window->windowed.h = window->h;
int displayIndex;
SDL_Rect bounds;
displayIndex = SDL_GetIndexOfDisplay(display);
SDL_GetDisplayBounds(displayIndex, &bounds);
window->x = bounds.x;
window->y = bounds.y;
window->w = bounds.w;
window->h = bounds.h;
}
window->last_fullscreen_flags = window->flags;
window->opacity = 1.0f;
window->brightness = 1.0f;
window->next = _this->windows;
if (_this->windows) {
}
if (_this->CreateSDLWindow && _this->CreateSDLWindow(_this, window) < 0) {
return NULL;
}
/* Clear minimized if not on windows, only windows handles it at create rather than FinishWindowCreation,
* but it's important or window focus will get broken on windows!
*/
#if !defined(__WIN32__)
if (window->flags & SDL_WINDOW_MINIMIZED) {
}
#endif
#if __WINRT__ && (NTDDI_VERSION < NTDDI_WIN10)
/* HACK: WinRT 8.x apps can't choose whether or not they are fullscreen
or not. The user can choose this, via OS-provided UI, but this can't
be set programmatically.
Just look at what SDL's WinRT video backend code detected with regards
to fullscreen (being active, or not), and figure out a return/error code
from that.
*/
flags = window->flags;
#endif
if (title) {
SDL_SetWindowTitle(window, title);
}
/* If the window was created fullscreen, make sure the mode code matches */
return window;
}
static SDL_Surface* SDL_CreateWindowFramebuffer ( SDL_Window window)
static

Definition at line 2269 of file SDL_video.c.

References SDL_VideoDevice::CreateWindowFramebuffer, SDL_Window::h, NULL, SDL_CreateRGBSurfaceFrom, SDL_PixelFormatEnumToMasks, SDL_VideoDevice::UpdateWindowFramebuffer, and SDL_Window::w.

Referenced by SDL_GetWindowSurface().

{
void *pixels;
int pitch;
int bpp;
Uint32 Rmask, Gmask, Bmask, Amask;
return NULL;
}
if (_this->CreateWindowFramebuffer(_this, window, &format, &pixels, &pitch) < 0) {
return NULL;
}
if (!SDL_PixelFormatEnumToMasks(format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
return NULL;
}
return SDL_CreateRGBSurfaceFrom(pixels, window->w, window->h, bpp, pitch, Rmask, Gmask, Bmask, Amask);
}
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 1576 of file SDL_video.c.

References SDL_Window::brightness, SDL_VideoDevice::CreateSDLWindowFrom, SDL_Window::flags, SDL_Window::id, SDL_Window::is_destroying, SDL_Window::last_fullscreen_flags, SDL_Window::magic, SDL_Window::next, SDL_VideoDevice::next_object_id, NULL, SDL_Window::opacity, 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.

{
if (!_this) {
return NULL;
}
return NULL;
}
window = (SDL_Window *)SDL_calloc(1, sizeof(*window));
if (!window) {
return NULL;
}
window->magic = &_this->window_magic;
window->id = _this->next_object_id++;
window->last_fullscreen_flags = window->flags;
window->opacity = 1.0f;
window->brightness = 1.0f;
window->next = _this->windows;
if (_this->windows) {
}
if (_this->CreateSDLWindowFrom(_this, window, data) < 0) {
return NULL;
}
return window;
}
static int SDL_CreateWindowTexture ( SDL_VideoDevice unused,
SDL_Window window,
Uint32 format,
void **  pixels,
int *  pitch 
)
static

Definition at line 259 of file SDL_video.c.

References SDL_WindowTextureData::bytes_per_pixel, SDL_Window::h, i, SDL_RendererInfo::name, NULL, SDL_RendererInfo::num_texture_formats, SDL_WindowTextureData::pitch, SDL_WindowTextureData::pixels, renderer, SDL_WindowTextureData::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, SDL_WindowTextureData::texture, SDL_RendererInfo::texture_formats, and SDL_Window::w.

Referenced by SDL_VideoInit().

{
if (!data) {
int i;
/* Check to see if there's a specific driver requested */
if (hint && *hint != '0' && *hint != '1' &&
SDL_strcasecmp(hint, "true") != 0 &&
SDL_strcasecmp(hint, "false") != 0 &&
SDL_strcasecmp(hint, "software") != 0) {
for (i = 0; i < SDL_GetNumRenderDrivers(); ++i) {
if (SDL_strcasecmp(info.name, hint) == 0) {
renderer = SDL_CreateRenderer(window, i, 0);
break;
}
}
}
if (!renderer) {
for (i = 0; i < SDL_GetNumRenderDrivers(); ++i) {
if (SDL_strcmp(info.name, "software") != 0) {
renderer = SDL_CreateRenderer(window, i, 0);
if (renderer) {
break;
}
}
}
}
if (!renderer) {
return SDL_SetError("No hardware accelerated renderers available");
}
/* Create the data after we successfully create the renderer (bug #1116) */
data = (SDL_WindowTextureData *)SDL_calloc(1, sizeof(*data));
if (!data) {
return SDL_OutOfMemory();
}
data->renderer = renderer;
}
/* Free any old texture and pixel data */
if (data->texture) {
data->texture = NULL;
}
SDL_free(data->pixels);
data->pixels = NULL;
{
if (SDL_GetRendererInfo(data->renderer, &info) < 0) {
return -1;
}
/* Find the first format without an alpha channel */
*format = info.texture_formats[0];
for (i = 0; i < info.num_texture_formats; ++i) {
break;
}
}
}
window->w, window->h);
if (!data->texture) {
return -1;
}
/* Create framebuffer data */
data->pitch = (((window->w * data->bytes_per_pixel) + 3) & ~3);
{
/* Make static analysis happy about potential malloc(0) calls. */
const size_t allocsize = window->h * data->pitch;
data->pixels = SDL_malloc((allocsize > 0) ? allocsize : 1);
if (!data->pixels) {
return SDL_OutOfMemory();
}
}
*pixels = data->pixels;
*pitch = data->pitch;
/* Make sure we're not double-scaling the viewport */
return 0;
}
void SDL_DestroyWindow ( SDL_Window window)

Destroy a window.

Definition at line 2687 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, SDL_VideoDevice::current_glwin, SDL_Window::data, SDL_VideoDevice::DestroyWindow, SDL_VideoDevice::DestroyWindowFramebuffer, SDL_Surface::flags, SDL_Window::flags, SDL_VideoDisplay::fullscreen_window, SDL_Window::gamma, SDL_Window::icon, SDL_Window::is_destroying, SDL_Window::magic, SDL_WindowUserData::name, SDL_WindowUserData::next, SDL_Window::next, NULL, SDL_Window::prev, SDL_DONTFREE, 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, SDL_Window::surface, SDL_Window::title, and SDL_VideoDevice::windows.

{
SDL_VideoDisplay *display;
/* Restore video mode, etc. */
SDL_HideWindow(window);
/* Make sure this window no longer has focus */
if (SDL_GetKeyboardFocus() == window) {
}
if (SDL_GetMouseFocus() == window) {
}
/* make no context current if this is the current context window. */
if (window->flags & SDL_WINDOW_OPENGL) {
if (_this->current_glwin == window) {
}
}
if (window->surface) {
window->surface->flags &= ~SDL_DONTFREE;
}
}
}
if (window->flags & SDL_WINDOW_OPENGL) {
}
if (window->flags & SDL_WINDOW_VULKAN) {
}
display = SDL_GetDisplayForWindow(window);
if (display->fullscreen_window == window) {
display->fullscreen_window = NULL;
}
/* Now invalidate magic */
window->magic = NULL;
/* Free memory associated with the window */
SDL_free(window->title);
SDL_free(window->gamma);
while (window->data) {
window->data = data->next;
SDL_free(data->name);
SDL_free(data);
}
/* Unlink the window from the list */
if (window->next) {
window->next->prev = window->prev;
}
if (window->prev) {
window->prev->next = window->next;
} else {
_this->windows = window->next;
}
SDL_free(window);
}
static void SDL_DestroyWindowTexture ( SDL_VideoDevice unused,
SDL_Window window 
)
static
void SDL_DisableScreenSaver ( void  )

Prevent the screen from being blanked by a screensaver.

See Also
SDL_IsScreenSaverEnabled()
SDL_EnableScreenSaver()

Definition at line 2788 of file SDL_video.c.

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

void SDL_EnableScreenSaver ( void  )

Allow the screen to be blanked by a screensaver.

See Also
SDL_IsScreenSaverEnabled()
SDL_DisableScreenSaver()

Definition at line 2773 of file SDL_video.c.

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

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 962 of file SDL_video.c.

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

{
SDL_VideoDisplay *display;
CHECK_DISPLAY_INDEX(displayIndex, NULL);
display = &_this->displays[displayIndex];
return SDL_GetClosestDisplayModeForDisplay(display, mode, closest);
}
static SDL_DisplayMode* SDL_GetClosestDisplayModeForDisplay ( SDL_VideoDisplay display,
const SDL_DisplayMode mode,
SDL_DisplayMode closest 
)
static

Definition at line 855 of file SDL_video.c.

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().

{
Uint32 target_format;
int target_refresh_rate;
int i;
SDL_DisplayMode *current, *match;
if (!mode || !closest) {
SDL_SetError("Missing desired mode or closest mode parameter");
return NULL;
}
/* Default to the desktop format */
if (mode->format) {
target_format = mode->format;
} else {
target_format = display->desktop_mode.format;
}
/* Default to the desktop refresh rate */
if (mode->refresh_rate) {
target_refresh_rate = mode->refresh_rate;
} else {
target_refresh_rate = display->desktop_mode.refresh_rate;
}
match = NULL;
for (i = 0; i < SDL_GetNumDisplayModesForDisplay(display); ++i) {
current = &display->display_modes[i];
if (current->w && (current->w < mode->w)) {
/* Out of sorted modes large enough here */
break;
}
if (current->h && (current->h < mode->h)) {
if (current->w && (current->w == mode->w)) {
/* Out of sorted modes large enough here */
break;
}
/* Wider, but not tall enough, due to a different
aspect ratio. This mode must be skipped, but closer
modes may still follow. */
continue;
}
if (!match || current->w < match->w || current->h < match->h) {
match = current;
continue;
}
if (current->format != match->format) {
/* Sorted highest depth to lowest */
if (current->format == target_format ||
(SDL_BITSPERPIXEL(current->format) >=
SDL_BITSPERPIXEL(target_format)
&& SDL_PIXELTYPE(current->format) ==
SDL_PIXELTYPE(target_format))) {
match = current;
}
continue;
}
if (current->refresh_rate != match->refresh_rate) {
/* Sorted highest refresh to lowest */
if (current->refresh_rate >= target_refresh_rate) {
match = current;
}
}
}
if (match) {
if (match->format) {
closest->format = match->format;
} else {
closest->format = mode->format;
}
if (match->w && match->h) {
closest->w = match->w;
closest->h = match->h;
} else {
closest->w = mode->w;
closest->h = mode->h;
}
if (match->refresh_rate) {
closest->refresh_rate = match->refresh_rate;
} else {
closest->refresh_rate = mode->refresh_rate;
}
closest->driverdata = match->driverdata;
/*
* Pick some reasonable defaults if the app and driver don't
* care
*/
if (!closest->format) {
}
if (!closest->w) {
closest->w = 640;
}
if (!closest->h) {
closest->h = 480;
}
return closest;
}
return NULL;
}
int SDL_GetCurrentDisplayMode ( int  displayIndex,
SDL_DisplayMode mode 
)

Fill in information about the current display mode.

Definition at line 841 of file SDL_video.c.

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

{
SDL_VideoDisplay *display;
CHECK_DISPLAY_INDEX(displayIndex, -1);
display = &_this->displays[displayIndex];
if (mode) {
*mode = display->current_mode;
}
return 0;
}
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 576 of file SDL_video.c.

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

{
if (!_this) {
return NULL;
}
return _this->name;
}
int SDL_GetDesktopDisplayMode ( int  displayIndex,
SDL_DisplayMode mode 
)

Fill in information about the desktop display mode.

Definition at line 827 of file SDL_video.c.

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

{
SDL_VideoDisplay *display;
CHECK_DISPLAY_INDEX(displayIndex, -1);
display = &_this->displays[displayIndex];
if (mode) {
*mode = display->desktop_mode;
}
return 0;
}
SDL_VideoDisplay* SDL_GetDisplay ( int  displayIndex)

Definition at line 1024 of file SDL_video.c.

References CHECK_DISPLAY_INDEX, SDL_VideoDevice::displays, and NULL.

{
CHECK_DISPLAY_INDEX(displayIndex, NULL);
return &_this->displays[displayIndex];
}
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 676 of file SDL_video.c.

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

{
CHECK_DISPLAY_INDEX(displayIndex, -1);
if (rect) {
SDL_VideoDisplay *display = &_this->displays[displayIndex];
if (_this->GetDisplayBounds(_this, display, rect) == 0) {
return 0;
}
}
/* Assume that the displays are left to right */
if (displayIndex == 0) {
rect->x = 0;
rect->y = 0;
} else {
SDL_GetDisplayBounds(displayIndex-1, rect);
rect->x += rect->w;
}
rect->w = display->current_mode.w;
rect->h = display->current_mode.h;
}
return 0; /* !!! FIXME: should this be an error if (rect==NULL) ? */
}
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 723 of file SDL_video.c.

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

{
SDL_VideoDisplay *display;
CHECK_DISPLAY_INDEX(displayIndex, -1);
display = &_this->displays[displayIndex];
if (_this->GetDisplayDPI(_this, display, ddpi, hdpi, vdpi) == 0) {
return 0;
}
} else {
return SDL_Unsupported();
}
return -1;
}
void* SDL_GetDisplayDriverData ( int  displayIndex)

Definition at line 660 of file SDL_video.c.

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

{
CHECK_DISPLAY_INDEX(displayIndex, NULL);
return _this->displays[displayIndex].driverdata;
}
SDL_VideoDisplay* SDL_GetDisplayForWindow ( SDL_Window window)

Definition at line 1092 of file SDL_video.c.

References SDL_VideoDevice::displays, NULL, and SDL_GetWindowDisplayIndex.

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

{
int displayIndex = SDL_GetWindowDisplayIndex(window);
if (displayIndex >= 0) {
return &_this->displays[displayIndex];
} else {
return NULL;
}
}
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 809 of file SDL_video.c.

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

{
SDL_VideoDisplay *display;
CHECK_DISPLAY_INDEX(displayIndex, -1);
display = &_this->displays[displayIndex];
return SDL_SetError("index must be in the range of 0 - %d",
}
if (mode) {
*mode = display->display_modes[index];
}
return 0;
}
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 668 of file SDL_video.c.

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

{
CHECK_DISPLAY_INDEX(displayIndex, NULL);
return _this->displays[displayIndex].name;
}
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 743 of file SDL_video.c.

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

{
SDL_VideoDisplay *display;
display = &_this->displays[displayIndex];
return display->orientation;
}
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 703 of file SDL_video.c.

References CHECK_DISPLAY_INDEX, SDL_VideoDevice::displays, SDL_VideoDevice::GetDisplayUsableBounds, and SDL_GetDisplayBounds.

{
CHECK_DISPLAY_INDEX(displayIndex, -1);
if (rect) {
SDL_VideoDisplay *display = &_this->displays[displayIndex];
if (_this->GetDisplayUsableBounds(_this, display, rect) == 0) {
return 0;
}
}
/* Oh well, just give the entire display bounds. */
return SDL_GetDisplayBounds(displayIndex, rect);
}
return 0; /* !!! FIXME: should this be an error if (rect==NULL) ? */
}
SDL_Window* SDL_GetFocusWindow ( void  )

Definition at line 2671 of file SDL_video.c.

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

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

{
if (!_this) {
return NULL;
}
for (window = _this->windows; window; window = window->next) {
if (window->flags & SDL_WINDOW_INPUT_FOCUS) {
return window;
}
}
return NULL;
}
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 2559 of file SDL_video.c.

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

int SDL_GetIndexOfDisplay ( SDL_VideoDisplay display)

Definition at line 645 of file SDL_video.c.

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

Referenced by SDL_CreateWindow(), and SDL_SendDisplayEvent().

{
int displayIndex;
for (displayIndex = 0; displayIndex < _this->num_displays; ++displayIndex) {
if (display == &_this->displays[displayIndex]) {
return displayIndex;
}
}
/* Couldn't find the display, just use index 0 */
return 0;
}
int SDL_GetNumDisplayModes ( int  displayIndex)

Returns the number of available display modes.

See Also
SDL_GetDisplayMode()

Definition at line 801 of file SDL_video.c.

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

{
CHECK_DISPLAY_INDEX(displayIndex, -1);
}
static int SDL_GetNumDisplayModesForDisplay ( SDL_VideoDisplay display)
static
int SDL_GetNumVideoDisplays ( void  )

Returns the number of available video displays.

See Also
SDL_GetDisplayBounds()

Definition at line 635 of file SDL_video.c.

References SDL_VideoDevice::num_displays, and SDL_UninitializedVideo().

{
if (!_this) {
return 0;
}
}
int SDL_GetNumVideoDrivers ( void  )

Get the number of video drivers compiled into SDL.

See Also
SDL_GetVideoDriver()

Definition at line 446 of file SDL_video.c.

References SDL_arraysize.

{
return SDL_arraysize(bootstrap) - 1;
}
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 452 of file SDL_video.c.

References VideoBootStrap::name, NULL, and SDL_GetNumVideoDrivers.

{
if (index >= 0 && index < SDL_GetNumVideoDrivers()) {
return bootstrap[index]->name;
}
return NULL;
}
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 2043 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, SDL_VideoDevice::GetWindowBordersSize, and SDL_Unsupported.

{
int dummy = 0;
if (!top) { top = &dummy; }
if (!left) { left = &dummy; }
if (!right) { right = &dummy; }
if (!bottom) { bottom = &dummy; }
/* Always initialize, so applications don't have to care */
*top = *left = *bottom = *right = 0;
CHECK_WINDOW_MAGIC(window, -1);
return SDL_Unsupported();
}
}
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 2355 of file SDL_video.c.

References SDL_Window::brightness, and CHECK_WINDOW_MAGIC.

{
CHECK_WINDOW_MAGIC(window, 1.0f);
return window->brightness;
}
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 1839 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, SDL_WindowUserData::data, SDL_Window::data, SDL_WindowUserData::name, SDL_WindowUserData::next, NULL, SDL_InvalidParamError, and SDL_strcmp.

{
/* Input validation */
if (name == NULL || name[0] == '\0') {
return NULL;
}
for (data = window->data; data; data = data->next) {
if (data->name && SDL_strcmp(data->name, name) == 0) {
return data->data;
}
}
return NULL;
}
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 1032 of file SDL_video.c.

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

{
int displayIndex;
int i, dist;
int closest = -1;
int closest_dist = 0x7FFFFFFF;
SDL_Point center;
SDL_Point delta;
CHECK_WINDOW_MAGIC(window, -1);
if (SDL_WINDOWPOS_ISUNDEFINED(window->x) ||
displayIndex = (window->x & 0xFFFF);
if (displayIndex >= _this->num_displays) {
displayIndex = 0;
}
return displayIndex;
}
if (SDL_WINDOWPOS_ISUNDEFINED(window->y) ||
displayIndex = (window->y & 0xFFFF);
if (displayIndex >= _this->num_displays) {
displayIndex = 0;
}
return displayIndex;
}
/* Find the display containing the window */
for (i = 0; i < _this->num_displays; ++i) {
if (display->fullscreen_window == window) {
return i;
}
}
center.x = window->x + window->w / 2;
center.y = window->y + window->h / 2;
for (i = 0; i < _this->num_displays; ++i) {
if (SDL_EnclosePoints(&center, 1, &rect, NULL)) {
return i;
}
delta.x = center.x - (rect.x + rect.w / 2);
delta.y = center.y - (rect.y + rect.h / 2);
dist = (delta.x*delta.x + delta.y*delta.y);
if (dist < closest_dist) {
closest = i;
closest_dist = dist;
}
}
if (closest < 0) {
SDL_SetError("Couldn't find any displays");
}
return closest;
}
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 1123 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, SDL_VideoDisplay::desktop_mode, SDL_Window::flags, SDL_Window::fullscreen_mode, SDL_DisplayMode::h, SDL_Rect::h, SDL_GetClosestDisplayModeForDisplay(), SDL_GetDisplayForWindow(), SDL_InvalidParamError, SDL_SetError, SDL_WINDOW_FULLSCREEN_DESKTOP, SDL_DisplayMode::w, SDL_Rect::w, and SDL_Window::windowed.

{
SDL_DisplayMode fullscreen_mode;
SDL_VideoDisplay *display;
CHECK_WINDOW_MAGIC(window, -1);
if (!mode) {
return SDL_InvalidParamError("mode");
}
fullscreen_mode = window->fullscreen_mode;
if (!fullscreen_mode.w) {
fullscreen_mode.w = window->windowed.w;
}
if (!fullscreen_mode.h) {
fullscreen_mode.h = window->windowed.h;
}
display = SDL_GetDisplayForWindow(window);
/* if in desktop size mode, just return the size of the desktop */
fullscreen_mode = display->desktop_mode;
&fullscreen_mode,
&fullscreen_mode)) {
return SDL_SetError("Couldn't find display mode match");
}
if (mode) {
*mode = fullscreen_mode;
}
return 0;
}
Uint32 SDL_GetWindowFlags ( SDL_Window window)

Get the window flags.

Definition at line 1737 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, and SDL_Window::flags.

{
CHECK_WINDOW_MAGIC(window, 0);
return window->flags;
}
SDL_Window* SDL_GetWindowFromID ( Uint32  id)

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

Definition at line 1721 of file SDL_video.c.

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

{
if (!_this) {
return NULL;
}
for (window = _this->windows; window; window = window->next) {
if (window->id == id) {
return window;
}
}
return NULL;
}
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 2459 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, SDL_Window::gamma, SDL_VideoDevice::GetWindowGammaRamp, i, SDL_Window::saved_gamma, SDL_malloc, SDL_memcpy, and SDL_OutOfMemory.

{
CHECK_WINDOW_MAGIC(window, -1);
if (!window->gamma) {
int i;
window->gamma = (Uint16 *)SDL_malloc(256*6*sizeof(Uint16));
if (!window->gamma) {
return SDL_OutOfMemory();
}
window->saved_gamma = window->gamma + 3*256;
if (_this->GetWindowGammaRamp(_this, window, window->gamma) < 0) {
return -1;
}
} else {
/* Create an identity gamma ramp */
for (i = 0; i < 256; ++i) {
Uint16 value = (Uint16)((i << 8) | i);
window->gamma[0*256+i] = value;
window->gamma[1*256+i] = value;
window->gamma[2*256+i] = value;
}
}
SDL_memcpy(window->saved_gamma, window->gamma, 3*256*sizeof(Uint16));
}
if (red) {
SDL_memcpy(red, &window->gamma[0*256], 256*sizeof(Uint16));
}
if (green) {
SDL_memcpy(green, &window->gamma[1*256], 256*sizeof(Uint16));
}
if (blue) {
SDL_memcpy(blue, &window->gamma[2*256], 256*sizeof(Uint16));
}
return 0;
}
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 2551 of file SDL_video.c.

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

Uint32 SDL_GetWindowID ( SDL_Window window)

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

Definition at line 1713 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, and SDL_Window::id.

{
CHECK_WINDOW_MAGIC(window, 0);
return window->id;
}
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 2138 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, SDL_Window::max_h, and SDL_Window::max_w.

{
if (max_w) {
*max_w = window->max_w;
}
if (max_h) {
*max_h = window->max_h;
}
}
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 2096 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, SDL_Window::min_h, and SDL_Window::min_w.

{
if (min_w) {
*min_w = window->min_w;
}
if (min_h) {
*min_h = window->min_h;
}
}
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 2387 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, and SDL_Window::opacity.

{
CHECK_WINDOW_MAGIC(window, -1);
if (out_opacity) {
*out_opacity = window->opacity;
}
return 0;
}
Uint32 SDL_GetWindowPixelFormat ( SDL_Window window)

Get the pixel format associated with the window.

Definition at line 1160 of file SDL_video.c.

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

{
SDL_VideoDisplay *display;
display = SDL_GetDisplayForWindow(window);
return display->current_mode.format;
}
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 1905 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, SDL_Window::flags, SDL_GetDisplayBounds, SDL_GetWindowDisplayIndex, SDL_WINDOW_FULLSCREEN, SDL_zero, SDL_Rect::x, SDL_Window::x, SDL_Rect::y, and SDL_Window::y.

{
/* Fullscreen windows are always at their display's origin */
if (window->flags & SDL_WINDOW_FULLSCREEN) {
int displayIndex;
if (x) {
*x = 0;
}
if (y) {
*y = 0;
}
/* Find the window's monitor and update to the
monitor offset. */
displayIndex = SDL_GetWindowDisplayIndex(window);
if (displayIndex >= 0) {
SDL_Rect bounds;
SDL_zero(bounds);
SDL_GetDisplayBounds(displayIndex, &bounds);
if (x) {
*x = bounds.x;
}
if (y) {
*y = bounds.y;
}
}
} else {
if (x) {
*x = window->x;
}
if (y) {
*y = window->y;
}
}
}
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 2031 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, SDL_Window::h, and SDL_Window::w.

{
if (w) {
*w = window->w;
}
if (h) {
*h = window->h;
}
}
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 2293 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, SDL_Surface::flags, NULL, SDL_CreateWindowFramebuffer(), SDL_DONTFREE, SDL_FreeSurface, SDL_TRUE, SDL_Window::surface, and SDL_Window::surface_valid.

{
if (!window->surface_valid) {
if (window->surface) {
window->surface->flags &= ~SDL_DONTFREE;
}
if (window->surface) {
window->surface->flags |= SDL_DONTFREE;
}
}
return window->surface;
}
const char* SDL_GetWindowTitle ( SDL_Window window)

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

See Also
SDL_SetWindowTitle()

Definition at line 1762 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, and SDL_Window::title.

{
CHECK_WINDOW_MAGIC(window, "");
return window->title ? window->title : "";
}
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) ) { ... }

Definition at line 3712 of file SDL_video.c.

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

{
if (!info) {
return SDL_FALSE;
}
return SDL_FALSE;
}
return (_this->GetWindowWMInfo(_this, window, info));
}
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 3468 of file SDL_video.c.

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

{
if (!(window->flags & SDL_WINDOW_OPENGL)) {
SDL_SetError("The specified window isn't an OpenGL window");
return NULL;
}
ctx = _this->GL_CreateContext(_this, window);
/* Creating a context is assumed to make it current in the SDL driver. */
if (ctx) {
}
return ctx;
}
void SDL_GL_DeduceMaxSupportedESProfile ( int *  major,
int *  minor 
)

Definition at line 3019 of file SDL_video.c.

References SDL_GL_ExtensionSupported.

{
/* THIS REQUIRES AN EXISTING GL CONTEXT THAT HAS BEEN MADE CURRENT. */
/* Please refer to https://bugzilla.libsdl.org/show_bug.cgi?id=3725 for discussion. */
#if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
/* XXX This is fragile; it will break in the event of release of
* new versions of OpenGL ES.
*/
if (SDL_GL_ExtensionSupported("GL_ARB_ES3_2_compatibility")) {
*major = 3;
*minor = 2;
} else if (SDL_GL_ExtensionSupported("GL_ARB_ES3_1_compatibility")) {
*major = 3;
*minor = 1;
} else if (SDL_GL_ExtensionSupported("GL_ARB_ES3_compatibility")) {
*major = 3;
*minor = 0;
} else {
*major = 2;
*minor = 0;
}
#endif
}
void SDL_GL_DeleteContext ( SDL_GLContext  context)

Delete an OpenGL context.

See Also
SDL_GL_CreateContext()

Definition at line 3599 of file SDL_video.c.

References SDL_VideoDevice::GL_DeleteContext, NULL, SDL_GL_GetCurrentContext, and SDL_GL_MakeCurrent.

SDL_bool SDL_GL_ExtensionSupported ( const char *  extension)

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

Definition at line 2929 of file SDL_video.c.

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.

{
#if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
const GLubyte *(APIENTRY * glGetStringFunc) (GLenum);
const char *extensions;
const char *start;
const char *where, *terminator;
/* Extension names should not have spaces. */
where = SDL_strchr(extension, ' ');
if (where || *extension == '\0') {
return SDL_FALSE;
}
/* See if there's an environment variable override */
start = SDL_getenv(extension);
if (start && *start == '0') {
return SDL_FALSE;
}
/* Lookup the available extensions */
glGetStringFunc = SDL_GL_GetProcAddress("glGetString");
if (!glGetStringFunc) {
return SDL_FALSE;
}
if (isAtLeastGL3((const char *) glGetStringFunc(GL_VERSION))) {
const GLubyte *(APIENTRY * glGetStringiFunc) (GLenum, GLuint);
void (APIENTRY * glGetIntegervFunc) (GLenum pname, GLint * params);
GLint num_exts = 0;
glGetStringiFunc = SDL_GL_GetProcAddress("glGetStringi");
glGetIntegervFunc = SDL_GL_GetProcAddress("glGetIntegerv");
if ((!glGetStringiFunc) || (!glGetIntegervFunc)) {
return SDL_FALSE;
}
#ifndef GL_NUM_EXTENSIONS
#define GL_NUM_EXTENSIONS 0x821D
#endif
glGetIntegervFunc(GL_NUM_EXTENSIONS, &num_exts);
for (i = 0; i < num_exts; i++) {
const char *thisext = (const char *) glGetStringiFunc(GL_EXTENSIONS, i);
if (SDL_strcmp(thisext, extension) == 0) {
return SDL_TRUE;
}
}
return SDL_FALSE;
}
/* Try the old way with glGetString(GL_EXTENSIONS) ... */
extensions = (const char *) glGetStringFunc(GL_EXTENSIONS);
if (!extensions) {
return SDL_FALSE;
}
/*
* It takes a bit of care to be fool-proof about parsing the OpenGL
* extensions string. Don't be fooled by sub-strings, etc.
*/
start = extensions;
for (;;) {
where = SDL_strstr(start, extension);
if (!where)
break;
terminator = where + SDL_strlen(extension);
if (where == extensions || *(where - 1) == ' ')
if (*terminator == ' ' || *terminator == '\0')
return SDL_TRUE;
start = terminator;
}
return SDL_FALSE;
#else
return SDL_FALSE;
#endif
}
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 3219 of file SDL_video.c.

References 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.

{
#if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
GLenum (APIENTRY *glGetErrorFunc) (void);
GLenum attrib = 0;
GLenum error = 0;
/*
* Some queries in Core Profile desktop OpenGL 3+ contexts require
* glGetFramebufferAttachmentParameteriv instead of glGetIntegerv. Note that
* the enums we use for the former function don't exist in OpenGL ES 2, and
* the function itself doesn't exist prior to OpenGL 3 and OpenGL ES 2.
*/
#if SDL_VIDEO_OPENGL
const GLubyte *(APIENTRY *glGetStringFunc) (GLenum name);
void (APIENTRY *glGetFramebufferAttachmentParameterivFunc) (GLenum target, GLenum attachment, GLenum pname, GLint* params);
GLenum attachment = GL_BACK_LEFT;
GLenum attachmentattrib = 0;
#endif
if (!value) {
return SDL_InvalidParamError("value");
}
/* Clear value in any case */
*value = 0;
if (!_this) {
}
switch (attr) {
#if SDL_VIDEO_OPENGL
#endif
attrib = GL_RED_BITS;
break;
#if SDL_VIDEO_OPENGL
#endif
attrib = GL_BLUE_BITS;
break;
#if SDL_VIDEO_OPENGL
#endif
attrib = GL_GREEN_BITS;
break;
#if SDL_VIDEO_OPENGL
#endif
attrib = GL_ALPHA_BITS;
break;
#if SDL_VIDEO_OPENGL
attrib = GL_DOUBLEBUFFER;
break;
#else
/* OpenGL ES 1.0 and above specifications have EGL_SINGLE_BUFFER */
/* parameter which switches double buffer to single buffer. OpenGL ES */
/* SDL driver must set proper value after initialization */
return 0;
#endif
#if SDL_VIDEO_OPENGL
attachment = GL_DEPTH;
#endif
attrib = GL_DEPTH_BITS;
break;
#if SDL_VIDEO_OPENGL
attachment = GL_STENCIL;
#endif
attrib = GL_STENCIL_BITS;
break;
#if SDL_VIDEO_OPENGL
break;
break;
break;
break;
attrib = GL_STEREO;
break;
#else
/* none of these are supported in OpenGL ES */
*value = 0;
return 0;
#endif
break;
attrib = GL_SAMPLES;
break;
#if SDL_VIDEO_OPENGL
#else
#endif
break;
{
int rsize = 0, gsize = 0, bsize = 0, asize = 0;
/* There doesn't seem to be a single flag in OpenGL for this! */
return -1;
}
return -1;
}
return -1;
}
return -1;
}
*value = rsize + gsize + bsize + asize;
return 0;
}
{
/* FIXME: How do we get this information? */
return 0;
}
{
return 0;
}
{
return 0;
}
{
return 0;
}
/* FIXME: SDL_GL_CONTEXT_EGL to be deprecated in SDL 2.1 */
{
*value = 1;
}
else {
*value = 0;
}
return 0;
}
{
return 0;
}
{
return 0;
}
{
return 0;
}
{
return 0;
}
{
return 0;
}
default:
return SDL_SetError("Unknown OpenGL attribute");
}
#if SDL_VIDEO_OPENGL
glGetStringFunc = SDL_GL_GetProcAddress("glGetString");
if (!glGetStringFunc) {
return -1;
}
if (attachmentattrib && isAtLeastGL3((const char *) glGetStringFunc(GL_VERSION))) {
glGetFramebufferAttachmentParameterivFunc = SDL_GL_GetProcAddress("glGetFramebufferAttachmentParameteriv");
if (glGetFramebufferAttachmentParameterivFunc) {
glGetFramebufferAttachmentParameterivFunc(GL_FRAMEBUFFER, attachment, attachmentattrib, (GLint *) value);
} else {
return -1;
}
} else
#endif
{
void (APIENTRY *glGetIntegervFunc) (GLenum pname, GLint * params);
glGetIntegervFunc = SDL_GL_GetProcAddress("glGetIntegerv");
if (glGetIntegervFunc) {
glGetIntegervFunc(attrib, (GLint *) value);
} else {
return -1;
}
}
glGetErrorFunc = SDL_GL_GetProcAddress("glGetError");
if (!glGetErrorFunc) {
return -1;
}
error = glGetErrorFunc();
if (error != GL_NO_ERROR) {
if (error == GL_INVALID_ENUM) {
return SDL_SetError("OpenGL error: GL_INVALID_ENUM");
} else if (error == GL_INVALID_VALUE) {
return SDL_SetError("OpenGL error: GL_INVALID_VALUE");
}
return SDL_SetError("OpenGL error: %08X", error);
}
return 0;
#else
return SDL_Unsupported();
#endif /* SDL_VIDEO_OPENGL */
}
SDL_GLContext SDL_GL_GetCurrentContext ( void  )

Get the currently active OpenGL context.

Definition at line 3532 of file SDL_video.c.

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

SDL_Window* SDL_GL_GetCurrentWindow ( void  )

Get the currently active OpenGL window.

Definition at line 3522 of file SDL_video.c.

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

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 3541 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, SDL_VideoDevice::GL_GetDrawableSize, and SDL_GetWindowSize.

{
} else {
SDL_GetWindowSize(window, w, h);
}
}
void* SDL_GL_GetProcAddress ( const char *  proc)

Get the address of an OpenGL function.

Definition at line 2882 of file SDL_video.c.

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

{
void *func;
if (!_this) {
return NULL;
}
func = NULL;
func = _this->GL_GetProcAddress(_this, proc);
} else {
SDL_SetError("No GL driver has been loaded");
}
} else {
SDL_SetError("No dynamic GL support in current SDL video driver (%s)", _this->name);
}
return func;
}
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 3567 of file SDL_video.c.

References SDL_VideoDevice::GL_GetSwapInterval, NULL, and SDL_GL_GetCurrentContext.

{
if (!_this) {
return 0;
} else if (SDL_GL_GetCurrentContext() == NULL) {
return 0;
} else if (_this->GL_GetSwapInterval) {
} else {
return 0;
}
}
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 2853 of file SDL_video.c.

References 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().

{
int retval;
if (!_this) {
}
return SDL_SetError("OpenGL library already loaded");
}
retval = 0;
} else {
return SDL_SetError("No dynamic GL support in current SDL video driver (%s)", _this->name);
}
}
if (retval == 0) {
} else {
}
}
return (retval);
}
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 3491 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, SDL_VideoDevice::current_glctx, SDL_VideoDevice::current_glctx_tls, SDL_VideoDevice::current_glwin, SDL_VideoDevice::current_glwin_tls, SDL_Window::flags, SDL_VideoDevice::GL_MakeCurrent, NULL, retval, SDL_GL_GetCurrentContext, SDL_GL_GetCurrentWindow, SDL_SetError, SDL_TLSSet, and SDL_WINDOW_OPENGL.

{
int retval;
if (window == SDL_GL_GetCurrentWindow() &&
/* We're already current. */
return 0;
}
if (!ctx) {
window = NULL;
} else {
CHECK_WINDOW_MAGIC(window, -1);
if (!(window->flags & SDL_WINDOW_OPENGL)) {
return SDL_SetError("The specified window isn't an OpenGL window");
}
}
retval = _this->GL_MakeCurrent(_this, window, ctx);
if (retval == 0) {
}
return retval;
}
void SDL_GL_ResetAttributes ( void  )

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

Definition at line 3044 of file SDL_video.c.

References 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.

{
if (!_this) {
return;
}
_this->gl_config.accelerated = -1; /* accelerated or not, both are fine */
} else {
#if SDL_VIDEO_OPENGL
#elif SDL_VIDEO_OPENGL_ES2
#elif SDL_VIDEO_OPENGL_ES
#endif
}
}
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 3098 of file SDL_video.c.

References 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.

{
#if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
int retval;
if (!_this) {
}
retval = 0;
switch (attr) {
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
/* FIXME: SDL_GL_CONTEXT_EGL to be deprecated in SDL 2.1 */
if (value != 0) {
} else {
};
break;
retval = SDL_SetError("Unknown OpenGL context flag %d", value);
break;
}
break;
if (value != 0 &&
retval = SDL_SetError("Unknown OpenGL context profile %d", value);
break;
}
break;
break;
break;
break;
break;
break;
default:
retval = SDL_SetError("Unknown OpenGL attribute");
break;
}
return retval;
#else
return SDL_Unsupported();
#endif /* SDL_VIDEO_OPENGL */
}
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 3553 of file SDL_video.c.

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

{
if (!_this) {
} else if (SDL_GL_GetCurrentContext() == NULL) {
return SDL_SetError("No OpenGL context has been made current");
} else if (_this->GL_SetSwapInterval) {
return _this->GL_SetSwapInterval(_this, interval);
} else {
return SDL_SetError("Setting the swap interval is not supported");
}
}
void SDL_GL_SwapWindow ( SDL_Window window)

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

Definition at line 3581 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, SDL_Window::flags, SDL_VideoDevice::GL_SwapWindow, SDL_GL_GetCurrentWindow, SDL_SetError, and SDL_WINDOW_OPENGL.

{
if (!(window->flags & SDL_WINDOW_OPENGL)) {
SDL_SetError("The specified window isn't an OpenGL window");
return;
}
if (SDL_GL_GetCurrentWindow() != window) {
SDL_SetError("The specified window has not been made current");
return;
}
}
void SDL_GL_UnloadLibrary ( void  )

Unload the OpenGL library previously loaded by SDL_GL_LoadLibrary().

See Also
SDL_GL_LoadLibrary()

Definition at line 2904 of file SDL_video.c.

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

{
if (!_this) {
return;
}
return;
}
}
}
}
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 3786 of file SDL_video.c.

References SDL_VideoDevice::HasScreenKeyboardSupport, and SDL_FALSE.

SDL_bool SDL_HasWindows ( void  )

Definition at line 1707 of file SDL_video.c.

References NULL, and SDL_VideoDevice::windows.

Referenced by SDL_PrivateJoystickShouldIgnoreEvent().

{
return (_this && _this->windows != NULL);
}
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 3795 of file SDL_video.c.

References SDL_VideoDevice::IsScreenKeyboardShown, and SDL_FALSE.

{
if (window && _this && _this->IsScreenKeyboardShown) {
return _this->IsScreenKeyboardShown(_this, window);
}
return SDL_FALSE;
}
SDL_bool SDL_IsScreenSaverEnabled ( void  )

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

See Also
SDL_EnableScreenSaver()
SDL_DisableScreenSaver()

Definition at line 2764 of file SDL_video.c.

References SDL_FALSE, SDL_TRUE, and SDL_VideoDevice::suspend_screensaver.

{
if (!_this) {
return SDL_TRUE;
}
}
SDL_bool SDL_IsTextInputActive ( void  )

Return whether or not Unicode text input events are enabled.

See Also
SDL_StartTextInput()
SDL_StopTextInput()

Definition at line 3751 of file SDL_video.c.

References SDL_ENABLE, SDL_GetEventState, and SDL_TEXTINPUT.

void SDL_MaximizeWindow ( SDL_Window window)

Make a window as large as possible.

See Also
SDL_RestoreWindow()

Definition at line 2197 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, SDL_Window::flags, SDL_VideoDevice::MaximizeWindow, and SDL_WINDOW_MAXIMIZED.

{
if (window->flags & SDL_WINDOW_MAXIMIZED) {
return;
}
/* !!! FIXME: should this check if the window is resizable? */
}
}
static SDL_bool SDL_MessageboxValidForDriver ( const SDL_MessageBoxData messageboxdata,
SDL_SYSWM_TYPE  drivertype 
)
static

Definition at line 3824 of file SDL_video.c.

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

Referenced by SDL_ShowMessageBox().

{
SDL_Window *window = messageboxdata->window;
if (!window) {
return SDL_TRUE;
}
if (!SDL_GetWindowWMInfo(window, &info)) {
return SDL_TRUE;
} else {
return (info.subsystem == drivertype);
}
}
void SDL_MinimizeWindow ( SDL_Window window)

Minimize a window to an iconic representation.

See Also
SDL_RestoreWindow()

Definition at line 2213 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, SDL_Window::flags, SDL_VideoDevice::MinimizeWindow, SDL_FALSE, SDL_UpdateFullscreenMode(), and SDL_WINDOW_MINIMIZED.

{
if (window->flags & SDL_WINDOW_MINIMIZED) {
return;
}
}
}
void SDL_OnApplicationDidEnterBackground ( void  )
void SDL_OnApplicationDidReceiveMemoryWarning ( void  )

Definition at line 4009 of file SDL_video.c.

References SDL_APP_LOWMEMORY, and SDL_SendAppEvent().

void SDL_OnApplicationWillEnterForeground ( void  )
void SDL_OnApplicationWillTerminate ( void  )

Definition at line 4004 of file SDL_video.c.

References SDL_APP_TERMINATING, and SDL_SendAppEvent().

void SDL_OnWindowEnter ( SDL_Window window)

Definition at line 2607 of file SDL_video.c.

References SDL_VideoDevice::OnWindowEnter.

Referenced by SDL_SendWindowEvent().

{
}
}
void SDL_OnWindowFocusGained ( SDL_Window window)
void SDL_OnWindowHidden ( SDL_Window window)

Definition at line 2572 of file SDL_video.c.

References SDL_FALSE, and SDL_UpdateFullscreenMode().

Referenced by SDL_SendWindowEvent().

void SDL_OnWindowLeave ( SDL_Window window)

Definition at line 2615 of file SDL_video.c.

Referenced by SDL_SendWindowEvent().

{
}
void SDL_OnWindowMinimized ( SDL_Window window)

Definition at line 2585 of file SDL_video.c.

References SDL_FALSE, and SDL_UpdateFullscreenMode().

Referenced by SDL_SendWindowEvent().

void SDL_OnWindowRestored ( SDL_Window window)

Definition at line 2591 of file SDL_video.c.

References FULLSCREEN_VISIBLE, SDL_TRUE, and SDL_UpdateFullscreenMode().

Referenced by SDL_OnWindowShown(), and SDL_SendWindowEvent().

{
/*
* FIXME: Is this fine to just remove this, or should it be preserved just
* for the fullscreen case? In principle it seems like just hiding/showing
* windows shouldn't affect the stacking order; maybe the right fix is to
* re-decouple OnWindowShown and OnWindowRestored.
*/
/*SDL_RaiseWindow(window);*/
if (FULLSCREEN_VISIBLE(window)) {
}
}
void SDL_OnWindowShown ( SDL_Window window)

Definition at line 2566 of file SDL_video.c.

References SDL_OnWindowRestored().

Referenced by SDL_SendWindowEvent().

{
}
void SDL_RaiseWindow ( SDL_Window window)

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

Definition at line 2184 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, SDL_Window::flags, SDL_VideoDevice::RaiseWindow, and SDL_WINDOW_SHOWN.

{
if (!(window->flags & SDL_WINDOW_SHOWN)) {
return;
}
_this->RaiseWindow(_this, window);
}
}
int SDL_RecreateWindow ( SDL_Window window,
Uint32  flags 
)

Definition at line 1617 of file SDL_video.c.

References CREATE_FLAGS, SDL_VideoDevice::CreateSDLWindow, SDL_VideoDevice::DestroyWindow, SDL_VideoDevice::DestroyWindowFramebuffer, SDL_Surface::flags, SDL_Window::flags, SDL_VideoDevice::GL_CreateContext, SDL_Window::hit_test, SDL_Window::icon, SDL_Window::is_destroying, SDL_Window::last_fullscreen_flags, 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_WINDOW_FOREIGN, SDL_WINDOW_HIDDEN, SDL_WINDOW_OPENGL, SDL_WINDOW_VULKAN, SDL_VideoDevice::SetWindowHitTest, SDL_VideoDevice::SetWindowIcon, SDL_VideoDevice::SetWindowTitle, SDL_Window::surface, and SDL_Window::title.

{
SDL_bool loaded_opengl = SDL_FALSE;
return SDL_SetError("OpenGL support is either not configured in SDL "
"or not available in current SDL video driver "
"(%s) or platform", _this->name);
}
if (window->flags & SDL_WINDOW_FOREIGN) {
/* Can't destroy and re-create foreign windows, hrm */
} else {
}
/* Restore video mode, etc. */
SDL_HideWindow(window);
/* Tear down the old native window */
if (window->surface) {
window->surface->flags &= ~SDL_DONTFREE;
window->surface = NULL;
}
}
}
if ((window->flags & SDL_WINDOW_OPENGL) != (flags & SDL_WINDOW_OPENGL)) {
if (flags & SDL_WINDOW_OPENGL) {
return -1;
}
loaded_opengl = SDL_TRUE;
} else {
}
}
if ((window->flags & SDL_WINDOW_VULKAN) != (flags & SDL_WINDOW_VULKAN)) {
SDL_SetError("Can't change SDL_WINDOW_VULKAN window flag");
return -1;
}
if ((window->flags & SDL_WINDOW_VULKAN) && (flags & SDL_WINDOW_OPENGL)) {
SDL_SetError("Vulkan and OpenGL not supported on same window");
return -1;
}
window->last_fullscreen_flags = window->flags;
if (_this->CreateSDLWindow && !(flags & SDL_WINDOW_FOREIGN)) {
if (_this->CreateSDLWindow(_this, window) < 0) {
if (loaded_opengl) {
window->flags &= ~SDL_WINDOW_OPENGL;
}
return -1;
}
}
if (flags & SDL_WINDOW_FOREIGN) {
}
if (_this->SetWindowTitle && window->title) {
}
if (_this->SetWindowIcon && window->icon) {
_this->SetWindowIcon(_this, window, window->icon);
}
if (window->hit_test) {
}
return 0;
}
static void SDL_RestoreMousePosition ( SDL_Window window)
static

Definition at line 1171 of file SDL_video.c.

References SDL_GetMouseFocus, SDL_GetMouseState, and SDL_WarpMouseInWindow.

Referenced by SDL_UpdateFullscreenMode().

{
int x, y;
if (window == SDL_GetMouseFocus()) {
SDL_WarpMouseInWindow(window, x, y);
}
}
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 2229 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, SDL_Window::flags, SDL_VideoDevice::RestoreWindow, SDL_WINDOW_MAXIMIZED, and SDL_WINDOW_MINIMIZED.

{
return;
}
}
}
static int SDL_SetDisplayModeForDisplay ( SDL_VideoDisplay display,
const SDL_DisplayMode mode 
)
static

Definition at line 975 of file SDL_video.c.

References 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_DisplayMode display_mode;
SDL_DisplayMode current_mode;
if (mode) {
display_mode = *mode;
/* Default to the current mode */
if (!display_mode.format) {
display_mode.format = display->current_mode.format;
}
if (!display_mode.w) {
display_mode.w = display->current_mode.w;
}
if (!display_mode.h) {
display_mode.h = display->current_mode.h;
}
if (!display_mode.refresh_rate) {
display_mode.refresh_rate = display->current_mode.refresh_rate;
}
/* Get a good video mode, the closest one possible */
if (!SDL_GetClosestDisplayModeForDisplay(display, &display_mode, &display_mode)) {
return SDL_SetError("No video mode large enough for %dx%d",
display_mode.w, display_mode.h);
}
} else {
display_mode = display->desktop_mode;
}
/* See if there's anything left to do */
current_mode = display->current_mode;
if (SDL_memcmp(&display_mode, &current_mode, sizeof(display_mode)) == 0) {
return 0;
}
/* Actually change the display mode */
return SDL_SetError("SDL video driver doesn't support changing display mode");
}
if (_this->SetDisplayMode(_this, display, &display_mode) < 0) {
return -1;
}
display->current_mode = display_mode;
return 0;
}
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 3778 of file SDL_video.c.

References SDL_VideoDevice::SetTextInputRect.

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 1947 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, SDL_Window::flags, SDL_FALSE, SDL_WINDOW_BORDERLESS, SDL_WINDOW_FULLSCREEN, and SDL_VideoDevice::SetWindowBordered.

{
if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
const int want = (bordered != SDL_FALSE); /* normalize the flag. */
const int have = ((window->flags & SDL_WINDOW_BORDERLESS) == 0);
if ((want != have) && (_this->SetWindowBordered)) {
if (want) {
} else {
}
}
}
}
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 2339 of file SDL_video.c.

References SDL_Window::brightness, CHECK_WINDOW_MAGIC, SDL_CalculateGammaRamp, and SDL_SetWindowGammaRamp.

{
Uint16 ramp[256];
int status;
CHECK_WINDOW_MAGIC(window, -1);
SDL_CalculateGammaRamp(brightness, ramp);
status = SDL_SetWindowGammaRamp(window, ramp, ramp, ramp);
if (status == 0) {
window->brightness = brightness;
}
return status;
}
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 1792 of file SDL_video.c.

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

{
/* Input validation */
if (name == NULL || name[0] == '\0') {
return NULL;
}
/* See if the named data already exists */
prev = NULL;
for (data = window->data; data; prev = data, data = data->next) {
if (data->name && SDL_strcmp(data->name, name) == 0) {
void *last_value = data->data;
if (userdata) {
/* Set the new value */
data->data = userdata;
} else {
/* Delete this value */
if (prev) {
prev->next = data->next;
} else {
window->data = data->next;
}
SDL_free(data->name);
SDL_free(data);
}
return last_value;
}
}
/* Add new data to the window */
if (userdata) {
data = (SDL_WindowUserData *)SDL_malloc(sizeof(*data));
data->name = SDL_strdup(name);
data->data = userdata;
data->next = window->data;
window->data = data;
}
return NULL;
}
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 1103 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, SDL_Window::flags, SDL_Window::fullscreen_mode, FULLSCREEN_VISIBLE, SDL_GetDisplayForWindow(), SDL_GetWindowDisplayMode, SDL_SetDisplayModeForDisplay(), SDL_WINDOW_FULLSCREEN_DESKTOP, and SDL_zero.

{
CHECK_WINDOW_MAGIC(window, -1);
if (mode) {
window->fullscreen_mode = *mode;
} else {
}
SDL_DisplayMode fullscreen_mode;
if (SDL_GetWindowDisplayMode(window, &fullscreen_mode) == 0) {
}
}
return 0;
}
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 2243 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, SDL_Window::flags, FULLSCREEN_MASK, FULLSCREEN_VISIBLE, and SDL_UpdateFullscreenMode().

{
Uint32 oldflags;
CHECK_WINDOW_MAGIC(window, -1);
if (flags == (window->flags & FULLSCREEN_MASK)) {
return 0;
}
/* clear the previous flags and OR in the new ones */
oldflags = window->flags & FULLSCREEN_MASK;
window->flags &= ~FULLSCREEN_MASK;
window->flags |= flags;
if (SDL_UpdateFullscreenMode(window, FULLSCREEN_VISIBLE(window)) == 0) {
return 0;
}
window->flags &= ~FULLSCREEN_MASK;
window->flags |= oldflags;
return -1;
}
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 2425 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, SDL_Window::flags, SDL_Window::gamma, NULL, SDL_assert, SDL_GetWindowGammaRamp, SDL_memcpy, SDL_Unsupported, SDL_WINDOW_INPUT_FOCUS, and SDL_VideoDevice::SetWindowGammaRamp.

{
CHECK_WINDOW_MAGIC(window, -1);
return SDL_Unsupported();
}
if (!window->gamma) {
if (SDL_GetWindowGammaRamp(window, NULL, NULL, NULL) < 0) {
return -1;
}
SDL_assert(window->gamma != NULL);
}
if (red) {
SDL_memcpy(&window->gamma[0*256], red, 256*sizeof(Uint16));
}
if (green) {
SDL_memcpy(&window->gamma[1*256], green, 256*sizeof(Uint16));
}
if (blue) {
SDL_memcpy(&window->gamma[2*256], blue, 256*sizeof(Uint16));
}
if (window->flags & SDL_WINDOW_INPUT_FOCUS) {
return _this->SetWindowGammaRamp(_this, window, window->gamma);
} else {
return 0;
}
}
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 2535 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, SDL_Window::flags, SDL_UpdateWindowGrab(), and SDL_WINDOW_INPUT_GRABBED.

{
if (!!grabbed == !!(window->flags & SDL_WINDOW_INPUT_GRABBED)) {
return;
}
if (grabbed) {
} else {
}
}
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 3973 of file SDL_video.c.

References callback(), CHECK_WINDOW_MAGIC, SDL_Window::hit_test, SDL_Window::hit_test_data, NULL, SDL_Unsupported, and SDL_VideoDevice::SetWindowHitTest.

{
CHECK_WINDOW_MAGIC(window, -1);
return SDL_Unsupported();
} else if (_this->SetWindowHitTest(window, callback != NULL) == -1) {
return -1;
}
window->hit_test = callback;
window->hit_test_data = userdata;
return 0;
}
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 1770 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, SDL_Window::icon, SDL_ConvertSurfaceFormat, SDL_FreeSurface, SDL_PIXELFORMAT_ARGB8888, and SDL_VideoDevice::SetWindowIcon.

{
if (!icon) {
return;
}
/* Convert the icon into ARGB8888 */
if (!window->icon) {
return;
}
_this->SetWindowIcon(_this, window, window->icon);
}
}
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 2412 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, SDL_Unsupported, and SDL_VideoDevice::SetWindowInputFocus.

{
CHECK_WINDOW_MAGIC(window, -1);
return SDL_Unsupported();
}
return _this->SetWindowInputFocus(_this, window);
}
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 2108 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, SDL_Window::flags, SDL_Window::h, SDL_Window::max_h, SDL_Window::max_w, SDL_InvalidParamError, SDL_min, SDL_SetError, SDL_SetWindowSize, SDL_WINDOW_FULLSCREEN, SDL_VideoDevice::SetWindowMaximumSize, and SDL_Window::w.

{
if (max_w <= 0) {
return;
}
if (max_h <= 0) {
return;
}
if (max_w <= window->min_w || max_h <= window->min_h) {
SDL_SetError("SDL_SetWindowMaximumSize(): Tried to set maximum size smaller than minimum size");
return;
}
window->max_w = max_w;
window->max_h = max_h;
if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
}
/* Ensure that window is not larger than maximal size */
SDL_SetWindowSize(window, SDL_min(window->w, window->max_w), SDL_min(window->h, window->max_h));
}
}
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 2065 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, SDL_Window::flags, SDL_Window::h, SDL_Window::max_h, SDL_Window::max_w, SDL_Window::min_h, SDL_Window::min_w, SDL_InvalidParamError, SDL_max, SDL_SetError, SDL_SetWindowSize, SDL_WINDOW_FULLSCREEN, SDL_VideoDevice::SetWindowMinimumSize, and SDL_Window::w.

{
if (min_w <= 0) {
return;
}
if (min_h <= 0) {
return;
}
if ((window->max_w && min_w >= window->max_w) ||
(window->max_h && min_h >= window->max_h)) {
SDL_SetError("SDL_SetWindowMinimumSize(): Tried to set minimum size larger than maximum size");
return;
}
window->min_w = min_w;
window->min_h = min_h;
if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
}
/* Ensure that window is not smaller than minimal size */
SDL_SetWindowSize(window, SDL_max(window->w, window->min_w), SDL_max(window->h, window->min_h));
}
}
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 2399 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, SDL_Unsupported, and SDL_VideoDevice::SetWindowModalFor.

{
CHECK_WINDOW_MAGIC(modal_window, -1);
CHECK_WINDOW_MAGIC(parent_window, -1);
return SDL_Unsupported();
}
return _this->SetWindowModalFor(_this, modal_window, parent_window);
}
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 2363 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, SDL_Window::opacity, retval, SDL_Unsupported, and SDL_VideoDevice::SetWindowOpacity.

{
int retval;
CHECK_WINDOW_MAGIC(window, -1);
return SDL_Unsupported();
}
if (opacity < 0.0f) {
opacity = 0.0f;
} else if (opacity > 1.0f) {
opacity = 1.0f;
}
retval = _this->SetWindowOpacity(_this, window, opacity);
if (retval == 0) {
window->opacity = opacity;
}
return retval;
}
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 1860 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, SDL_Window::flags, SDL_Rect::h, SDL_Window::h, SDL_VideoDevice::num_displays, SDL_GetDisplayBounds, SDL_SendWindowEvent(), SDL_WINDOW_FULLSCREEN, SDL_WINDOWEVENT_MOVED, SDL_WINDOWPOS_ISCENTERED, SDL_WINDOWPOS_ISUNDEFINED, SDL_zero, SDL_VideoDevice::SetWindowPosition, SDL_Rect::w, SDL_Window::w, SDL_Window::windowed, SDL_Rect::x, SDL_Window::x, SDL_Rect::y, and SDL_Window::y.

{
int displayIndex = (x & 0xFFFF);
SDL_Rect bounds;
if (displayIndex >= _this->num_displays) {
displayIndex = 0;
}
SDL_zero(bounds);
SDL_GetDisplayBounds(displayIndex, &bounds);
x = bounds.x + (bounds.w - window->w) / 2;
}
y = bounds.y + (bounds.h - window->h) / 2;
}
}
if ((window->flags & SDL_WINDOW_FULLSCREEN)) {
window->windowed.x = x;
}
window->windowed.y = y;
}
} else {
window->x = x;
}
window->y = y;
}
}
}
}
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 1965 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, SDL_Window::flags, SDL_FALSE, SDL_WINDOW_FULLSCREEN, SDL_WINDOW_RESIZABLE, and SDL_VideoDevice::SetWindowResizable.

{
if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
const int want = (resizable != SDL_FALSE); /* normalize the flag. */
const int have = ((window->flags & SDL_WINDOW_RESIZABLE) != 0);
if ((want != have) && (_this->SetWindowResizable)) {
if (want) {
} else {
}
}
}
}
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 1983 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, SDL_Window::flags, FULLSCREEN_VISIBLE, SDL_Rect::h, SDL_Window::h, SDL_Window::last_fullscreen_flags, SDL_Window::max_h, SDL_Window::max_w, SDL_Window::min_h, SDL_Window::min_w, SDL_InvalidParamError, SDL_OnWindowResized(), SDL_TRUE, SDL_UpdateFullscreenMode(), SDL_WINDOW_FULLSCREEN, SDL_WINDOW_FULLSCREEN_DESKTOP, SDL_VideoDevice::SetWindowSize, SDL_Rect::w, SDL_Window::w, and SDL_Window::windowed.

{
if (w <= 0) {
return;
}
if (h <= 0) {
return;
}
/* Make sure we don't exceed any window size limits */
if (window->min_w && w < window->min_w) {
w = window->min_w;
}
if (window->max_w && w > window->max_w) {
w = window->max_w;
}
if (window->min_h && h < window->min_h) {
h = window->min_h;
}
if (window->max_h && h > window->max_h) {
h = window->max_h;
}
window->windowed.w = w;
window->windowed.h = h;
if (window->flags & SDL_WINDOW_FULLSCREEN) {
window->last_fullscreen_flags = 0;
}
} else {
window->w = w;
window->h = h;
}
if (window->w == w && window->h == h) {
/* We didn't get a SDL_WINDOWEVENT_RESIZED event (by design) */
}
}
}
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 1745 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, SDL_free, SDL_strdup, SDL_VideoDevice::SetWindowTitle, and SDL_Window::title.

{
if (title == window->title) {
return;
}
SDL_free(window->title);
window->title = SDL_strdup(title ? title : "");
}
}
SDL_bool SDL_ShouldAllowTopmost ( void  )
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 3843 of file SDL_video.c.

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

{
int dummybutton;
int retval = -1;
SDL_bool relative_mode;
int show_cursor_prev;
SDL_bool mouse_captured;
SDL_Window *current_window;
if (!messageboxdata) {
return SDL_InvalidParamError("messageboxdata");
} else if (messageboxdata->numbuttons < 0) {
return SDL_SetError("Invalid number of buttons");
}
current_window = SDL_GetKeyboardFocus();
mouse_captured = current_window && ((SDL_GetWindowFlags(current_window) & SDL_WINDOW_MOUSE_CAPTURE) != 0);
relative_mode = SDL_GetRelativeMouseMode();
show_cursor_prev = SDL_ShowCursor(1);
if (!buttonid) {
buttonid = &dummybutton;
}
retval = _this->ShowMessageBox(_this, messageboxdata, buttonid);
}
/* It's completely fine to call this function before video is initialized */
#if SDL_VIDEO_DRIVER_ANDROID
if (retval == -1 &&
Android_ShowMessageBox(messageboxdata, buttonid) == 0) {
retval = 0;
}
#endif
#if SDL_VIDEO_DRIVER_WINDOWS
if (retval == -1 &&
WIN_ShowMessageBox(messageboxdata, buttonid) == 0) {
retval = 0;
}
#endif
#if SDL_VIDEO_DRIVER_WINRT
if (retval == -1 &&
WINRT_ShowMessageBox(messageboxdata, buttonid) == 0) {
retval = 0;
}
#endif
#if SDL_VIDEO_DRIVER_COCOA
if (retval == -1 &&
Cocoa_ShowMessageBox(messageboxdata, buttonid) == 0) {
retval = 0;
}
#endif
#if SDL_VIDEO_DRIVER_UIKIT
if (retval == -1 &&
UIKit_ShowMessageBox(messageboxdata, buttonid) == 0) {
retval = 0;
}
#endif
#if SDL_VIDEO_DRIVER_X11
if (retval == -1 &&
X11_ShowMessageBox(messageboxdata, buttonid) == 0) {
retval = 0;
}
#endif
if (retval == -1) {
SDL_SetError("No message system available");
}
if (current_window) {
SDL_RaiseWindow(current_window);
if (mouse_captured) {
}
}
SDL_ShowCursor(show_cursor_prev);
SDL_SetRelativeMouseMode(relative_mode);
return retval;
}
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 3934 of file SDL_video.c.

References button, SDL_MessageBoxData::buttons, SDL_MessageBoxButtonData::flags, SDL_MessageBoxData::flags, SDL_MessageBoxData::message, NULL, SDL_MessageBoxData::numbuttons, SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT, SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, SDL_ShowMessageBox, SDL_zero, SDL_MessageBoxButtonData::text, SDL_MessageBoxData::title, and SDL_MessageBoxData::window.

{
#ifdef __EMSCRIPTEN__
/* !!! FIXME: propose a browser API for this, get this #ifdef out of here? */
/* Web browsers don't (currently) have an API for a custom message box
that can block, but for the most common case (SDL_ShowSimpleMessageBox),
we can use the standard Javascript alert() function. */
EM_ASM_({
alert(UTF8ToString($0) + "\n\n" + UTF8ToString($1));
}, title, message);
return 0;
#else
SDL_zero(data);
data.flags = flags;
data.title = title;
data.message = message;
data.numbuttons = 1;
data.buttons = &button;
data.window = window;
SDL_zero(button);
button.text = "OK";
return SDL_ShowMessageBox(&data, NULL);
#endif
}
void SDL_ShowWindow ( SDL_Window window)
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 3730 of file SDL_video.c.

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

{
/* First, enable text events */
/* Then show the on-screen keyboard, if any */
window = SDL_GetFocusWindow();
if (window && _this && _this->ShowScreenKeyboard) {
}
/* Finally start the text input system */
}
}
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 3757 of file SDL_video.c.

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

{
/* Stop the text input system */
}
/* Hide the on-screen keyboard, if any */
window = SDL_GetFocusWindow();
if (window && _this && _this->HideScreenKeyboard) {
}
/* Finally disable text events */
}
void SDL_ToggleDragAndDropSupport ( void  )

Definition at line 1374 of file SDL_video.c.

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

Referenced by SDL_EventState().

{
for (window = _this->windows; window; window = window->next) {
_this->AcceptDragAndDrop(window, enable);
}
}
}
static int SDL_UpdateFullscreenMode ( SDL_Window window,
SDL_bool  fullscreen 
)
static

Definition at line 1186 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, SDL_Window::flags, FULLSCREEN_MASK, FULLSCREEN_VISIBLE, SDL_VideoDisplay::fullscreen_window, SDL_DisplayMode::h, SDL_Window::h, SDL_Window::is_destroying, SDL_Window::is_hiding, SDL_Window::last_fullscreen_flags, 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_VideoDisplay *display;
SDL_Window *other;
CHECK_WINDOW_MAGIC(window,-1);
/* if we are in the process of hiding don't go back to fullscreen */
if (window->is_hiding && fullscreen) {
return 0;
}
#ifdef __MACOSX__
/* if the window is going away and no resolution change is necessary,
do nothing, or else we may trigger an ugly double-transition
*/
if (SDL_strcmp(_this->name, "cocoa") == 0) { /* don't do this for X11, etc */
return 0;
/* If we're switching between a fullscreen Space and "normal" fullscreen, we need to get back to normal first. */
if (!Cocoa_SetWindowFullscreenSpace(window, SDL_FALSE)) {
return -1;
}
} else if (fullscreen && ((window->last_fullscreen_flags & FULLSCREEN_MASK) == SDL_WINDOW_FULLSCREEN) && ((window->flags & FULLSCREEN_MASK) == SDL_WINDOW_FULLSCREEN_DESKTOP)) {
display = SDL_GetDisplayForWindow(window);
}
}
if (Cocoa_SetWindowFullscreenSpace(window, fullscreen)) {
if (Cocoa_IsWindowInFullscreenSpace(window) != fullscreen) {
return -1;
}
window->last_fullscreen_flags = window->flags;
return 0;
}
}
#elif __WINRT__ && (NTDDI_VERSION < NTDDI_WIN10)
/* HACK: WinRT 8.x apps can't choose whether or not they are fullscreen
or not. The user can choose this, via OS-provided UI, but this can't
be set programmatically.
Just look at what SDL's WinRT video backend code detected with regards
to fullscreen (being active, or not), and figure out a return/error code
from that.
*/
if (fullscreen == !(WINRT_DetectWindowFlags(window) & FULLSCREEN_MASK)) {
/* Uh oh, either:
1. fullscreen was requested, and we're already windowed
2. windowed-mode was requested, and we're already fullscreen
WinRT 8.x can't resolve either programmatically, so we're
giving up.
*/
return -1;
} else {
/* Whatever was requested, fullscreen or windowed mode, is already
in-place.
*/
return 0;
}
#endif
display = SDL_GetDisplayForWindow(window);
if (fullscreen) {
/* Hide any other fullscreen windows */
if (display->fullscreen_window &&
display->fullscreen_window != window) {
}
}
/* See if anything needs to be done now */
if ((display->fullscreen_window == window) == fullscreen) {
if ((window->last_fullscreen_flags & FULLSCREEN_MASK) == (window->flags & FULLSCREEN_MASK)) {
return 0;
}
}
/* See if there are any fullscreen windows */
for (other = _this->windows; other; other = other->next) {
SDL_bool setDisplayMode = SDL_FALSE;
if (other == window) {
setDisplayMode = fullscreen;
} else if (FULLSCREEN_VISIBLE(other) &&
SDL_GetDisplayForWindow(other) == display) {
setDisplayMode = SDL_TRUE;
}
if (setDisplayMode) {
SDL_DisplayMode fullscreen_mode;
SDL_zero(fullscreen_mode);
if (SDL_GetWindowDisplayMode(other, &fullscreen_mode) == 0) {
SDL_bool resized = SDL_TRUE;
if (other->w == fullscreen_mode.w && other->h == fullscreen_mode.h) {
resized = SDL_FALSE;
}
/* only do the mode change if we want exclusive fullscreen */
if (SDL_SetDisplayModeForDisplay(display, &fullscreen_mode) < 0) {
return -1;
}
} else {
if (SDL_SetDisplayModeForDisplay(display, NULL) < 0) {
return -1;
}
}
}
display->fullscreen_window = other;
/* Generate a mode change event here */
if (resized) {
#ifndef ANDROID
// Android may not resize the window to exactly what our fullscreen mode is, especially on
// windowed Android environments like the Chromebook or Samsung DeX. Given this, we shouldn't
// use fullscreen_mode.w and fullscreen_mode.h, but rather get our current native size. As such,
// Android's SetWindowFullscreen will generate the window event for us with the proper final size.
fullscreen_mode.w, fullscreen_mode.h);
#endif
} else {
}
window->last_fullscreen_flags = window->flags;
return 0;
}
}
}
/* Nope, restore the desktop mode */
}
display->fullscreen_window = NULL;
/* Generate a mode change event here */
/* Restore the cursor position */
window->last_fullscreen_flags = window->flags;
return 0;
}
void SDL_UpdateWindowGrab ( SDL_Window window)

Definition at line 2504 of file SDL_video.c.

References 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_Window *grabbed_window;
SDL_bool grabbed;
if ((SDL_GetMouse()->relative_mode || (window->flags & SDL_WINDOW_INPUT_GRABBED)) &&
grabbed = SDL_TRUE;
} else {
grabbed = SDL_FALSE;
}
grabbed_window = _this->grabbed_window;
if (grabbed) {
if (grabbed_window && (grabbed_window != window)) {
/* stealing a grab from another window! */
grabbed_window->flags &= ~SDL_WINDOW_INPUT_GRABBED;
_this->SetWindowGrab(_this, grabbed_window, SDL_FALSE);
}
}
} else if (grabbed_window == window) {
_this->grabbed_window = NULL; /* ungrabbing. */
}
_this->SetWindowGrab(_this, window, grabbed);
}
}
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 2312 of file SDL_video.c.

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

{
SDL_Rect full_rect;
CHECK_WINDOW_MAGIC(window, -1);
full_rect.x = 0;
full_rect.y = 0;
full_rect.w = window->w;
full_rect.h = window->h;
return SDL_UpdateWindowSurfaceRects(window, &full_rect, 1);
}
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 2326 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, SDL_SetError, SDL_Window::surface_valid, and SDL_VideoDevice::UpdateWindowFramebuffer.

{
CHECK_WINDOW_MAGIC(window, -1);
if (!window->surface_valid) {
return SDL_SetError("Window surface is invalid, please call SDL_GetWindowSurface() to get a new surface");
}
return _this->UpdateWindowFramebuffer(_this, window, rects, numrects);
}
static int SDL_UpdateWindowTexture ( SDL_VideoDevice unused,
SDL_Window window,
const SDL_Rect rects,
int  numrects 
)
static

Definition at line 369 of file SDL_video.c.

References SDL_WindowTextureData::bytes_per_pixel, SDL_Window::h, NULL, SDL_WindowTextureData::pitch, SDL_WindowTextureData::pixels, rect, SDL_WindowTextureData::renderer, SDL_GetSpanEnclosingRect(), SDL_GetWindowData, SDL_RenderCopy, SDL_RenderPresent, SDL_SetError, SDL_UpdateTexture, SDL_WINDOWTEXTUREDATA, SDL_WindowTextureData::texture, SDL_Window::w, SDL_Rect::x, and SDL_Rect::y.

Referenced by SDL_VideoInit().

{
void *src;
if (!data || !data->texture) {
return SDL_SetError("No window texture data");
}
/* Update a single rect that contains subrects for best DMA performance */
if (SDL_GetSpanEnclosingRect(window->w, window->h, numrects, rects, &rect)) {
src = (void *)((Uint8 *)data->pixels +
rect.y * data->pitch +
rect.x * data->bytes_per_pixel);
if (SDL_UpdateTexture(data->texture, &rect, src, data->pitch) < 0) {
return -1;
}
if (SDL_RenderCopy(data->renderer, data->texture, NULL, NULL) < 0) {
return -1;
}
}
return 0;
}
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 464 of file SDL_video.c.

References available(), 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.

{
int index;
int i;
/* Check to make sure we don't overwrite '_this' */
if (_this != NULL) {
}
#if !SDL_TIMERS_DISABLED
#endif
/* Start the event loop */
SDL_MouseInit() < 0 ||
SDL_TouchInit() < 0) {
return -1;
}
/* Select the proper video driver */
index = 0;
video = NULL;
if (driver_name == NULL) {
driver_name = SDL_getenv("SDL_VIDEODRIVER");
}
if (driver_name != NULL) {
for (i = 0; bootstrap[i]; ++i) {
if (SDL_strncasecmp(bootstrap[i]->name, driver_name, SDL_strlen(driver_name)) == 0) {
if (bootstrap[i]->available()) {
video = bootstrap[i]->create(index);
break;
}
}
}
} else {
for (i = 0; bootstrap[i]; ++i) {
if (bootstrap[i]->available()) {
video = bootstrap[i]->create(index);
if (video != NULL) {
break;
}
}
}
}
if (video == NULL) {
if (driver_name) {
return SDL_SetError("%s not available", driver_name);
}
return SDL_SetError("No available video device");
}
_this = video;
/* Set some very sane GL defaults */
/* Initialize the video subsystem */
if (_this->VideoInit(_this) < 0) {
return -1;
}
/* Make sure some displays were added */
if (_this->num_displays == 0) {
return SDL_SetError("The video driver did not add any displays");
}
/* Add the renderer framebuffer emulation if desired */
}
/* Disable the screen saver by default. This is a change from <= 2.0.1,
but most things using SDL are games or media players; you wouldn't
want a screensaver to trigger if you're playing exclusively with a
joystick, or passively watching a movie. Things that use SDL but
function more like a normal desktop app should explicitly reenable the
screensaver. */
}
/* If we don't use a screen keyboard, turn on text input by default,
otherwise programs that expect to get text events without enabling
UNICODE input won't get any events.
Actually, come to think of it, you needed to call SDL_EnableUNICODE(1)
in SDL 1.2 before you got text input events. Hmm...
*/
}
/* We're ready to go! */
return 0;
}
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 2803 of file SDL_video.c.

References 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.

{
int i, j;
if (!_this) {
return;
}
/* Halt event processing before doing anything else */
/* Clean up the system video */
while (_this->windows) {
}
for (i = 0; i < _this->num_displays; ++i) {
for (j = display->num_display_modes; j--;) {
}
display->display_modes = NULL;
SDL_free(display->driverdata);
display->driverdata = NULL;
}
if (_this->displays) {
for (i = 0; i < _this->num_displays; ++i) {
}
}
}
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;
if(!SDL_Vulkan_CreateSurface(window, instance, &surface))
handle_error();
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 4126 of file SDL_video.c.

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

{
if (!(window->flags & SDL_WINDOW_VULKAN)) {
return SDL_FALSE;
}
if (!instance) {
SDL_InvalidParamError("instance");
return SDL_FALSE;
}
if (!surface) {
return SDL_FALSE;
}
return _this->Vulkan_CreateSurface(_this, window, instance, surface);
}
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 4150 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, SDL_GetWindowSize, and SDL_VideoDevice::Vulkan_GetDrawableSize.

{
} else {
SDL_GetWindowSize(window, w, h);
}
}
SDL_bool SDL_Vulkan_GetInstanceExtensions ( SDL_Window window,
unsigned *  count,
const char **  names 
)
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 4077 of file SDL_video.c.

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

{
if (!_this) {
return NULL;
}
SDL_SetError("No Vulkan loader has been loaded");
return NULL;
}
}
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, MoltenVK.framework/MoltenVK and libMoltenVK.dylib in that order. On iOS SDL will attempt to load libMoltenVK.dylib. 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 4051 of file SDL_video.c.

References 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.

{
int retval;
if (!_this) {
return -1;
}
return SDL_SetError("Vulkan loader library already loaded");
}
retval = 0;
} else {
return SDL_SetError("Vulkan support is either not configured in SDL "
"or not available in current SDL video driver "
"(%s) or platform", _this->name);
}
}
if (retval == 0) {
}
return retval;
}
void SDL_Vulkan_UnloadLibrary ( void  )
static SDL_bool ShouldMinimizeOnFocusLoss ( SDL_Window window)
static

Definition at line 2637 of file SDL_video.c.

References SDL_Window::flags, SDL_Window::is_destroying, SDL_VideoDevice::name, SDL_FALSE, SDL_GetHintBoolean, SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, SDL_strcmp, SDL_TRUE, and SDL_WINDOW_FULLSCREEN.

Referenced by SDL_OnWindowFocusLost().

{
if (!(window->flags & SDL_WINDOW_FULLSCREEN) || window->is_destroying) {
return SDL_FALSE;
}
#ifdef __MACOSX__
if (SDL_strcmp(_this->name, "cocoa") == 0) { /* don't do this for X11, etc */
if (Cocoa_IsWindowInFullscreenSpace(window)) {
return SDL_FALSE;
}
}
#endif
}
static SDL_bool ShouldUseTextureFramebuffer ( )
static

Definition at line 169 of file SDL_video.c.

References 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().

{
const char *hint;
/* If there's no native framebuffer support then there's no option */
return SDL_TRUE;
}
/* If this is the dummy driver there is no texture support */
if (_this->is_dummy) {
return SDL_FALSE;
}
/* If the user has specified a software renderer we can't use a
texture framebuffer, or renderer creation will go recursive.
*/
if (hint && SDL_strcasecmp(hint, "software") == 0) {
return SDL_FALSE;
}
/* See if the user or application wants a specific behavior */
if (hint) {
if (*hint == '0' || SDL_strcasecmp(hint, "false") == 0) {
return SDL_FALSE;
} else {
return SDL_TRUE;
}
}
/* Each platform has different performance characteristics */
#if defined(__WIN32__)
/* GDI BitBlt() is way faster than Direct3D dynamic textures right now.
*/
return SDL_FALSE;
#elif defined(__MACOSX__)
/* Mac OS X uses OpenGL as the native fast path (for cocoa and X11) */
return SDL_TRUE;
#elif defined(__LINUX__)
/* Properly configured OpenGL drivers are faster than MIT-SHM */
#if SDL_VIDEO_OPENGL
/* Ugh, find a way to cache this value! */
{
SDL_bool hasAcceleratedOpenGL = SDL_FALSE;
window = SDL_CreateWindow("OpenGL test", -32, -32, 32, 32, SDL_WINDOW_OPENGL|SDL_WINDOW_HIDDEN);
if (window) {
context = SDL_GL_CreateContext(window);
if (context) {
const GLubyte *(APIENTRY * glGetStringFunc) (GLenum);
const char *vendor = NULL;
glGetStringFunc = SDL_GL_GetProcAddress("glGetString");
if (glGetStringFunc) {
vendor = (const char *) glGetStringFunc(GL_VENDOR);
}
/* Add more vendors here at will... */
if (vendor &&
(SDL_strstr(vendor, "ATI Technologies") ||
SDL_strstr(vendor, "NVIDIA"))) {
hasAcceleratedOpenGL = SDL_TRUE;
}
}
}
return hasAcceleratedOpenGL;
}
#elif SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
/* Let's be optimistic about this! */
return SDL_TRUE;
#else
return SDL_FALSE;
#endif
#else
/* Play it safe, assume that if there is a framebuffer driver that it's
optimized for the current platform.
*/
return SDL_FALSE;
#endif
}

Variable Documentation

VideoBootStrap* bootstrap[]
static

Definition at line 60 of file SDL_video.c.