SDL  2.0
SDL_video.h File Reference
#include "SDL_stdinc.h"
#include "SDL_pixels.h"
#include "SDL_rect.h"
#include "SDL_surface.h"
#include "begin_code.h"
#include "close_code.h"
+ Include dependency graph for SDL_video.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  SDL_DisplayMode
 The structure that defines a display mode. More...
 

Macros

#define SDL_WINDOWPOS_UNDEFINED_MASK   0x1FFF0000u
 Used to indicate that you don't care what the window position is. More...
 
#define SDL_WINDOWPOS_UNDEFINED_DISPLAY(X)   (SDL_WINDOWPOS_UNDEFINED_MASK|(X))
 
#define SDL_WINDOWPOS_UNDEFINED   SDL_WINDOWPOS_UNDEFINED_DISPLAY(0)
 
#define SDL_WINDOWPOS_ISUNDEFINED(X)   (((X)&0xFFFF0000) == SDL_WINDOWPOS_UNDEFINED_MASK)
 
#define SDL_WINDOWPOS_CENTERED_MASK   0x2FFF0000u
 Used to indicate that the window position should be centered. More...
 
#define SDL_WINDOWPOS_CENTERED_DISPLAY(X)   (SDL_WINDOWPOS_CENTERED_MASK|(X))
 
#define SDL_WINDOWPOS_CENTERED   SDL_WINDOWPOS_CENTERED_DISPLAY(0)
 
#define SDL_WINDOWPOS_ISCENTERED(X)   (((X)&0xFFFF0000) == SDL_WINDOWPOS_CENTERED_MASK)
 

Typedefs

typedef voidSDL_GLContext
 An opaque handle to an OpenGL context. More...
 
typedef SDL_HitTestResult(* SDL_HitTest) (SDL_Window *win, const SDL_Point *area, void *data)
 Callback used for hit-testing. More...
 

Enumerations

enum  SDL_WindowFlags {
  SDL_WINDOW_FULLSCREEN = 0x00000001,
  SDL_WINDOW_OPENGL = 0x00000002,
  SDL_WINDOW_SHOWN = 0x00000004,
  SDL_WINDOW_HIDDEN = 0x00000008,
  SDL_WINDOW_BORDERLESS = 0x00000010,
  SDL_WINDOW_RESIZABLE = 0x00000020,
  SDL_WINDOW_MINIMIZED = 0x00000040,
  SDL_WINDOW_MAXIMIZED = 0x00000080,
  SDL_WINDOW_INPUT_GRABBED = 0x00000100,
  SDL_WINDOW_INPUT_FOCUS = 0x00000200,
  SDL_WINDOW_MOUSE_FOCUS = 0x00000400,
  SDL_WINDOW_FULLSCREEN_DESKTOP = ( SDL_WINDOW_FULLSCREEN | 0x00001000 ),
  SDL_WINDOW_FOREIGN = 0x00000800,
  SDL_WINDOW_ALLOW_HIGHDPI = 0x00002000,
  SDL_WINDOW_MOUSE_CAPTURE = 0x00004000,
  SDL_WINDOW_ALWAYS_ON_TOP = 0x00008000,
  SDL_WINDOW_SKIP_TASKBAR = 0x00010000,
  SDL_WINDOW_UTILITY = 0x00020000,
  SDL_WINDOW_TOOLTIP = 0x00040000,
  SDL_WINDOW_POPUP_MENU = 0x00080000
}
 The flags on a window. More...
 
enum  SDL_WindowEventID {
  SDL_WINDOWEVENT_NONE,
  SDL_WINDOWEVENT_SHOWN,
  SDL_WINDOWEVENT_HIDDEN,
  SDL_WINDOWEVENT_EXPOSED,
  SDL_WINDOWEVENT_MOVED,
  SDL_WINDOWEVENT_RESIZED,
  SDL_WINDOWEVENT_SIZE_CHANGED,
  SDL_WINDOWEVENT_MINIMIZED,
  SDL_WINDOWEVENT_MAXIMIZED,
  SDL_WINDOWEVENT_RESTORED,
  SDL_WINDOWEVENT_ENTER,
  SDL_WINDOWEVENT_LEAVE,
  SDL_WINDOWEVENT_FOCUS_GAINED,
  SDL_WINDOWEVENT_FOCUS_LOST,
  SDL_WINDOWEVENT_CLOSE,
  SDL_WINDOWEVENT_TAKE_FOCUS,
  SDL_WINDOWEVENT_HIT_TEST
}
 Event subtype for window events. More...
 
enum  SDL_GLattr {
  SDL_GL_RED_SIZE,
  SDL_GL_GREEN_SIZE,
  SDL_GL_BLUE_SIZE,
  SDL_GL_ALPHA_SIZE,
  SDL_GL_BUFFER_SIZE,
  SDL_GL_DOUBLEBUFFER,
  SDL_GL_DEPTH_SIZE,
  SDL_GL_STENCIL_SIZE,
  SDL_GL_ACCUM_RED_SIZE,
  SDL_GL_ACCUM_GREEN_SIZE,
  SDL_GL_ACCUM_BLUE_SIZE,
  SDL_GL_ACCUM_ALPHA_SIZE,
  SDL_GL_STEREO,
  SDL_GL_MULTISAMPLEBUFFERS,
  SDL_GL_MULTISAMPLESAMPLES,
  SDL_GL_ACCELERATED_VISUAL,
  SDL_GL_RETAINED_BACKING,
  SDL_GL_CONTEXT_MAJOR_VERSION,
  SDL_GL_CONTEXT_MINOR_VERSION,
  SDL_GL_CONTEXT_EGL,
  SDL_GL_CONTEXT_FLAGS,
  SDL_GL_CONTEXT_PROFILE_MASK,
  SDL_GL_SHARE_WITH_CURRENT_CONTEXT,
  SDL_GL_FRAMEBUFFER_SRGB_CAPABLE,
  SDL_GL_CONTEXT_RELEASE_BEHAVIOR
}
 OpenGL configuration attributes. More...
 
enum  SDL_GLprofile {
  SDL_GL_CONTEXT_PROFILE_CORE = 0x0001,
  SDL_GL_CONTEXT_PROFILE_COMPATIBILITY = 0x0002,
  SDL_GL_CONTEXT_PROFILE_ES = 0x0004
}
 
enum  SDL_GLcontextFlag {
  SDL_GL_CONTEXT_DEBUG_FLAG = 0x0001,
  SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG = 0x0002,
  SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG = 0x0004,
  SDL_GL_CONTEXT_RESET_ISOLATION_FLAG = 0x0008
}
 
enum  SDL_GLcontextReleaseFlag {
  SDL_GL_CONTEXT_RELEASE_BEHAVIOR_NONE = 0x0000,
  SDL_GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH = 0x0001
}
 
enum  SDL_HitTestResult {
  SDL_HITTEST_NORMAL,
  SDL_HITTEST_DRAGGABLE,
  SDL_HITTEST_RESIZE_TOPLEFT,
  SDL_HITTEST_RESIZE_TOP,
  SDL_HITTEST_RESIZE_TOPRIGHT,
  SDL_HITTEST_RESIZE_RIGHT,
  SDL_HITTEST_RESIZE_BOTTOMRIGHT,
  SDL_HITTEST_RESIZE_BOTTOM,
  SDL_HITTEST_RESIZE_BOTTOMLEFT,
  SDL_HITTEST_RESIZE_LEFT
}
 Possible return values from the SDL_HitTest callback. More...
 

Functions

int SDL_GetNumVideoDrivers (void)
 Get the number of video drivers compiled into SDL. More...
 
const char * SDL_GetVideoDriver (int index)
 Get the name of a built in video driver. More...
 
int SDL_VideoInit (const char *driver_name)
 Initialize the video subsystem, optionally specifying a video driver. More...
 
void SDL_VideoQuit (void)
 Shuts down the video subsystem. More...
 
const char * SDL_GetCurrentVideoDriver (void)
 Returns the name of the currently initialized video driver. More...
 
int SDL_GetNumVideoDisplays (void)
 Returns the number of available video displays. More...
 
const char * SDL_GetDisplayName (int displayIndex)
 Get the name of a display in UTF-8 encoding. More...
 
int SDL_GetDisplayBounds (int displayIndex, SDL_Rect *rect)
 Get the desktop area represented by a display, with the primary display located at 0,0. More...
 
int SDL_GetDisplayDPI (int displayIndex, float *ddpi, float *hdpi, float *vdpi)
 Get the dots/pixels-per-inch for a display. More...
 
int SDL_GetDisplayUsableBounds (int displayIndex, SDL_Rect *rect)
 Get the usable desktop area represented by a display, with the primary display located at 0,0. More...
 
int SDL_GetNumDisplayModes (int displayIndex)
 Returns the number of available display modes. More...
 
int SDL_GetDisplayMode (int displayIndex, int modeIndex, SDL_DisplayMode *mode)
 Fill in information about a specific display mode. More...
 
int SDL_GetDesktopDisplayMode (int displayIndex, SDL_DisplayMode *mode)
 Fill in information about the desktop display mode. More...
 
int SDL_GetCurrentDisplayMode (int displayIndex, SDL_DisplayMode *mode)
 Fill in information about the current display mode. More...
 
SDL_DisplayModeSDL_GetClosestDisplayMode (int displayIndex, const SDL_DisplayMode *mode, SDL_DisplayMode *closest)
 Get the closest match to the requested display mode. More...
 
int SDL_GetWindowDisplayIndex (SDL_Window *window)
 Get the display index associated with a window. More...
 
int SDL_SetWindowDisplayMode (SDL_Window *window, const SDL_DisplayMode *mode)
 Set the display mode used when a fullscreen window is visible. More...
 
int SDL_GetWindowDisplayMode (SDL_Window *window, SDL_DisplayMode *mode)
 Fill in information about the display mode used when a fullscreen window is visible. More...
 
Uint32 SDL_GetWindowPixelFormat (SDL_Window *window)
 Get the pixel format associated with the window. More...
 
SDL_WindowSDL_CreateWindow (const char *title, int x, int y, int w, int h, Uint32 flags)
 Create a window with the specified position, dimensions, and flags. More...
 
SDL_WindowSDL_CreateWindowFrom (const void *data)
 Create an SDL window from an existing native window. More...
 
Uint32 SDL_GetWindowID (SDL_Window *window)
 Get the numeric ID of a window, for logging purposes. More...
 
SDL_WindowSDL_GetWindowFromID (Uint32 id)
 Get a window from a stored ID, or NULL if it doesn't exist. More...
 
Uint32 SDL_GetWindowFlags (SDL_Window *window)
 Get the window flags. More...
 
void SDL_SetWindowTitle (SDL_Window *window, const char *title)
 Set the title of a window, in UTF-8 format. More...
 
const char * SDL_GetWindowTitle (SDL_Window *window)
 Get the title of a window, in UTF-8 format. More...
 
void SDL_SetWindowIcon (SDL_Window *window, SDL_Surface *icon)
 Set the icon for a window. More...
 
voidSDL_SetWindowData (SDL_Window *window, const char *name, void *userdata)
 Associate an arbitrary named pointer with a window. More...
 
voidSDL_GetWindowData (SDL_Window *window, const char *name)
 Retrieve the data pointer associated with a window. More...
 
void SDL_SetWindowPosition (SDL_Window *window, int x, int y)
 Set the position of a window. More...
 
void SDL_GetWindowPosition (SDL_Window *window, int *x, int *y)
 Get the position of a window. More...
 
void SDL_SetWindowSize (SDL_Window *window, int w, int h)
 Set the size of a window's client area. More...
 
void SDL_GetWindowSize (SDL_Window *window, int *w, int *h)
 Get the size of a window's client area. More...
 
int SDL_GetWindowBordersSize (SDL_Window *window, int *top, int *left, int *bottom, int *right)
 Get the size of a window's borders (decorations) around the client area. More...
 
void SDL_SetWindowMinimumSize (SDL_Window *window, int min_w, int min_h)
 Set the minimum size of a window's client area. More...
 
void SDL_GetWindowMinimumSize (SDL_Window *window, int *w, int *h)
 Get the minimum size of a window's client area. More...
 
void SDL_SetWindowMaximumSize (SDL_Window *window, int max_w, int max_h)
 Set the maximum size of a window's client area. More...
 
void SDL_GetWindowMaximumSize (SDL_Window *window, int *w, int *h)
 Get the maximum size of a window's client area. More...
 
void SDL_SetWindowBordered (SDL_Window *window, SDL_bool bordered)
 Set the border state of a window. More...
 
void SDL_SetWindowResizable (SDL_Window *window, SDL_bool resizable)
 Set the user-resizable state of a window. More...
 
void SDL_ShowWindow (SDL_Window *window)
 Show a window. More...
 
void SDL_HideWindow (SDL_Window *window)
 Hide a window. More...
 
void SDL_RaiseWindow (SDL_Window *window)
 Raise a window above other windows and set the input focus. More...
 
void SDL_MaximizeWindow (SDL_Window *window)
 Make a window as large as possible. More...
 
void SDL_MinimizeWindow (SDL_Window *window)
 Minimize a window to an iconic representation. More...
 
void SDL_RestoreWindow (SDL_Window *window)
 Restore the size and position of a minimized or maximized window. More...
 
int SDL_SetWindowFullscreen (SDL_Window *window, Uint32 flags)
 Set a window's fullscreen state. More...
 
SDL_SurfaceSDL_GetWindowSurface (SDL_Window *window)
 Get the SDL surface associated with the window. More...
 
int SDL_UpdateWindowSurface (SDL_Window *window)
 Copy the window surface to the screen. More...
 
int SDL_UpdateWindowSurfaceRects (SDL_Window *window, const SDL_Rect *rects, int numrects)
 Copy a number of rectangles on the window surface to the screen. More...
 
void SDL_SetWindowGrab (SDL_Window *window, SDL_bool grabbed)
 Set a window's input grab mode. More...
 
SDL_bool SDL_GetWindowGrab (SDL_Window *window)
 Get a window's input grab mode. More...
 
SDL_WindowSDL_GetGrabbedWindow (void)
 Get the window that currently has an input grab enabled. More...
 
int SDL_SetWindowBrightness (SDL_Window *window, float brightness)
 Set the brightness (gamma correction) for a window. More...
 
float SDL_GetWindowBrightness (SDL_Window *window)
 Get the brightness (gamma correction) for a window. More...
 
int SDL_SetWindowOpacity (SDL_Window *window, float opacity)
 Set the opacity for a window. More...
 
int SDL_GetWindowOpacity (SDL_Window *window, float *out_opacity)
 Get the opacity of a window. More...
 
int SDL_SetWindowModalFor (SDL_Window *modal_window, SDL_Window *parent_window)
 Sets the window as a modal for another window (TODO: reconsider this function and/or its name) More...
 
int SDL_SetWindowInputFocus (SDL_Window *window)
 Explicitly sets input focus to the window. More...
 
int SDL_SetWindowGammaRamp (SDL_Window *window, const Uint16 *red, const Uint16 *green, const Uint16 *blue)
 Set the gamma ramp for a window. More...
 
int SDL_GetWindowGammaRamp (SDL_Window *window, Uint16 *red, Uint16 *green, Uint16 *blue)
 Get the gamma ramp for a window. More...
 
int SDL_SetWindowHitTest (SDL_Window *window, SDL_HitTest callback, void *callback_data)
 Provide a callback that decides if a window region has special properties. More...
 
void SDL_DestroyWindow (SDL_Window *window)
 Destroy a window. More...
 
SDL_bool SDL_IsScreenSaverEnabled (void)
 Returns whether the screensaver is currently enabled (default off). More...
 
void SDL_EnableScreenSaver (void)
 Allow the screen to be blanked by a screensaver. More...
 
void SDL_DisableScreenSaver (void)
 Prevent the screen from being blanked by a screensaver. More...
 
OpenGL support functions
int SDL_GL_LoadLibrary (const char *path)
 Dynamically load an OpenGL library. More...
 
voidSDL_GL_GetProcAddress (const char *proc)
 Get the address of an OpenGL function. More...
 
void SDL_GL_UnloadLibrary (void)
 Unload the OpenGL library previously loaded by SDL_GL_LoadLibrary(). More...
 
SDL_bool SDL_GL_ExtensionSupported (const char *extension)
 Return true if an OpenGL extension is supported for the current context. More...
 
void SDL_GL_ResetAttributes (void)
 Reset all previously set OpenGL context attributes to their default values. More...
 
int SDL_GL_SetAttribute (SDL_GLattr attr, int value)
 Set an OpenGL window attribute before window creation. More...
 
int SDL_GL_GetAttribute (SDL_GLattr attr, int *value)
 Get the actual value for an attribute from the current context. More...
 
SDL_GLContext SDL_GL_CreateContext (SDL_Window *window)
 Create an OpenGL context for use with an OpenGL window, and make it current. More...
 
int SDL_GL_MakeCurrent (SDL_Window *window, SDL_GLContext context)
 Set up an OpenGL context for rendering into an OpenGL window. More...
 
SDL_WindowSDL_GL_GetCurrentWindow (void)
 Get the currently active OpenGL window. More...
 
SDL_GLContext SDL_GL_GetCurrentContext (void)
 Get the currently active OpenGL context. More...
 
void SDL_GL_GetDrawableSize (SDL_Window *window, int *w, int *h)
 Get the size of a window's underlying drawable in pixels (for use with glViewport). More...
 
int SDL_GL_SetSwapInterval (int interval)
 Set the swap interval for the current OpenGL context. More...
 
int SDL_GL_GetSwapInterval (void)
 Get the swap interval for the current OpenGL context. More...
 
void SDL_GL_SwapWindow (SDL_Window *window)
 Swap the OpenGL buffers for a window, if double-buffering is supported. More...
 
void SDL_GL_DeleteContext (SDL_GLContext context)
 Delete an OpenGL context. More...
 

Detailed Description

Header file for SDL video functions.

Definition in file SDL_video.h.

Macro Definition Documentation

◆ SDL_WINDOWPOS_CENTERED

◆ SDL_WINDOWPOS_CENTERED_DISPLAY

#define SDL_WINDOWPOS_CENTERED_DISPLAY (   X)    (SDL_WINDOWPOS_CENTERED_MASK|(X))

Definition at line 135 of file SDL_video.h.

Referenced by SDLTest_CommonArg().

◆ SDL_WINDOWPOS_CENTERED_MASK

#define SDL_WINDOWPOS_CENTERED_MASK   0x2FFF0000u

Used to indicate that the window position should be centered.

Definition at line 134 of file SDL_video.h.

◆ SDL_WINDOWPOS_ISCENTERED

#define SDL_WINDOWPOS_ISCENTERED (   X)    (((X)&0xFFFF0000) == SDL_WINDOWPOS_CENTERED_MASK)

◆ SDL_WINDOWPOS_ISUNDEFINED

#define SDL_WINDOWPOS_ISUNDEFINED (   X)    (((X)&0xFFFF0000) == SDL_WINDOWPOS_UNDEFINED_MASK)

◆ SDL_WINDOWPOS_UNDEFINED

#define SDL_WINDOWPOS_UNDEFINED   SDL_WINDOWPOS_UNDEFINED_DISPLAY(0)

◆ SDL_WINDOWPOS_UNDEFINED_DISPLAY

#define SDL_WINDOWPOS_UNDEFINED_DISPLAY (   X)    (SDL_WINDOWPOS_UNDEFINED_MASK|(X))

Definition at line 126 of file SDL_video.h.

Referenced by SDLTest_CommonArg().

◆ SDL_WINDOWPOS_UNDEFINED_MASK

#define SDL_WINDOWPOS_UNDEFINED_MASK   0x1FFF0000u

Used to indicate that you don't care what the window position is.

Definition at line 125 of file SDL_video.h.

Typedef Documentation

◆ SDL_GLContext

SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 Uint32 return SDL_AudioCVT SDL_AudioFormat Uint8 int SDL_AudioFormat Uint8 int return Uint8 const Uint8 Uint32 int const char return return return return return return return return Uint32 return Uint32 SDL_Event return SDL_Event int return SDL_EventFilter void SDL_EventFilter void SDL_EventFilter void int return const char const char return SDL_JoystickGUID return int return int return SDL_GameController return int return const char return SDL_GameController SDL_GameControllerAxis return const char return SDL_GameController SDL_GameControllerButton return SDL_GameController SDL_RWops return SDL_TouchID SDL_RWops return int return int return return SDL_Joystick return SDL_Haptic SDL_Haptic return SDL_Haptic return SDL_Haptic SDL_HapticEffect return SDL_Haptic int Uint32 return SDL_Haptic int SDL_Haptic int return SDL_Haptic return SDL_Haptic return SDL_Haptic return SDL_Haptic return const char const char return const char SDL_HintCallback void int return SDL_Joystick return SDL_Joystick return const char return SDL_Joystick return SDL_Joystick return SDL_Joystick return int return SDL_Joystick int return SDL_Joystick int return return return SDL_Scancode return SDL_Scancode return SDL_Keycode return return const char return void int SDL_LogPriority SDL_LogOutputFunction void Uint32 const char const char SDL_Window return int int return SDL_Window int int return SDL_Surface int int return SDL_Cursor return int return SDL_mutex return SDL_mutex return Uint32 return SDL_sem return SDL_sem Uint32 return SDL_sem return SDL_cond SDL_cond return SDL_cond SDL_mutex Uint32 return Uint32 int Uint32 Uint32 Uint32 Uint32 return Uint32 return int return SDL_Palette const SDL_Color int int return const SDL_PixelFormat Uint8 Uint8 Uint8 return Uint32 const SDL_PixelFormat Uint8 Uint8 Uint8 float Uint16 int int return const SDL_Rect const SDL_Rect SDL_Rect return const SDL_Point int const SDL_Rect SDL_Rect return return int int Uint32 SDL_Window SDL_Renderer return SDL_Surface return SDL_Renderer SDL_RendererInfo return SDL_Renderer Uint32 int int int return SDL_Texture Uint32 int int int return SDL_Texture Uint8 Uint8 Uint8 return SDL_Texture Uint8 return SDL_Texture SDL_BlendMode return SDL_Texture const SDL_Rect const Uint8 int const Uint8 int const Uint8 int return SDL_Texture SDL_Renderer SDL_Texture return SDL_Renderer int int return SDL_Renderer const SDL_Rect return SDL_Renderer const SDL_Rect return SDL_Renderer float float return SDL_Renderer Uint8 Uint8 Uint8 Uint8 return SDL_Renderer SDL_BlendMode return SDL_Renderer return SDL_Renderer const SDL_Point int return SDL_Renderer const SDL_Point int return SDL_Renderer const SDL_Rect int return SDL_Renderer const SDL_Rect int return SDL_Renderer SDL_Texture const SDL_Rect const SDL_Rect const double const SDL_Point const SDL_RendererFlip return SDL_Renderer SDL_Renderer SDL_Texture return void int return return SDL_RWops return SDL_RWops return SDL_RWops return SDL_RWops return SDL_RWops Uint16 return SDL_RWops Uint32 return SDL_RWops Uint64 return const char unsigned int unsigned int unsigned int unsigned int Uint32 return SDL_Window SDL_Surface SDL_WindowShapeMode return size_t return void size_t return const char return void size_t size_t int(*) SDL_DYNAPI_PROC int return int return int size_t return size_t return const wchar_t return const wchar_t size_t return const char size_t return const char size_t return char return char return const char int return int char int return long char int return Sint64 char int return const char return const char char int return const char char int return const char char return const char const char size_t return const char const char size_t return double return double return double return double return double return double return double int return float return const char const char return SDL_iconv_t const char size_t char size_t return Uint32 int int int Uint32 Uint32 Uint32 Uint32 return SDL_Surface SDL_Surface return SDL_RWops int return SDL_Surface int return SDL_Surface Uint32 return SDL_Surface Uint8 Uint8 Uint8 return SDL_Surface Uint8 return SDL_Surface SDL_BlendMode return SDL_Surface SDL_Rect SDL_Surface Uint32 Uint32 return SDL_Surface const SDL_Rect Uint32 return SDL_Surface const SDL_Rect SDL_Surface SDL_Rect return SDL_Surface const SDL_Rect SDL_Surface const SDL_Rect return SDL_Surface SDL_Rect SDL_Surface SDL_Rect return SDL_Thread return SDL_Thread return SDL_Thread int return SDL_TLSID const void void(*) return return Uint32 SDL_TimerID return int return SDL_TouchID int return return return const char return return int return int return int SDL_DisplayMode return int const SDL_DisplayMode SDL_DisplayMode return SDL_Window const SDL_DisplayMode return SDL_Window return const void return Uint32 return SDL_Window const char SDL_Window SDL_Surface SDL_Window const char return SDL_Window int int SDL_Window int int SDL_Window int int SDL_Window int int SDL_Window SDL_Window SDL_Window SDL_Window Uint32 return SDL_Window return SDL_Window SDL_bool SDL_Window float return SDL_Window const Uint16 const Uint16 const Uint16 return SDL_Window const char return SDL_GLattr int return SDL_Window return return SDL_Window int int return SDL_GLContext(int, SDL_vsscanf,(const char *a, const char *b, va_list c),(a, b, c), return) SDL_DYNAPI_PROC(int

An opaque handle to an OpenGL context.

Definition at line 172 of file SDL_video.h.

◆ SDL_HitTest

typedef SDL_HitTestResult( * SDL_HitTest) (SDL_Window *win, const SDL_Point *area, void *data)

Callback used for hit-testing.

See also
SDL_SetWindowHitTest

Definition at line 986 of file SDL_video.h.

Enumeration Type Documentation

◆ SDL_GLattr

enum SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 Uint32 return SDL_AudioCVT SDL_AudioFormat Uint8 int SDL_AudioFormat Uint8 int return Uint8 const Uint8 Uint32 int const char return return return return return return return return Uint32 return Uint32 SDL_Event return SDL_Event int return SDL_EventFilter void SDL_EventFilter void SDL_EventFilter void int return const char const char return SDL_JoystickGUID return int return int return SDL_GameController return int return const char return SDL_GameController SDL_GameControllerAxis return const char return SDL_GameController SDL_GameControllerButton return SDL_GameController SDL_RWops return SDL_TouchID SDL_RWops return int return int return return SDL_Joystick return SDL_Haptic SDL_Haptic return SDL_Haptic return SDL_Haptic SDL_HapticEffect return SDL_Haptic int Uint32 return SDL_Haptic int SDL_Haptic int return SDL_Haptic return SDL_Haptic return SDL_Haptic return SDL_Haptic return const char const char return const char SDL_HintCallback void int return SDL_Joystick return SDL_Joystick return const char return SDL_Joystick return SDL_Joystick return SDL_Joystick return int return SDL_Joystick int return SDL_Joystick int return return return SDL_Scancode return SDL_Scancode return SDL_Keycode return return const char return void int SDL_LogPriority SDL_LogOutputFunction void Uint32 const char const char SDL_Window return int int return SDL_Window int int return SDL_Surface int int return SDL_Cursor return int return SDL_mutex return SDL_mutex return Uint32 return SDL_sem return SDL_sem Uint32 return SDL_sem return SDL_cond SDL_cond return SDL_cond SDL_mutex Uint32 return Uint32 int Uint32 Uint32 Uint32 Uint32 return Uint32 return int return SDL_Palette const SDL_Color int int return const SDL_PixelFormat Uint8 Uint8 Uint8 return Uint32 const SDL_PixelFormat Uint8 Uint8 Uint8 float Uint16 int int return const SDL_Rect const SDL_Rect SDL_Rect return const SDL_Point int const SDL_Rect SDL_Rect return return int int Uint32 SDL_Window SDL_Renderer return SDL_Surface return SDL_Renderer SDL_RendererInfo return SDL_Renderer Uint32 int int int return SDL_Texture Uint32 int int int return SDL_Texture Uint8 Uint8 Uint8 return SDL_Texture Uint8 return SDL_Texture SDL_BlendMode return SDL_Texture const SDL_Rect const Uint8 int const Uint8 int const Uint8 int return SDL_Texture SDL_Renderer SDL_Texture return SDL_Renderer int int return SDL_Renderer const SDL_Rect return SDL_Renderer const SDL_Rect return SDL_Renderer float float return SDL_Renderer Uint8 Uint8 Uint8 Uint8 return SDL_Renderer SDL_BlendMode return SDL_Renderer return SDL_Renderer const SDL_Point int return SDL_Renderer const SDL_Point int return SDL_Renderer const SDL_Rect int return SDL_Renderer const SDL_Rect int return SDL_Renderer SDL_Texture const SDL_Rect const SDL_Rect const double const SDL_Point const SDL_RendererFlip return SDL_Renderer SDL_Renderer SDL_Texture return void int return return SDL_RWops return SDL_RWops return SDL_RWops return SDL_RWops return SDL_RWops Uint16 return SDL_RWops Uint32 return SDL_RWops Uint64 return const char unsigned int unsigned int unsigned int unsigned int Uint32 return SDL_Window SDL_Surface SDL_WindowShapeMode return size_t return void size_t return const char return void size_t size_t int(*) a int return int return int size_t return size_t return const wchar_t return const wchar_t size_t return const char size_t return const char size_t return char return char return const char int return int char int return long char int return Sint64 char int return const char return const char char int return const char char int return const char char return const char const char size_t return const char const char size_t return double return double return double return double return double return double return double int return float return const char const char return SDL_iconv_t const char size_t char size_t return Uint32 int int int Uint32 Uint32 Uint32 Uint32 return SDL_Surface SDL_Surface return SDL_RWops int return SDL_Surface int return SDL_Surface Uint32 return SDL_Surface Uint8 Uint8 Uint8 return SDL_Surface Uint8 return SDL_Surface SDL_BlendMode return SDL_Surface SDL_Rect SDL_Surface Uint32 Uint32 return SDL_Surface const SDL_Rect Uint32 return SDL_Surface const SDL_Rect SDL_Surface SDL_Rect return SDL_Surface const SDL_Rect SDL_Surface const SDL_Rect return SDL_Surface SDL_Rect SDL_Surface SDL_Rect return SDL_Thread return SDL_Thread return SDL_Thread int return SDL_TLSID const void void(*) return return Uint32 SDL_TimerID return int return SDL_TouchID int return return return const char return return int return int return int SDL_DisplayMode return int const SDL_DisplayMode SDL_DisplayMode return SDL_Window const SDL_DisplayMode return SDL_Window return const void return Uint32 return SDL_Window const char SDL_Window SDL_Surface SDL_Window const char return SDL_Window int int SDL_Window int int SDL_Window int int SDL_Window int int SDL_Window SDL_Window SDL_Window SDL_Window Uint32 return SDL_Window return SDL_Window SDL_bool SDL_Window float return SDL_Window const Uint16 const Uint16 const Uint16 return SDL_Window const char return SDL_GLattr

OpenGL configuration attributes.

Enumerator
SDL_GL_RED_SIZE 
SDL_GL_GREEN_SIZE 
SDL_GL_BLUE_SIZE 
SDL_GL_ALPHA_SIZE 
SDL_GL_BUFFER_SIZE 
SDL_GL_DOUBLEBUFFER 
SDL_GL_DEPTH_SIZE 
SDL_GL_STENCIL_SIZE 
SDL_GL_ACCUM_RED_SIZE 
SDL_GL_ACCUM_GREEN_SIZE 
SDL_GL_ACCUM_BLUE_SIZE 
SDL_GL_ACCUM_ALPHA_SIZE 
SDL_GL_STEREO 
SDL_GL_MULTISAMPLEBUFFERS 
SDL_GL_MULTISAMPLESAMPLES 
SDL_GL_ACCELERATED_VISUAL 
SDL_GL_RETAINED_BACKING 
SDL_GL_CONTEXT_MAJOR_VERSION 
SDL_GL_CONTEXT_MINOR_VERSION 
SDL_GL_CONTEXT_EGL 
SDL_GL_CONTEXT_FLAGS 
SDL_GL_CONTEXT_PROFILE_MASK 
SDL_GL_SHARE_WITH_CURRENT_CONTEXT 
SDL_GL_FRAMEBUFFER_SRGB_CAPABLE 
SDL_GL_CONTEXT_RELEASE_BEHAVIOR 

Definition at line 177 of file SDL_video.h.

178 {
204 } SDL_GLattr;
SDL_GLattr
OpenGL configuration attributes.
Definition: SDL_video.h:177

◆ SDL_GLcontextFlag

Enumerator
SDL_GL_CONTEXT_DEBUG_FLAG 
SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG 
SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG 
SDL_GL_CONTEXT_RESET_ISOLATION_FLAG 

Definition at line 213 of file SDL_video.h.

◆ SDL_GLcontextReleaseFlag

Enumerator
SDL_GL_CONTEXT_RELEASE_BEHAVIOR_NONE 
SDL_GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH 

Definition at line 221 of file SDL_video.h.

◆ SDL_GLprofile

Enumerator
SDL_GL_CONTEXT_PROFILE_CORE 
SDL_GL_CONTEXT_PROFILE_COMPATIBILITY 
SDL_GL_CONTEXT_PROFILE_ES 

Definition at line 206 of file SDL_video.h.

◆ SDL_HitTestResult

Possible return values from the SDL_HitTest callback.

See also
SDL_HitTest
Enumerator
SDL_HITTEST_NORMAL 

Region is normal. No special properties.

SDL_HITTEST_DRAGGABLE 

Region can drag entire window.

SDL_HITTEST_RESIZE_TOPLEFT 
SDL_HITTEST_RESIZE_TOP 
SDL_HITTEST_RESIZE_TOPRIGHT 
SDL_HITTEST_RESIZE_RIGHT 
SDL_HITTEST_RESIZE_BOTTOMRIGHT 
SDL_HITTEST_RESIZE_BOTTOM 
SDL_HITTEST_RESIZE_BOTTOMLEFT 
SDL_HITTEST_RESIZE_LEFT 

Definition at line 967 of file SDL_video.h.

◆ SDL_WindowEventID

Event subtype for window events.

Enumerator
SDL_WINDOWEVENT_NONE 

Never used

SDL_WINDOWEVENT_SHOWN 

Window has been shown

SDL_WINDOWEVENT_HIDDEN 

Window has been hidden

SDL_WINDOWEVENT_EXPOSED 

Window has been exposed and should be redrawn

SDL_WINDOWEVENT_MOVED 

Window has been moved to data1, data2

SDL_WINDOWEVENT_RESIZED 

Window has been resized to data1xdata2

SDL_WINDOWEVENT_SIZE_CHANGED 

The window size has changed, either as a result of an API call or through the system or user changing the window size.

SDL_WINDOWEVENT_MINIMIZED 

Window has been minimized

SDL_WINDOWEVENT_MAXIMIZED 

Window has been maximized

SDL_WINDOWEVENT_RESTORED 

Window has been restored to normal size and position

SDL_WINDOWEVENT_ENTER 

Window has gained mouse focus

SDL_WINDOWEVENT_LEAVE 

Window has lost mouse focus

SDL_WINDOWEVENT_FOCUS_GAINED 

Window has gained keyboard focus

SDL_WINDOWEVENT_FOCUS_LOST 

Window has lost keyboard focus

SDL_WINDOWEVENT_CLOSE 

The window manager requests that the window be closed

SDL_WINDOWEVENT_TAKE_FOCUS 

Window is being offered a focus (should SetWindowInputFocus() on itself or a subwindow, or ignore)

SDL_WINDOWEVENT_HIT_TEST 

Window had a hit test that wasn't SDL_HITTEST_NORMAL.

Definition at line 143 of file SDL_video.h.

144 {
145  SDL_WINDOWEVENT_NONE, /**< Never used */
146  SDL_WINDOWEVENT_SHOWN, /**< Window has been shown */
147  SDL_WINDOWEVENT_HIDDEN, /**< Window has been hidden */
148  SDL_WINDOWEVENT_EXPOSED, /**< Window has been exposed and should be
149  redrawn */
150  SDL_WINDOWEVENT_MOVED, /**< Window has been moved to data1, data2
151  */
152  SDL_WINDOWEVENT_RESIZED, /**< Window has been resized to data1xdata2 */
153  SDL_WINDOWEVENT_SIZE_CHANGED, /**< The window size has changed, either as
154  a result of an API call or through the
155  system or user changing the window size. */
156  SDL_WINDOWEVENT_MINIMIZED, /**< Window has been minimized */
157  SDL_WINDOWEVENT_MAXIMIZED, /**< Window has been maximized */
158  SDL_WINDOWEVENT_RESTORED, /**< Window has been restored to normal size
159  and position */
160  SDL_WINDOWEVENT_ENTER, /**< Window has gained mouse focus */
161  SDL_WINDOWEVENT_LEAVE, /**< Window has lost mouse focus */
162  SDL_WINDOWEVENT_FOCUS_GAINED, /**< Window has gained keyboard focus */
163  SDL_WINDOWEVENT_FOCUS_LOST, /**< Window has lost keyboard focus */
164  SDL_WINDOWEVENT_CLOSE, /**< The window manager requests that the window be closed */
165  SDL_WINDOWEVENT_TAKE_FOCUS, /**< Window is being offered a focus (should SetWindowInputFocus() on itself or a subwindow, or ignore) */
166  SDL_WINDOWEVENT_HIT_TEST /**< Window had a hit test that wasn't SDL_HITTEST_NORMAL. */
SDL_WindowEventID
Event subtype for window events.
Definition: SDL_video.h:143

◆ SDL_WindowFlags

The flags on a window.

See also
SDL_GetWindowFlags()
Enumerator
SDL_WINDOW_FULLSCREEN 

fullscreen window

SDL_WINDOW_OPENGL 

window usable with OpenGL context

SDL_WINDOW_SHOWN 

window is visible

SDL_WINDOW_HIDDEN 

window is not visible

SDL_WINDOW_BORDERLESS 

no window decoration

SDL_WINDOW_RESIZABLE 

window can be resized

SDL_WINDOW_MINIMIZED 

window is minimized

SDL_WINDOW_MAXIMIZED 

window is maximized

SDL_WINDOW_INPUT_GRABBED 

window has grabbed input focus

SDL_WINDOW_INPUT_FOCUS 

window has input focus

SDL_WINDOW_MOUSE_FOCUS 

window has mouse focus

SDL_WINDOW_FULLSCREEN_DESKTOP 
SDL_WINDOW_FOREIGN 

window not created by SDL

SDL_WINDOW_ALLOW_HIGHDPI 

window should be created in high-DPI mode if supported

SDL_WINDOW_MOUSE_CAPTURE 

window has mouse captured (unrelated to INPUT_GRABBED)

SDL_WINDOW_ALWAYS_ON_TOP 

window should always be above others

SDL_WINDOW_SKIP_TASKBAR 

window should not be added to the taskbar

SDL_WINDOW_UTILITY 

window should be treated as a utility window

SDL_WINDOW_TOOLTIP 

window should be treated as a tooltip

SDL_WINDOW_POPUP_MENU 

window should be treated as a popup menu

Definition at line 97 of file SDL_video.h.

98 {
99  /* !!! FIXME: change this to name = (1<<x). */
100  SDL_WINDOW_FULLSCREEN = 0x00000001, /**< fullscreen window */
101  SDL_WINDOW_OPENGL = 0x00000002, /**< window usable with OpenGL context */
102  SDL_WINDOW_SHOWN = 0x00000004, /**< window is visible */
103  SDL_WINDOW_HIDDEN = 0x00000008, /**< window is not visible */
104  SDL_WINDOW_BORDERLESS = 0x00000010, /**< no window decoration */
105  SDL_WINDOW_RESIZABLE = 0x00000020, /**< window can be resized */
106  SDL_WINDOW_MINIMIZED = 0x00000040, /**< window is minimized */
107  SDL_WINDOW_MAXIMIZED = 0x00000080, /**< window is maximized */
108  SDL_WINDOW_INPUT_GRABBED = 0x00000100, /**< window has grabbed input focus */
109  SDL_WINDOW_INPUT_FOCUS = 0x00000200, /**< window has input focus */
110  SDL_WINDOW_MOUSE_FOCUS = 0x00000400, /**< window has mouse focus */
112  SDL_WINDOW_FOREIGN = 0x00000800, /**< window not created by SDL */
113  SDL_WINDOW_ALLOW_HIGHDPI = 0x00002000, /**< window should be created in high-DPI mode if supported */
114  SDL_WINDOW_MOUSE_CAPTURE = 0x00004000, /**< window has mouse captured (unrelated to INPUT_GRABBED) */
115  SDL_WINDOW_ALWAYS_ON_TOP = 0x00008000, /**< window should always be above others */
116  SDL_WINDOW_SKIP_TASKBAR = 0x00010000, /**< window should not be added to the taskbar */
117  SDL_WINDOW_UTILITY = 0x00020000, /**< window should be treated as a utility window */
118  SDL_WINDOW_TOOLTIP = 0x00040000, /**< window should be treated as a tooltip */
119  SDL_WINDOW_POPUP_MENU = 0x00080000 /**< window should be treated as a popup menu */
SDL_WindowFlags
The flags on a window.
Definition: SDL_video.h:97

Function Documentation

◆ SDL_CreateWindow()

SDL_Window* SDL_CreateWindow ( const char *  title,
int  x,
int  y,
int  w,
int  h,
Uint32  flags 
)

Create a window with the specified position, dimensions, and flags.

Parameters
titleThe title of the window, in UTF-8 encoding.
xThe x position of the window, SDL_WINDOWPOS_CENTERED, or SDL_WINDOWPOS_UNDEFINED.
yThe y position of the window, SDL_WINDOWPOS_CENTERED, or SDL_WINDOWPOS_UNDEFINED.
wThe width of the window, in screen coordinates.
hThe height of the window, in screen coordinates.
flagsThe flags for the window, a mask of any of the following: SDL_WINDOW_FULLSCREEN, SDL_WINDOW_OPENGL, SDL_WINDOW_HIDDEN, SDL_WINDOW_BORDERLESS, SDL_WINDOW_RESIZABLE, SDL_WINDOW_MAXIMIZED, SDL_WINDOW_MINIMIZED, SDL_WINDOW_INPUT_GRABBED, SDL_WINDOW_ALLOW_HIGHDPI.
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() or SDL_GetRendererOutputSize() to query the drawable size in pixels.

See also
SDL_DestroyWindow()

Definition at line 1330 of file SDL_video.c.

References SDL_Window::brightness, CREATE_FLAGS, SDL_VideoDevice::CreateWindow, SDL_Window::flags, FULLSCREEN_VISIBLE, SDL_VideoDevice::GL_CreateContext, SDL_Rect::h, SDL_Window::h, SDL_Window::id, SDL_Window::is_destroying, 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_strcmp, SDL_UpdateFullscreenMode(), SDL_VideoInit(), SDL_WINDOW_ALLOW_HIGHDPI, SDL_WINDOW_FULLSCREEN, SDL_WINDOW_HIDDEN, SDL_WINDOW_OPENGL, SDL_WINDOW_POPUP_MENU, SDL_WINDOW_TOOLTIP, SDL_WINDOW_UTILITY, SDL_WINDOWPOS_ISCENTERED, SDL_WINDOWPOS_ISUNDEFINED, SDL_Rect::w, SDL_Window::w, window, SDL_VideoDevice::window_magic, SDL_Window::windowed, SDL_VideoDevice::windows, SDL_Rect::x, SDL_Window::x, SDL_Rect::y, and SDL_Window::y.

Referenced by ShouldUseTextureFramebuffer().

1331 {
1332  SDL_Window *window;
1333 
1334  if (!_this) {
1335  /* Initialize the video system if needed */
1336  if (SDL_VideoInit(NULL) < 0) {
1337  return NULL;
1338  }
1339  }
1340 
1341  if ( (((flags & SDL_WINDOW_UTILITY) != 0) + ((flags & SDL_WINDOW_TOOLTIP) != 0) + ((flags & SDL_WINDOW_POPUP_MENU) != 0)) > 1 ) {
1342  SDL_SetError("Conflicting window flags specified");
1343  return NULL;
1344  }
1345 
1346  /* Some platforms can't create zero-sized windows */
1347  if (w < 1) {
1348  w = 1;
1349  }
1350  if (h < 1) {
1351  h = 1;
1352  }
1353 
1354  /* Some platforms blow up if the windows are too large. Raise it later? */
1355  if ((w > 16384) || (h > 16384)) {
1356  SDL_SetError("Window is too large.");
1357  return NULL;
1358  }
1359 
1360  /* Some platforms have OpenGL enabled by default */
1361 #if (SDL_VIDEO_OPENGL && __MACOSX__) || __IPHONEOS__ || __ANDROID__ || __NACL__
1362  if (SDL_strcmp(_this->name, "dummy") != 0) {
1364  }
1365 #endif
1366  if (flags & SDL_WINDOW_OPENGL) {
1367  if (!_this->GL_CreateContext) {
1368  SDL_SetError("No OpenGL support in video driver");
1369  return NULL;
1370  }
1371  if (SDL_GL_LoadLibrary(NULL) < 0) {
1372  return NULL;
1373  }
1374  }
1375 
1376  /* Unless the user has specified the high-DPI disabling hint, respect the
1377  * SDL_WINDOW_ALLOW_HIGHDPI flag.
1378  */
1381  flags &= ~SDL_WINDOW_ALLOW_HIGHDPI;
1382  }
1383  }
1384 
1385  window = (SDL_Window *)SDL_calloc(1, sizeof(*window));
1386  if (!window) {
1387  SDL_OutOfMemory();
1388  return NULL;
1389  }
1390  window->magic = &_this->window_magic;
1391  window->id = _this->next_object_id++;
1392  window->x = x;
1393  window->y = y;
1394  window->w = w;
1395  window->h = h;
1398  SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
1399  int displayIndex;
1400  SDL_Rect bounds;
1401 
1402  displayIndex = SDL_GetIndexOfDisplay(display);
1403  SDL_GetDisplayBounds(displayIndex, &bounds);
1405  window->x = bounds.x + (bounds.w - w) / 2;
1406  }
1408  window->y = bounds.y + (bounds.h - h) / 2;
1409  }
1410  }
1411  window->windowed.x = window->x;
1412  window->windowed.y = window->y;
1413  window->windowed.w = window->w;
1414  window->windowed.h = window->h;
1415 
1416  if (flags & SDL_WINDOW_FULLSCREEN) {
1417  SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
1418  int displayIndex;
1419  SDL_Rect bounds;
1420 
1421  displayIndex = SDL_GetIndexOfDisplay(display);
1422  SDL_GetDisplayBounds(displayIndex, &bounds);
1423 
1424  window->x = bounds.x;
1425  window->y = bounds.y;
1426  window->w = bounds.w;
1427  window->h = bounds.h;
1428  }
1429 
1430  window->flags = ((flags & CREATE_FLAGS) | SDL_WINDOW_HIDDEN);
1431  window->last_fullscreen_flags = window->flags;
1432  window->opacity = 1.0f;
1433  window->brightness = 1.0f;
1434  window->next = _this->windows;
1435  window->is_destroying = SDL_FALSE;
1436 
1437  if (_this->windows) {
1438  _this->windows->prev = window;
1439  }
1440  _this->windows = window;
1441 
1442  if (_this->CreateWindow && _this->CreateWindow(_this, window) < 0) {
1443  SDL_DestroyWindow(window);
1444  return NULL;
1445  }
1446 
1447 #if __WINRT__ && (NTDDI_VERSION < NTDDI_WIN10)
1448  /* HACK: WinRT 8.x apps can't choose whether or not they are fullscreen
1449  or not. The user can choose this, via OS-provided UI, but this can't
1450  be set programmatically.
1451 
1452  Just look at what SDL's WinRT video backend code detected with regards
1453  to fullscreen (being active, or not), and figure out a return/error code
1454  from that.
1455  */
1456  flags = window->flags;
1457 #endif
1458 
1459  if (title) {
1460  SDL_SetWindowTitle(window, title);
1461  }
1463 
1464  /* If the window was created fullscreen, make sure the mode code matches */
1466 
1467  return window;
1468 }
#define SDL_WINDOWPOS_ISUNDEFINED(X)
Definition: SDL_video.h:128
SDL_Window * next
Definition: SDL_sysvideo.h:112
const char * name
Definition: SDL_sysvideo.h:149
#define FULLSCREEN_VISIBLE(W)
Definition: SDL_sysvideo.h:114
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
const void * magic
Definition: SDL_sysvideo.h:73
static SDL_Window * window
#define SDL_HINT_VIDEO_HIGHDPI_DISABLED
If set to 1, then do not allow high-DPI windows. ("Retina" on Mac and iOS)
Definition: SDL_hints.h:418
int SDL_GL_LoadLibrary(const char *path)
Dynamically load an OpenGL library.
Definition: SDL_video.c:2713
void SDL_SetWindowTitle(SDL_Window *window, const char *title)
Set the title of a window, in UTF-8 format.
Definition: SDL_video.c:1619
#define SDL_WINDOWPOS_ISCENTERED(X)
Definition: SDL_video.h:137
SDL_bool is_destroying
Definition: SDL_sysvideo.h:99
SDL_Rect windowed
Definition: SDL_sysvideo.h:85
#define SDL_GetHintBoolean
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
#define CREATE_FLAGS
Definition: SDL_video.c:1306
float opacity
Definition: SDL_sysvideo.h:89
void * SDL_calloc(size_t nmemb, size_t size)
SDL_VideoDisplay * SDL_GetDisplayForWindow(SDL_Window *window)
Definition: SDL_video.c:1058
SDL_GLContext(* GL_CreateContext)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:250
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1567
void SDL_DestroyWindow(SDL_Window *window)
Destroy a window.
Definition: SDL_video.c:2550
int x
Definition: SDL_rect.h:66
static int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen)
Definition: SDL_video.c:1152
SDL_Window * windows
Definition: SDL_sysvideo.h:294
int SDL_GetDisplayBounds(int displayIndex, SDL_Rect *rect)
Get the desktop area represented by a display, with the primary display located at 0...
Definition: SDL_video.c:661
int w
Definition: SDL_rect.h:67
float brightness
Definition: SDL_sysvideo.h:91
#define NULL
Definition: begin_code.h:143
#define SDL_OutOfMemory()
Definition: SDL_error.h:52
Uint32 last_fullscreen_flags
Definition: SDL_sysvideo.h:82
#define SDL_SetError
SDL_Window * prev
Definition: SDL_sysvideo.h:111
int SDL_VideoInit(const char *driver_name)
Initialize the video subsystem, optionally specifying a video driver.
Definition: SDL_video.c:449
int h
Definition: SDL_rect.h:67
int(* CreateWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:203
The type used to identify a window.
Definition: SDL_sysvideo.h:71
static void SDL_FinishWindowCreation(SDL_Window *window, Uint32 flags)
Definition: SDL_video.c:1310
Uint32 id
Definition: SDL_sysvideo.h:74
GLbitfield flags
GLubyte GLubyte GLubyte GLubyte w
#define SDL_strcmp
static int SDL_GetIndexOfDisplay(SDL_VideoDisplay *display)
Definition: SDL_video.c:630
Uint32 flags
Definition: SDL_sysvideo.h:81
Uint32 next_object_id
Definition: SDL_sysvideo.h:297
int y
Definition: SDL_rect.h:66
GLfloat GLfloat GLfloat GLfloat h
A rectangle, with the origin at the upper left.
Definition: SDL_rect.h:64

◆ SDL_CreateWindowFrom()

SDL_Window* SDL_CreateWindowFrom ( const void data)

Create an SDL window from an existing native window.

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

Definition at line 1471 of file SDL_video.c.

References SDL_Window::brightness, SDL_VideoDevice::CreateWindowFrom, 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, SDL_Window::prev, SDL_calloc(), SDL_DestroyWindow(), SDL_FALSE, SDL_OutOfMemory, SDL_UninitializedVideo(), SDL_Unsupported, SDL_WINDOW_FOREIGN, window, SDL_VideoDevice::window_magic, and SDL_VideoDevice::windows.

1472 {
1473  SDL_Window *window;
1474 
1475  if (!_this) {
1477  return NULL;
1478  }
1479  if (!_this->CreateWindowFrom) {
1480  SDL_Unsupported();
1481  return NULL;
1482  }
1483  window = (SDL_Window *)SDL_calloc(1, sizeof(*window));
1484  if (!window) {
1485  SDL_OutOfMemory();
1486  return NULL;
1487  }
1488  window->magic = &_this->window_magic;
1489  window->id = _this->next_object_id++;
1490  window->flags = SDL_WINDOW_FOREIGN;
1491  window->last_fullscreen_flags = window->flags;
1492  window->is_destroying = SDL_FALSE;
1493  window->opacity = 1.0f;
1494  window->brightness = 1.0f;
1495  window->next = _this->windows;
1496  if (_this->windows) {
1497  _this->windows->prev = window;
1498  }
1499  _this->windows = window;
1500 
1501  if (_this->CreateWindowFrom(_this, window, data) < 0) {
1502  SDL_DestroyWindow(window);
1503  return NULL;
1504  }
1505  return window;
1506 }
SDL_Window * next
Definition: SDL_sysvideo.h:112
const void * magic
Definition: SDL_sysvideo.h:73
int(* CreateWindowFrom)(_THIS, SDL_Window *window, const void *data)
Definition: SDL_sysvideo.h:204
static SDL_Window * window
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: SDL_opengl.h:1967
SDL_bool is_destroying
Definition: SDL_sysvideo.h:99
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
float opacity
Definition: SDL_sysvideo.h:89
void * SDL_calloc(size_t nmemb, size_t size)
void SDL_DestroyWindow(SDL_Window *window)
Destroy a window.
Definition: SDL_video.c:2550
SDL_Window * windows
Definition: SDL_sysvideo.h:294
float brightness
Definition: SDL_sysvideo.h:91
#define NULL
Definition: begin_code.h:143
#define SDL_OutOfMemory()
Definition: SDL_error.h:52
Uint32 last_fullscreen_flags
Definition: SDL_sysvideo.h:82
SDL_Window * prev
Definition: SDL_sysvideo.h:111
The type used to identify a window.
Definition: SDL_sysvideo.h:71
Uint32 id
Definition: SDL_sysvideo.h:74
static int SDL_UninitializedVideo()
Definition: SDL_video.c:425
Uint32 flags
Definition: SDL_sysvideo.h:81
Uint32 next_object_id
Definition: SDL_sysvideo.h:297
#define SDL_Unsupported()
Definition: SDL_error.h:53

◆ SDL_DestroyWindow()

void SDL_DestroyWindow ( SDL_Window window)

Destroy a window.

Definition at line 2550 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_WINDOW_OPENGL, SDL_Window::surface, SDL_Window::title, and SDL_VideoDevice::windows.

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

2551 {
2552  SDL_VideoDisplay *display;
2553 
2554  CHECK_WINDOW_MAGIC(window,);
2555 
2556  window->is_destroying = SDL_TRUE;
2557 
2558  /* Restore video mode, etc. */
2559  SDL_HideWindow(window);
2560 
2561  /* Make sure this window no longer has focus */
2562  if (SDL_GetKeyboardFocus() == window) {
2564  }
2565  if (SDL_GetMouseFocus() == window) {
2567  }
2568 
2569  /* make no context current if this is the current context window. */
2570  if (window->flags & SDL_WINDOW_OPENGL) {
2571  if (_this->current_glwin == window) {
2572  SDL_GL_MakeCurrent(window, NULL);
2573  }
2574  }
2575 
2576  if (window->surface) {
2577  window->surface->flags &= ~SDL_DONTFREE;
2578  SDL_FreeSurface(window->surface);
2579  }
2582  }
2583  if (_this->DestroyWindow) {
2584  _this->DestroyWindow(_this, window);
2585  }
2586  if (window->flags & SDL_WINDOW_OPENGL) {
2588  }
2589 
2590  display = SDL_GetDisplayForWindow(window);
2591  if (display->fullscreen_window == window) {
2592  display->fullscreen_window = NULL;
2593  }
2594 
2595  /* Now invalidate magic */
2596  window->magic = NULL;
2597 
2598  /* Free memory associated with the window */
2599  SDL_free(window->title);
2600  SDL_FreeSurface(window->icon);
2601  SDL_free(window->gamma);
2602  while (window->data) {
2603  SDL_WindowUserData *data = window->data;
2604 
2605  window->data = data->next;
2606  SDL_free(data->name);
2607  SDL_free(data);
2608  }
2609 
2610  /* Unlink the window from the list */
2611  if (window->next) {
2612  window->next->prev = window->prev;
2613  }
2614  if (window->prev) {
2615  window->prev->next = window->next;
2616  } else {
2617  _this->windows = window->next;
2618  }
2619 
2620  SDL_free(window);
2621 }
SDL_Window * next
Definition: SDL_sysvideo.h:112
void SDL_SetKeyboardFocus(SDL_Window *window)
Definition: SDL_keyboard.c:612
const void * magic
Definition: SDL_sysvideo.h:73
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: SDL_opengl.h:1967
#define SDL_DONTFREE
Definition: SDL_surface.h:55
SDL_bool is_destroying
Definition: SDL_sysvideo.h:99
void SDL_SetMouseFocus(SDL_Window *window)
Definition: SDL_mouse.c:103
void SDL_HideWindow(SDL_Window *window)
Hide a window.
Definition: SDL_video.c:2030
#define SDL_GetKeyboardFocus
Uint32 flags
Definition: SDL_surface.h:71
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
struct SDL_WindowUserData * next
Definition: SDL_sysvideo.h:67
SDL_VideoDisplay * SDL_GetDisplayForWindow(SDL_Window *window)
Definition: SDL_video.c:1058
#define SDL_FreeSurface
void SDL_free(void *mem)
int SDL_GL_MakeCurrent(SDL_Window *window, SDL_GLContext ctx)
Set up an OpenGL context for rendering into an OpenGL window.
Definition: SDL_video.c:3289
void SDL_GL_UnloadLibrary(void)
Unload the OpenGL library previously loaded by SDL_GL_LoadLibrary().
Definition: SDL_video.c:2764
void(* DestroyWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:227
char * title
Definition: SDL_sysvideo.h:75
SDL_Window * windows
Definition: SDL_sysvideo.h:294
SDL_Window * fullscreen_window
Definition: SDL_sysvideo.h:132
void(* DestroyWindowFramebuffer)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:230
#define NULL
Definition: begin_code.h:143
#define SDL_GetMouseFocus
SDL_Surface * icon
Definition: SDL_sysvideo.h:76
SDL_Window * prev
Definition: SDL_sysvideo.h:111
Uint16 * gamma
Definition: SDL_sysvideo.h:92
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
Uint32 flags
Definition: SDL_sysvideo.h:81
SDL_Surface * surface
Definition: SDL_sysvideo.h:95
SDL_Window * current_glwin
Definition: SDL_sysvideo.h:338
SDL_WindowUserData * data
Definition: SDL_sysvideo.h:107

◆ SDL_DisableScreenSaver()

void SDL_DisableScreenSaver ( void  )

Prevent the screen from being blanked by a screensaver.

See also
SDL_IsScreenSaverEnabled()
SDL_EnableScreenSaver()

Definition at line 2648 of file SDL_video.c.

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

Referenced by SDL_VideoInit().

2649 {
2650  if (!_this) {
2651  return;
2652  }
2653  if (_this->suspend_screensaver) {
2654  return;
2655  }
2657  if (_this->SuspendScreenSaver) {
2659  }
2660 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
SDL_bool suspend_screensaver
Definition: SDL_sysvideo.h:291
void(* SuspendScreenSaver)(_THIS)
Definition: SDL_sysvideo.h:265

◆ SDL_EnableScreenSaver()

void SDL_EnableScreenSaver ( void  )

Allow the screen to be blanked by a screensaver.

See also
SDL_IsScreenSaverEnabled()
SDL_DisableScreenSaver()

Definition at line 2633 of file SDL_video.c.

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

Referenced by SDL_VideoQuit().

2634 {
2635  if (!_this) {
2636  return;
2637  }
2638  if (!_this->suspend_screensaver) {
2639  return;
2640  }
2642  if (_this->SuspendScreenSaver) {
2644  }
2645 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
SDL_bool suspend_screensaver
Definition: SDL_sysvideo.h:291
void(* SuspendScreenSaver)(_THIS)
Definition: SDL_sysvideo.h:265

◆ SDL_GetClosestDisplayMode()

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

Get the closest match to the requested display mode.

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

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

See also
SDL_GetNumDisplayModes()
SDL_GetDisplayMode()

Definition at line 936 of file SDL_video.c.

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

939 {
940  SDL_VideoDisplay *display;
941 
942  CHECK_DISPLAY_INDEX(displayIndex, NULL);
943 
944  display = &_this->displays[displayIndex];
945  return SDL_GetClosestDisplayModeForDisplay(display, mode, closest);
946 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
SDL_VideoDisplay * displays
Definition: SDL_sysvideo.h:293
#define NULL
Definition: begin_code.h:143
static SDL_DisplayMode * SDL_GetClosestDisplayModeForDisplay(SDL_VideoDisplay *display, const SDL_DisplayMode *mode, SDL_DisplayMode *closest)
Definition: SDL_video.c:829
#define CHECK_DISPLAY_INDEX(displayIndex, retval)
Definition: SDL_video.c:130

◆ SDL_GetCurrentDisplayMode()

int SDL_GetCurrentDisplayMode ( int  displayIndex,
SDL_DisplayMode mode 
)

Fill in information about the current display mode.

Definition at line 815 of file SDL_video.c.

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

816 {
817  SDL_VideoDisplay *display;
818 
819  CHECK_DISPLAY_INDEX(displayIndex, -1);
820 
821  display = &_this->displays[displayIndex];
822  if (mode) {
823  *mode = display->current_mode;
824  }
825  return 0;
826 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
SDL_DisplayMode current_mode
Definition: SDL_sysvideo.h:130
SDL_VideoDisplay * displays
Definition: SDL_sysvideo.h:293
#define CHECK_DISPLAY_INDEX(displayIndex, retval)
Definition: SDL_video.c:130

◆ SDL_GetCurrentVideoDriver()

const char* SDL_GetCurrentVideoDriver ( void  )

Returns the name of the currently initialized video driver.

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

Definition at line 561 of file SDL_video.c.

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

562 {
563  if (!_this) {
565  return NULL;
566  }
567  return _this->name;
568 }
const char * name
Definition: SDL_sysvideo.h:149
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
#define NULL
Definition: begin_code.h:143
static int SDL_UninitializedVideo()
Definition: SDL_video.c:425

◆ SDL_GetDesktopDisplayMode()

int SDL_GetDesktopDisplayMode ( int  displayIndex,
SDL_DisplayMode mode 
)

Fill in information about the desktop display mode.

Definition at line 801 of file SDL_video.c.

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

802 {
803  SDL_VideoDisplay *display;
804 
805  CHECK_DISPLAY_INDEX(displayIndex, -1);
806 
807  display = &_this->displays[displayIndex];
808  if (mode) {
809  *mode = display->desktop_mode;
810  }
811  return 0;
812 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
SDL_VideoDisplay * displays
Definition: SDL_sysvideo.h:293
SDL_DisplayMode desktop_mode
Definition: SDL_sysvideo.h:129
#define CHECK_DISPLAY_INDEX(displayIndex, retval)
Definition: SDL_video.c:130

◆ SDL_GetDisplayBounds()

int SDL_GetDisplayBounds ( int  displayIndex,
SDL_Rect rect 
)

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

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

Definition at line 661 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_DisplayMode::w, SDL_Rect::w, SDL_Rect::x, and SDL_Rect::y.

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

662 {
663  CHECK_DISPLAY_INDEX(displayIndex, -1);
664 
665  if (rect) {
666  SDL_VideoDisplay *display = &_this->displays[displayIndex];
667 
668  if (_this->GetDisplayBounds) {
669  if (_this->GetDisplayBounds(_this, display, rect) == 0) {
670  return 0;
671  }
672  }
673 
674  /* Assume that the displays are left to right */
675  if (displayIndex == 0) {
676  rect->x = 0;
677  rect->y = 0;
678  } else {
679  SDL_GetDisplayBounds(displayIndex-1, rect);
680  rect->x += rect->w;
681  }
682  rect->w = display->current_mode.w;
683  rect->h = display->current_mode.h;
684  }
685  return 0; /* !!! FIXME: should this be an error if (rect==NULL) ? */
686 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
SDL_DisplayMode current_mode
Definition: SDL_sysvideo.h:130
SDL_VideoDisplay * displays
Definition: SDL_sysvideo.h:293
int(* GetDisplayBounds)(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect)
Definition: SDL_sysvideo.h:174
int x
Definition: SDL_rect.h:66
int SDL_GetDisplayBounds(int displayIndex, SDL_Rect *rect)
Get the desktop area represented by a display, with the primary display located at 0...
Definition: SDL_video.c:661
int w
Definition: SDL_rect.h:67
int h
Definition: SDL_rect.h:67
#define CHECK_DISPLAY_INDEX(displayIndex, retval)
Definition: SDL_video.c:130
int y
Definition: SDL_rect.h:66

◆ SDL_GetDisplayDPI()

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

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

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

Definition at line 708 of file SDL_video.c.

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

709 {
710  SDL_VideoDisplay *display;
711 
712  CHECK_DISPLAY_INDEX(displayIndex, -1);
713 
714  display = &_this->displays[displayIndex];
715 
716  if (_this->GetDisplayDPI) {
717  if (_this->GetDisplayDPI(_this, display, ddpi, hdpi, vdpi) == 0) {
718  return 0;
719  }
720  } else {
721  return SDL_Unsupported();
722  }
723 
724  return -1;
725 }
int(* GetDisplayDPI)(_THIS, SDL_VideoDisplay *display, float *ddpi, float *hdpi, float *vdpi)
Definition: SDL_sysvideo.h:179
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
SDL_VideoDisplay * displays
Definition: SDL_sysvideo.h:293
#define CHECK_DISPLAY_INDEX(displayIndex, retval)
Definition: SDL_video.c:130
#define SDL_Unsupported()
Definition: SDL_error.h:53

◆ SDL_GetDisplayMode()

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

Fill in information about a specific display mode.

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

Definition at line 783 of file SDL_video.c.

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

784 {
785  SDL_VideoDisplay *display;
786 
787  CHECK_DISPLAY_INDEX(displayIndex, -1);
788 
789  display = &_this->displays[displayIndex];
791  return SDL_SetError("index must be in the range of 0 - %d",
792  SDL_GetNumDisplayModesForDisplay(display) - 1);
793  }
794  if (mode) {
795  *mode = display->display_modes[index];
796  }
797  return 0;
798 }
static int SDL_GetNumDisplayModesForDisplay(SDL_VideoDisplay *display)
Definition: SDL_video.c:764
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
SDL_DisplayMode * display_modes
Definition: SDL_sysvideo.h:128
SDL_VideoDisplay * displays
Definition: SDL_sysvideo.h:293
GLuint index
#define SDL_SetError
#define CHECK_DISPLAY_INDEX(displayIndex, retval)
Definition: SDL_video.c:130

◆ SDL_GetDisplayName()

const char* SDL_GetDisplayName ( int  displayIndex)

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

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

Definition at line 653 of file SDL_video.c.

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

654 {
655  CHECK_DISPLAY_INDEX(displayIndex, NULL);
656 
657  return _this->displays[displayIndex].name;
658 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
SDL_VideoDisplay * displays
Definition: SDL_sysvideo.h:293
#define NULL
Definition: begin_code.h:143
#define CHECK_DISPLAY_INDEX(displayIndex, retval)
Definition: SDL_video.c:130

◆ SDL_GetDisplayUsableBounds()

int SDL_GetDisplayUsableBounds ( int  displayIndex,
SDL_Rect rect 
)

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

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

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

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

Definition at line 688 of file SDL_video.c.

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

689 {
690  CHECK_DISPLAY_INDEX(displayIndex, -1);
691 
692  if (rect) {
693  SDL_VideoDisplay *display = &_this->displays[displayIndex];
694 
696  if (_this->GetDisplayUsableBounds(_this, display, rect) == 0) {
697  return 0;
698  }
699  }
700 
701  /* Oh well, just give the entire display bounds. */
702  return SDL_GetDisplayBounds(displayIndex, rect);
703  }
704  return 0; /* !!! FIXME: should this be an error if (rect==NULL) ? */
705 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
SDL_VideoDisplay * displays
Definition: SDL_sysvideo.h:293
int SDL_GetDisplayBounds(int displayIndex, SDL_Rect *rect)
Get the desktop area represented by a display, with the primary display located at 0...
Definition: SDL_video.c:661
#define CHECK_DISPLAY_INDEX(displayIndex, retval)
Definition: SDL_video.c:130
int(* GetDisplayUsableBounds)(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect)
Definition: SDL_sysvideo.h:184

◆ SDL_GetGrabbedWindow()

SDL_Window* SDL_GetGrabbedWindow ( void  )

Get the window that currently has an input grab enabled.

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

Definition at line 2424 of file SDL_video.c.

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

2425 {
2427  return _this->grabbed_window;
2428 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
#define SDL_assert(condition)
Definition: SDL_assert.h:167
SDL_Window * grabbed_window
Definition: SDL_sysvideo.h:295
Uint32 flags
Definition: SDL_sysvideo.h:81

◆ SDL_GetNumDisplayModes()

int SDL_GetNumDisplayModes ( int  displayIndex)

Returns the number of available display modes.

See also
SDL_GetDisplayMode()

Definition at line 775 of file SDL_video.c.

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

776 {
777  CHECK_DISPLAY_INDEX(displayIndex, -1);
778 
779  return SDL_GetNumDisplayModesForDisplay(&_this->displays[displayIndex]);
780 }
static int SDL_GetNumDisplayModesForDisplay(SDL_VideoDisplay *display)
Definition: SDL_video.c:764
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
SDL_VideoDisplay * displays
Definition: SDL_sysvideo.h:293
#define CHECK_DISPLAY_INDEX(displayIndex, retval)
Definition: SDL_video.c:130

◆ SDL_GetNumVideoDisplays()

int SDL_GetNumVideoDisplays ( void  )

Returns the number of available video displays.

See also
SDL_GetDisplayBounds()

Definition at line 620 of file SDL_video.c.

References SDL_VideoDevice::num_displays, and SDL_UninitializedVideo().

621 {
622  if (!_this) {
624  return 0;
625  }
626  return _this->num_displays;
627 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
static int SDL_UninitializedVideo()
Definition: SDL_video.c:425

◆ SDL_GetNumVideoDrivers()

int SDL_GetNumVideoDrivers ( void  )

Get the number of video drivers compiled into SDL.

See also
SDL_GetVideoDriver()

Definition at line 431 of file SDL_video.c.

References SDL_arraysize.

Referenced by SDL_GetVideoDriver().

432 {
433  return SDL_arraysize(bootstrap) - 1;
434 }
static VideoBootStrap * bootstrap[]
Definition: SDL_video.c:63
#define SDL_arraysize(array)
Definition: SDL_stdinc.h:90

◆ SDL_GetVideoDriver()

const char* SDL_GetVideoDriver ( int  index)

Get the name of a built in video driver.

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

Definition at line 437 of file SDL_video.c.

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

438 {
439  if (index >= 0 && index < SDL_GetNumVideoDrivers()) {
440  return bootstrap[index]->name;
441  }
442  return NULL;
443 }
int SDL_GetNumVideoDrivers(void)
Get the number of video drivers compiled into SDL.
Definition: SDL_video.c:431
GLuint index
#define NULL
Definition: begin_code.h:143
static VideoBootStrap * bootstrap[]
Definition: SDL_video.c:63
const char * name
Definition: SDL_sysvideo.h:363

◆ SDL_GetWindowBordersSize()

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

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

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

Definition at line 1945 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, SDL_VideoDevice::GetWindowBordersSize, and SDL_Unsupported.

1946 {
1947  int dummy = 0;
1948 
1949  if (!top) { top = &dummy; }
1950  if (!left) { left = &dummy; }
1951  if (!right) { right = &dummy; }
1952  if (!bottom) { bottom = &dummy; }
1953 
1954  /* Always initialize, so applications don't have to care */
1955  *top = *left = *bottom = *right = 0;
1956 
1957  CHECK_WINDOW_MAGIC(window, -1);
1958 
1959  if (!_this->GetWindowBordersSize) {
1960  return SDL_Unsupported();
1961  }
1962 
1963  return _this->GetWindowBordersSize(_this, window, top, left, bottom, right);
1964 }
GLdouble GLdouble right
int(* GetWindowBordersSize)(_THIS, SDL_Window *window, int *top, int *left, int *bottom, int *right)
Definition: SDL_sysvideo.h:211
GLdouble GLdouble GLdouble GLdouble top
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
GLint left
GLint GLint bottom
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
#define SDL_Unsupported()
Definition: SDL_error.h:53

◆ SDL_GetWindowBrightness()

float SDL_GetWindowBrightness ( SDL_Window window)

Get the brightness (gamma correction) for a window.

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

Definition at line 2220 of file SDL_video.c.

References SDL_Window::brightness, and CHECK_WINDOW_MAGIC.

2221 {
2222  CHECK_WINDOW_MAGIC(window, 1.0f);
2223 
2224  return window->brightness;
2225 }
GLfloat f
float brightness
Definition: SDL_sysvideo.h:91
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120

◆ SDL_GetWindowData()

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

Retrieve the data pointer associated with a window.

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

Definition at line 1713 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.

Referenced by SDL_CreateWindowTexture(), and SDL_UpdateWindowTexture().

1714 {
1716 
1717  CHECK_WINDOW_MAGIC(window, NULL);
1718 
1719  /* Input validation */
1720  if (name == NULL || name[0] == '\0') {
1721  SDL_InvalidParamError("name");
1722  return NULL;
1723  }
1724 
1725  for (data = window->data; data; data = data->next) {
1726  if (data->name && SDL_strcmp(data->name, name) == 0) {
1727  return data->data;
1728  }
1729  }
1730  return NULL;
1731 }
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: SDL_opengl.h:1967
GLuint const GLchar * name
#define SDL_InvalidParamError(param)
Definition: SDL_error.h:54
struct SDL_WindowUserData * next
Definition: SDL_sysvideo.h:67
#define NULL
Definition: begin_code.h:143
#define SDL_strcmp
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
SDL_WindowUserData * data
Definition: SDL_sysvideo.h:107

◆ SDL_GetWindowDisplayIndex()

int SDL_GetWindowDisplayIndex ( SDL_Window window)

Get the display index associated with a window.

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

Definition at line 998 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.

Referenced by SDL_GetDisplayForWindow(), and SDL_GetWindowPosition().

999 {
1000  int displayIndex;
1001  int i, dist;
1002  int closest = -1;
1003  int closest_dist = 0x7FFFFFFF;
1004  SDL_Point center;
1005  SDL_Point delta;
1006  SDL_Rect rect;
1007 
1008  CHECK_WINDOW_MAGIC(window, -1);
1009 
1010  if (SDL_WINDOWPOS_ISUNDEFINED(window->x) ||
1011  SDL_WINDOWPOS_ISCENTERED(window->x)) {
1012  displayIndex = (window->x & 0xFFFF);
1013  if (displayIndex >= _this->num_displays) {
1014  displayIndex = 0;
1015  }
1016  return displayIndex;
1017  }
1018  if (SDL_WINDOWPOS_ISUNDEFINED(window->y) ||
1019  SDL_WINDOWPOS_ISCENTERED(window->y)) {
1020  displayIndex = (window->y & 0xFFFF);
1021  if (displayIndex >= _this->num_displays) {
1022  displayIndex = 0;
1023  }
1024  return displayIndex;
1025  }
1026 
1027  /* Find the display containing the window */
1028  for (i = 0; i < _this->num_displays; ++i) {
1029  SDL_VideoDisplay *display = &_this->displays[i];
1030 
1031  if (display->fullscreen_window == window) {
1032  return i;
1033  }
1034  }
1035  center.x = window->x + window->w / 2;
1036  center.y = window->y + window->h / 2;
1037  for (i = 0; i < _this->num_displays; ++i) {
1038  SDL_GetDisplayBounds(i, &rect);
1039  if (SDL_EnclosePoints(&center, 1, &rect, NULL)) {
1040  return i;
1041  }
1042 
1043  delta.x = center.x - (rect.x + rect.w / 2);
1044  delta.y = center.y - (rect.y + rect.h / 2);
1045  dist = (delta.x*delta.x + delta.y*delta.y);
1046  if (dist < closest_dist) {
1047  closest = i;
1048  closest_dist = dist;
1049  }
1050  }
1051  if (closest < 0) {
1052  SDL_SetError("Couldn't find any displays");
1053  }
1054  return closest;
1055 }
#define SDL_WINDOWPOS_ISUNDEFINED(X)
Definition: SDL_video.h:128
SDL_Rect rect
Definition: testrelative.c:27
The structure that defines a point.
Definition: SDL_rect.h:48
#define SDL_WINDOWPOS_ISCENTERED(X)
Definition: SDL_video.h:137
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
int x
Definition: SDL_rect.h:50
int y
Definition: SDL_rect.h:51
SDL_VideoDisplay * displays
Definition: SDL_sysvideo.h:293
int x
Definition: SDL_rect.h:66
int SDL_GetDisplayBounds(int displayIndex, SDL_Rect *rect)
Get the desktop area represented by a display, with the primary display located at 0...
Definition: SDL_video.c:661
int w
Definition: SDL_rect.h:67
SDL_Window * fullscreen_window
Definition: SDL_sysvideo.h:132
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
#define NULL
Definition: begin_code.h:143
#define SDL_SetError
int h
Definition: SDL_rect.h:67
#define SDL_EnclosePoints
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
int y
Definition: SDL_rect.h:66
A rectangle, with the origin at the upper left.
Definition: SDL_rect.h:64

◆ SDL_GetWindowDisplayMode()

int SDL_GetWindowDisplayMode ( SDL_Window window,
SDL_DisplayMode mode 
)

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

See also
SDL_SetWindowDisplayMode()
SDL_SetWindowFullscreen()

Definition at line 1089 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.

Referenced by SDL_SetWindowDisplayMode(), and SDL_UpdateFullscreenMode().

1090 {
1091  SDL_DisplayMode fullscreen_mode;
1092  SDL_VideoDisplay *display;
1093 
1094  CHECK_WINDOW_MAGIC(window, -1);
1095 
1096  if (!mode) {
1097  return SDL_InvalidParamError("mode");
1098  }
1099 
1100  fullscreen_mode = window->fullscreen_mode;
1101  if (!fullscreen_mode.w) {
1102  fullscreen_mode.w = window->windowed.w;
1103  }
1104  if (!fullscreen_mode.h) {
1105  fullscreen_mode.h = window->windowed.h;
1106  }
1107 
1108  display = SDL_GetDisplayForWindow(window);
1109 
1110  /* if in desktop size mode, just return the size of the desktop */
1112  fullscreen_mode = display->desktop_mode;
1114  &fullscreen_mode,
1115  &fullscreen_mode)) {
1116  return SDL_SetError("Couldn't find display mode match");
1117  }
1118 
1119  if (mode) {
1120  *mode = fullscreen_mode;
1121  }
1122  return 0;
1123 }
SDL_DisplayMode fullscreen_mode
Definition: SDL_sysvideo.h:87
The structure that defines a display mode.
Definition: SDL_video.h:53
#define SDL_InvalidParamError(param)
Definition: SDL_error.h:54
SDL_Rect windowed
Definition: SDL_sysvideo.h:85
SDL_VideoDisplay * SDL_GetDisplayForWindow(SDL_Window *window)
Definition: SDL_video.c:1058
int w
Definition: SDL_rect.h:67
SDL_DisplayMode desktop_mode
Definition: SDL_sysvideo.h:129
#define SDL_SetError
int h
Definition: SDL_rect.h:67
static SDL_DisplayMode * SDL_GetClosestDisplayModeForDisplay(SDL_VideoDisplay *display, const SDL_DisplayMode *mode, SDL_DisplayMode *closest)
Definition: SDL_video.c:829
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
Uint32 flags
Definition: SDL_sysvideo.h:81

◆ SDL_GetWindowFlags()

Uint32 SDL_GetWindowFlags ( SDL_Window window)

Get the window flags.

Definition at line 1611 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, and SDL_Window::flags.

Referenced by SDL_ShowMessageBox().

1612 {
1613  CHECK_WINDOW_MAGIC(window, 0);
1614 
1615  return window->flags;
1616 }
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
Uint32 flags
Definition: SDL_sysvideo.h:81

◆ SDL_GetWindowFromID()

SDL_Window* SDL_GetWindowFromID ( Uint32  id)

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

Definition at line 1595 of file SDL_video.c.

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

1596 {
1597  SDL_Window *window;
1598 
1599  if (!_this) {
1600  return NULL;
1601  }
1602  for (window = _this->windows; window; window = window->next) {
1603  if (window->id == id) {
1604  return window;
1605  }
1606  }
1607  return NULL;
1608 }
SDL_Window * next
Definition: SDL_sysvideo.h:112
static SDL_Window * window
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
SDL_Window * windows
Definition: SDL_sysvideo.h:294
#define NULL
Definition: begin_code.h:143
The type used to identify a window.
Definition: SDL_sysvideo.h:71
Uint32 id
Definition: SDL_sysvideo.h:74

◆ SDL_GetWindowGammaRamp()

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

Get the gamma ramp for a window.

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

Definition at line 2324 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.

Referenced by SDL_SetWindowGammaRamp().

2327 {
2328  CHECK_WINDOW_MAGIC(window, -1);
2329 
2330  if (!window->gamma) {
2331  int i;
2332 
2333  window->gamma = (Uint16 *)SDL_malloc(256*6*sizeof(Uint16));
2334  if (!window->gamma) {
2335  return SDL_OutOfMemory();
2336  }
2337  window->saved_gamma = window->gamma + 3*256;
2338 
2339  if (_this->GetWindowGammaRamp) {
2340  if (_this->GetWindowGammaRamp(_this, window, window->gamma) < 0) {
2341  return -1;
2342  }
2343  } else {
2344  /* Create an identity gamma ramp */
2345  for (i = 0; i < 256; ++i) {
2346  Uint16 value = (Uint16)((i << 8) | i);
2347 
2348  window->gamma[0*256+i] = value;
2349  window->gamma[1*256+i] = value;
2350  window->gamma[2*256+i] = value;
2351  }
2352  }
2353  SDL_memcpy(window->saved_gamma, window->gamma, 3*256*sizeof(Uint16));
2354  }
2355 
2356  if (red) {
2357  SDL_memcpy(red, &window->gamma[0*256], 256*sizeof(Uint16));
2358  }
2359  if (green) {
2360  SDL_memcpy(green, &window->gamma[1*256], 256*sizeof(Uint16));
2361  }
2362  if (blue) {
2363  SDL_memcpy(blue, &window->gamma[2*256], 256*sizeof(Uint16));
2364  }
2365  return 0;
2366 }
Uint16 * saved_gamma
Definition: SDL_sysvideo.h:93
const GLubyte GLuint red
Definition: SDL_glfuncs.h:78
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
#define SDL_memcpy
GLsizei const GLfloat * value
GLbyte GLbyte blue
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
#define SDL_OutOfMemory()
Definition: SDL_error.h:52
int(* GetWindowGammaRamp)(_THIS, SDL_Window *window, Uint16 *ramp)
Definition: SDL_sysvideo.h:225
GLbyte green
uint16_t Uint16
An unsigned 16-bit integer type.
Definition: SDL_stdinc.h:151
#define SDL_malloc
Uint16 * gamma
Definition: SDL_sysvideo.h:92
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120

◆ SDL_GetWindowGrab()

SDL_bool SDL_GetWindowGrab ( SDL_Window window)

Get a window's input grab mode.

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

Definition at line 2416 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.

2417 {
2418  CHECK_WINDOW_MAGIC(window, SDL_FALSE);
2420  return window == _this->grabbed_window;
2421 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
#define SDL_assert(condition)
Definition: SDL_assert.h:167
SDL_Window * grabbed_window
Definition: SDL_sysvideo.h:295
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
Uint32 flags
Definition: SDL_sysvideo.h:81

◆ SDL_GetWindowID()

Uint32 SDL_GetWindowID ( SDL_Window window)

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

Definition at line 1587 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, and SDL_Window::id.

1588 {
1589  CHECK_WINDOW_MAGIC(window, 0);
1590 
1591  return window->id;
1592 }
Uint32 id
Definition: SDL_sysvideo.h:74
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120

◆ SDL_GetWindowMaximumSize()

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

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

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

Definition at line 2003 of file SDL_video.c.

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

2004 {
2005  CHECK_WINDOW_MAGIC(window,);
2006  if (max_w) {
2007  *max_w = window->max_w;
2008  }
2009  if (max_h) {
2010  *max_h = window->max_h;
2011  }
2012 }
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120

◆ SDL_GetWindowMinimumSize()

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

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

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

Definition at line 1967 of file SDL_video.c.

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

1968 {
1969  CHECK_WINDOW_MAGIC(window,);
1970  if (min_w) {
1971  *min_w = window->min_w;
1972  }
1973  if (min_h) {
1974  *min_h = window->min_h;
1975  }
1976 }
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120

◆ SDL_GetWindowOpacity()

int SDL_GetWindowOpacity ( SDL_Window window,
float *  out_opacity 
)

Get the opacity of a window.

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

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

Definition at line 2252 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, and SDL_Window::opacity.

2253 {
2254  CHECK_WINDOW_MAGIC(window, -1);
2255 
2256  if (out_opacity) {
2257  *out_opacity = window->opacity;
2258  }
2259 
2260  return 0;
2261 }
float opacity
Definition: SDL_sysvideo.h:89
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120

◆ SDL_GetWindowPixelFormat()

Uint32 SDL_GetWindowPixelFormat ( SDL_Window window)

Get the pixel format associated with the window.

Definition at line 1126 of file SDL_video.c.

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

1127 {
1128  SDL_VideoDisplay *display;
1129 
1131 
1132  display = SDL_GetDisplayForWindow(window);
1133  return display->current_mode.format;
1134 }
SDL_VideoDisplay * SDL_GetDisplayForWindow(SDL_Window *window)
Definition: SDL_video.c:1058
SDL_DisplayMode current_mode
Definition: SDL_sysvideo.h:130
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
Uint32 format
Definition: SDL_video.h:55

◆ SDL_GetWindowPosition()

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

Get the position of a window.

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

Definition at line 1779 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.

1780 {
1781  CHECK_WINDOW_MAGIC(window,);
1782 
1783  /* Fullscreen windows are always at their display's origin */
1784  if (window->flags & SDL_WINDOW_FULLSCREEN) {
1785  int displayIndex;
1786 
1787  if (x) {
1788  *x = 0;
1789  }
1790  if (y) {
1791  *y = 0;
1792  }
1793 
1794  /* Find the window's monitor and update to the
1795  monitor offset. */
1796  displayIndex = SDL_GetWindowDisplayIndex(window);
1797  if (displayIndex >= 0) {
1798  SDL_Rect bounds;
1799 
1800  SDL_zero(bounds);
1801 
1802  SDL_GetDisplayBounds(displayIndex, &bounds);
1803  if (x) {
1804  *x = bounds.x;
1805  }
1806  if (y) {
1807  *y = bounds.y;
1808  }
1809  }
1810  } else {
1811  if (x) {
1812  *x = window->x;
1813  }
1814  if (y) {
1815  *y = window->y;
1816  }
1817  }
1818 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1567
#define SDL_zero(x)
Definition: SDL_stdinc.h:359
int x
Definition: SDL_rect.h:66
int SDL_GetDisplayBounds(int displayIndex, SDL_Rect *rect)
Get the desktop area represented by a display, with the primary display located at 0...
Definition: SDL_video.c:661
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
int SDL_GetWindowDisplayIndex(SDL_Window *window)
Get the display index associated with a window.
Definition: SDL_video.c:998
Uint32 flags
Definition: SDL_sysvideo.h:81
int y
Definition: SDL_rect.h:66
A rectangle, with the origin at the upper left.
Definition: SDL_rect.h:64

◆ SDL_GetWindowSize()

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

Get the size of a window's client area.

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

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

See also
SDL_SetWindowSize()

Definition at line 1909 of file SDL_video.c.

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

Referenced by SDL_GL_GetDrawableSize().

1910 {
1911  CHECK_WINDOW_MAGIC(window,);
1912  if (w) {
1913  *w = window->w;
1914  }
1915  if (h) {
1916  *h = window->h;
1917  }
1918 }
GLubyte GLubyte GLubyte GLubyte w
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
GLfloat GLfloat GLfloat GLfloat h

◆ SDL_GetWindowSurface()

SDL_Surface* SDL_GetWindowSurface ( SDL_Window window)

Get the SDL surface associated with the window.

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

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

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

Definition at line 2158 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.

2159 {
2160  CHECK_WINDOW_MAGIC(window, NULL);
2161 
2162  if (!window->surface_valid) {
2163  if (window->surface) {
2164  window->surface->flags &= ~SDL_DONTFREE;
2165  SDL_FreeSurface(window->surface);
2166  }
2167  window->surface = SDL_CreateWindowFramebuffer(window);
2168  if (window->surface) {
2169  window->surface_valid = SDL_TRUE;
2170  window->surface->flags |= SDL_DONTFREE;
2171  }
2172  }
2173  return window->surface;
2174 }
#define SDL_DONTFREE
Definition: SDL_surface.h:55
Uint32 flags
Definition: SDL_surface.h:71
#define SDL_FreeSurface
#define NULL
Definition: begin_code.h:143
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
SDL_bool surface_valid
Definition: SDL_sysvideo.h:96
SDL_Surface * surface
Definition: SDL_sysvideo.h:95
static SDL_Surface * SDL_CreateWindowFramebuffer(SDL_Window *window)
Definition: SDL_video.c:2134

◆ SDL_GetWindowTitle()

const char* SDL_GetWindowTitle ( SDL_Window window)

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

See also
SDL_SetWindowTitle()

Definition at line 1636 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, and SDL_Window::title.

1637 {
1638  CHECK_WINDOW_MAGIC(window, "");
1639 
1640  return window->title ? window->title : "";
1641 }
char * title
Definition: SDL_sysvideo.h:75
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120

◆ SDL_GL_CreateContext()

SDL_GLContext SDL_GL_CreateContext ( SDL_Window window)

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

See also
SDL_GL_DeleteContext()

Definition at line 3266 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, SDL_WINDOW_OPENGL, and window.

Referenced by ShouldUseTextureFramebuffer().

3267 {
3268  SDL_GLContext ctx = NULL;
3269  CHECK_WINDOW_MAGIC(window, NULL);
3270 
3271  if (!(window->flags & SDL_WINDOW_OPENGL)) {
3272  SDL_SetError("The specified window isn't an OpenGL window");
3273  return NULL;
3274  }
3275 
3276  ctx = _this->GL_CreateContext(_this, window);
3277 
3278  /* Creating a context is assumed to make it current in the SDL driver. */
3279  if (ctx) {
3281  _this->current_glctx = ctx;
3284  }
3285  return ctx;
3286 }
#define SDL_TLSSet
SDL_TLSID current_glwin_tls
Definition: SDL_sysvideo.h:340
static SDL_Window * window
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
void * SDL_GLContext
An opaque handle to an OpenGL context.
Definition: SDL_video.h:172
SDL_GLContext current_glctx
Definition: SDL_sysvideo.h:339
SDL_GLContext(* GL_CreateContext)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:250
#define NULL
Definition: begin_code.h:143
#define SDL_SetError
SDL_TLSID current_glctx_tls
Definition: SDL_sysvideo.h:341
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
Uint32 flags
Definition: SDL_sysvideo.h:81
SDL_Window * current_glwin
Definition: SDL_sysvideo.h:338

◆ SDL_GL_DeleteContext()

void SDL_GL_DeleteContext ( SDL_GLContext  context)

Delete an OpenGL context.

See also
SDL_GL_CreateContext()

Definition at line 3397 of file SDL_video.c.

References SDL_PixelFormat::Amask, SDL_PixelFormat::BytesPerPixel, SDL_Surface::flags, SDL_Surface::format, SDL_VideoDevice::GL_DeleteContext, SDL_Surface::h, NULL, SDL_Surface::pitch, SDL_Surface::pixels, SDL_free(), SDL_GL_GetCurrentContext(), SDL_GL_MakeCurrent(), SDL_malloc, SDL_memset, and SDL_Surface::w.

Referenced by ShouldUseTextureFramebuffer().

3398 {
3399  if (!_this || !context) {
3400  return;
3401  }
3402 
3403  if (SDL_GL_GetCurrentContext() == context) {
3405  }
3406 
3407  _this->GL_DeleteContext(_this, context);
3408 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
int SDL_GL_MakeCurrent(SDL_Window *window, SDL_GLContext ctx)
Set up an OpenGL context for rendering into an OpenGL window.
Definition: SDL_video.c:3289
#define NULL
Definition: begin_code.h:143
SDL_GLContext SDL_GL_GetCurrentContext(void)
Get the currently active OpenGL context.
Definition: SDL_video.c:3330
void(* GL_DeleteContext)(_THIS, SDL_GLContext context)
Definition: SDL_sysvideo.h:256

◆ SDL_GL_ExtensionSupported()

SDL_bool SDL_GL_ExtensionSupported ( const char *  extension)

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

Definition at line 2787 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.

2788 {
2789 #if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
2790  const GLubyte *(APIENTRY * glGetStringFunc) (GLenum);
2791  const char *extensions;
2792  const char *start;
2793  const char *where, *terminator;
2794 
2795  /* Extension names should not have spaces. */
2796  where = SDL_strchr(extension, ' ');
2797  if (where || *extension == '\0') {
2798  return SDL_FALSE;
2799  }
2800  /* See if there's an environment variable override */
2801  start = SDL_getenv(extension);
2802  if (start && *start == '0') {
2803  return SDL_FALSE;
2804  }
2805 
2806  /* Lookup the available extensions */
2807 
2808  glGetStringFunc = SDL_GL_GetProcAddress("glGetString");
2809  if (!glGetStringFunc) {
2810  return SDL_FALSE;
2811  }
2812 
2813  if (isAtLeastGL3((const char *) glGetStringFunc(GL_VERSION))) {
2814  const GLubyte *(APIENTRY * glGetStringiFunc) (GLenum, GLuint);
2815  void (APIENTRY * glGetIntegervFunc) (GLenum pname, GLint * params);
2816  GLint num_exts = 0;
2817  GLint i;
2818 
2819  glGetStringiFunc = SDL_GL_GetProcAddress("glGetStringi");
2820  glGetIntegervFunc = SDL_GL_GetProcAddress("glGetIntegerv");
2821  if ((!glGetStringiFunc) || (!glGetIntegervFunc)) {
2822  return SDL_FALSE;
2823  }
2824 
2825  #ifndef GL_NUM_EXTENSIONS
2826  #define GL_NUM_EXTENSIONS 0x821D
2827  #endif
2828  glGetIntegervFunc(GL_NUM_EXTENSIONS, &num_exts);
2829  for (i = 0; i < num_exts; i++) {
2830  const char *thisext = (const char *) glGetStringiFunc(GL_EXTENSIONS, i);
2831  if (SDL_strcmp(thisext, extension) == 0) {
2832  return SDL_TRUE;
2833  }
2834  }
2835 
2836  return SDL_FALSE;
2837  }
2838 
2839  /* Try the old way with glGetString(GL_EXTENSIONS) ... */
2840 
2841  extensions = (const char *) glGetStringFunc(GL_EXTENSIONS);
2842  if (!extensions) {
2843  return SDL_FALSE;
2844  }
2845  /*
2846  * It takes a bit of care to be fool-proof about parsing the OpenGL
2847  * extensions string. Don't be fooled by sub-strings, etc.
2848  */
2849 
2850  start = extensions;
2851 
2852  for (;;) {
2853  where = SDL_strstr(start, extension);
2854  if (!where)
2855  break;
2856 
2857  terminator = where + SDL_strlen(extension);
2858  if (where == start || *(where - 1) == ' ')
2859  if (*terminator == ' ' || *terminator == '\0')
2860  return SDL_TRUE;
2861 
2862  start = terminator;
2863  }
2864  return SDL_FALSE;
2865 #else
2866  return SDL_FALSE;
2867 #endif
2868 }
#define APIENTRY
Definition: SDL_opengl.h:132
int GLint
Definition: SDL_opengl.h:175
#define GL_EXTENSIONS
Definition: SDL_opengl.h:709
GLuint start
Definition: SDL_opengl.h:1564
#define GL_VERSION
Definition: SDL_opengl.h:708
#define SDL_strchr
#define GL_NUM_EXTENSIONS
static SDL_INLINE SDL_bool isAtLeastGL3(const char *verstr)
Definition: SDL_video.c:2781
const GLfloat * params
unsigned char GLubyte
Definition: SDL_opengl.h:176
#define SDL_getenv
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
unsigned int GLenum
Definition: SDL_opengl.h:169
GLenum pname
unsigned int GLuint
Definition: SDL_opengl.h:178
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 void
#define SDL_strlen
void * SDL_GL_GetProcAddress(const char *proc)
Get the address of an OpenGL function.
Definition: SDL_video.c:2742
#define SDL_strcmp
#define SDL_strstr

◆ SDL_GL_GetAttribute()

int SDL_GL_GetAttribute ( SDL_GLattr  attr,
int *  value 
)

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

Definition at line 3030 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::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_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_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_SetError, SDL_Unsupported, SDL_VideoDevice::share_with_current_context, and void.

3031 {
3032 #if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
3033  GLenum (APIENTRY *glGetErrorFunc) (void);
3034  GLenum attrib = 0;
3035  GLenum error = 0;
3036 
3037  /*
3038  * Some queries in Core Profile desktop OpenGL 3+ contexts require
3039  * glGetFramebufferAttachmentParameteriv instead of glGetIntegerv. Note that
3040  * the enums we use for the former function don't exist in OpenGL ES 2, and
3041  * the function itself doesn't exist prior to OpenGL 3 and OpenGL ES 2.
3042  */
3043 #if SDL_VIDEO_OPENGL
3044  const GLubyte *(APIENTRY *glGetStringFunc) (GLenum name);
3045  void (APIENTRY *glGetFramebufferAttachmentParameterivFunc) (GLenum target, GLenum attachment, GLenum pname, GLint* params);
3046  GLenum attachment = GL_BACK_LEFT;
3047  GLenum attachmentattrib = 0;
3048 #endif
3049 
3050  /* Clear value in any case */
3051  *value = 0;
3052 
3053  switch (attr) {
3054  case SDL_GL_RED_SIZE:
3055 #if SDL_VIDEO_OPENGL
3056  attachmentattrib = GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE;
3057 #endif
3058  attrib = GL_RED_BITS;
3059  break;
3060  case SDL_GL_BLUE_SIZE:
3061 #if SDL_VIDEO_OPENGL
3062  attachmentattrib = GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE;
3063 #endif
3064  attrib = GL_BLUE_BITS;
3065  break;
3066  case SDL_GL_GREEN_SIZE:
3067 #if SDL_VIDEO_OPENGL
3068  attachmentattrib = GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE;
3069 #endif
3070  attrib = GL_GREEN_BITS;
3071  break;
3072  case SDL_GL_ALPHA_SIZE:
3073 #if SDL_VIDEO_OPENGL
3074  attachmentattrib = GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE;
3075 #endif
3076  attrib = GL_ALPHA_BITS;
3077  break;
3078  case SDL_GL_DOUBLEBUFFER:
3079 #if SDL_VIDEO_OPENGL
3080  attrib = GL_DOUBLEBUFFER;
3081  break;
3082 #else
3083  /* OpenGL ES 1.0 and above specifications have EGL_SINGLE_BUFFER */
3084  /* parameter which switches double buffer to single buffer. OpenGL ES */
3085  /* SDL driver must set proper value after initialization */
3087  return 0;
3088 #endif
3089  case SDL_GL_DEPTH_SIZE:
3090 #if SDL_VIDEO_OPENGL
3091  attachment = GL_DEPTH;
3092  attachmentattrib = GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE;
3093 #endif
3094  attrib = GL_DEPTH_BITS;
3095  break;
3096  case SDL_GL_STENCIL_SIZE:
3097 #if SDL_VIDEO_OPENGL
3098  attachment = GL_STENCIL;
3099  attachmentattrib = GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE;
3100 #endif
3101  attrib = GL_STENCIL_BITS;
3102  break;
3103 #if SDL_VIDEO_OPENGL
3104  case SDL_GL_ACCUM_RED_SIZE:
3105  attrib = GL_ACCUM_RED_BITS;
3106  break;
3108  attrib = GL_ACCUM_GREEN_BITS;
3109  break;
3111  attrib = GL_ACCUM_BLUE_BITS;
3112  break;
3114  attrib = GL_ACCUM_ALPHA_BITS;
3115  break;
3116  case SDL_GL_STEREO:
3117  attrib = GL_STEREO;
3118  break;
3119 #else
3120  case SDL_GL_ACCUM_RED_SIZE:
3124  case SDL_GL_STEREO:
3125  /* none of these are supported in OpenGL ES */
3126  *value = 0;
3127  return 0;
3128 #endif
3130  attrib = GL_SAMPLE_BUFFERS;
3131  break;
3133  attrib = GL_SAMPLES;
3134  break;
3136 #if SDL_VIDEO_OPENGL
3137  attrib = GL_CONTEXT_RELEASE_BEHAVIOR;
3138 #else
3140 #endif
3141  break;
3142  case SDL_GL_BUFFER_SIZE:
3143  {
3144  int rsize = 0, gsize = 0, bsize = 0, asize = 0;
3145 
3146  /* There doesn't seem to be a single flag in OpenGL for this! */
3147  if (SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &rsize) < 0) {
3148  return -1;
3149  }
3150  if (SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &gsize) < 0) {
3151  return -1;
3152  }
3153  if (SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &bsize) < 0) {
3154  return -1;
3155  }
3156  if (SDL_GL_GetAttribute(SDL_GL_ALPHA_SIZE, &asize) < 0) {
3157  return -1;
3158  }
3159 
3160  *value = rsize + gsize + bsize + asize;
3161  return 0;
3162  }
3164  {
3165  /* FIXME: How do we get this information? */
3166  *value = (_this->gl_config.accelerated != 0);
3167  return 0;
3168  }
3170  {
3172  return 0;
3173  }
3175  {
3177  return 0;
3178  }
3180  {
3182  return 0;
3183  }
3184  case SDL_GL_CONTEXT_EGL:
3185  /* FIXME: SDL_GL_CONTEXT_EGL to be deprecated in SDL 2.1 */
3186  {
3188  *value = 1;
3189  }
3190  else {
3191  *value = 0;
3192  }
3193  return 0;
3194  }
3195  case SDL_GL_CONTEXT_FLAGS:
3196  {
3197  *value = _this->gl_config.flags;
3198  return 0;
3199  }
3201  {
3203  return 0;
3204  }
3206  {
3208  return 0;
3209  }
3211  {
3213  return 0;
3214  }
3215  default:
3216  return SDL_SetError("Unknown OpenGL attribute");
3217  }
3218 
3219 #if SDL_VIDEO_OPENGL
3220  glGetStringFunc = SDL_GL_GetProcAddress("glGetString");
3221  if (!glGetStringFunc) {
3222  return SDL_SetError("Failed getting OpenGL glGetString entry point");
3223  }
3224 
3225  if (attachmentattrib && isAtLeastGL3((const char *) glGetStringFunc(GL_VERSION))) {
3226  glGetFramebufferAttachmentParameterivFunc = SDL_GL_GetProcAddress("glGetFramebufferAttachmentParameteriv");
3227 
3228  if (glGetFramebufferAttachmentParameterivFunc) {
3229  glGetFramebufferAttachmentParameterivFunc(GL_FRAMEBUFFER, attachment, attachmentattrib, (GLint *) value);
3230  } else {
3231  return SDL_SetError("Failed getting OpenGL glGetFramebufferAttachmentParameteriv entry point");
3232  }
3233  } else
3234 #endif
3235  {
3236  void (APIENTRY *glGetIntegervFunc) (GLenum pname, GLint * params);
3237  glGetIntegervFunc = SDL_GL_GetProcAddress("glGetIntegerv");
3238  if (glGetIntegervFunc) {
3239  glGetIntegervFunc(attrib, (GLint *) value);
3240  } else {
3241  return SDL_SetError("Failed getting OpenGL glGetIntegerv entry point");
3242  }
3243  }
3244 
3245  glGetErrorFunc = SDL_GL_GetProcAddress("glGetError");
3246  if (!glGetErrorFunc) {
3247  return SDL_SetError("Failed getting OpenGL glGetError entry point");
3248  }
3249 
3250  error = glGetErrorFunc();
3251  if (error != GL_NO_ERROR) {
3252  if (error == GL_INVALID_ENUM) {
3253  return SDL_SetError("OpenGL error: GL_INVALID_ENUM");
3254  } else if (error == GL_INVALID_VALUE) {
3255  return SDL_SetError("OpenGL error: GL_INVALID_VALUE");
3256  }
3257  return SDL_SetError("OpenGL error: %08X", error);
3258  }
3259  return 0;
3260 #else
3261  return SDL_Unsupported();
3262 #endif /* SDL_VIDEO_OPENGL */
3263 }
#define GL_STENCIL_BITS
Definition: SDL_opengl.h:467
#define GL_INVALID_ENUM
Definition: SDL_opengl.h:713
#define GL_SAMPLE_BUFFERS
Definition: SDL_opengl.h:1832
#define GL_BACK_LEFT
Definition: SDL_opengl.h:492
#define GL_CONTEXT_RELEASE_BEHAVIOR_KHR
Definition: SDL_video.c:50
#define GL_DOUBLEBUFFER
Definition: SDL_opengl.h:514
#define APIENTRY
Definition: SDL_opengl.h:132
#define GL_RED_BITS
Definition: SDL_opengl.h:506
int GLint
Definition: SDL_opengl.h:175
#define GL_CONTEXT_RELEASE_BEHAVIOR
#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE
#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE
#define GL_SAMPLES
Definition: SDL_opengl.h:1833
#define GL_DEPTH_BITS
Definition: SDL_opengl.h:321
GLuint const GLchar * name
#define GL_VERSION
Definition: SDL_opengl.h:708
#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE
#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE
#define GL_ACCUM_ALPHA_BITS
Definition: SDL_opengl.h:376
#define GL_FRAMEBUFFER
#define GL_NO_ERROR
Definition: SDL_opengl.h:712
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
#define GL_BLUE_BITS
Definition: SDL_opengl.h:508
static SDL_INLINE SDL_bool isAtLeastGL3(const char *verstr)
Definition: SDL_video.c:2781
const GLfloat * params
#define GL_STENCIL
Definition: SDL_opengl.h:519
GLsizei const GLfloat * value
#define GL_ALPHA_BITS
Definition: SDL_opengl.h:505
GLenum target
#define GL_DEPTH
Definition: SDL_opengl.h:518
#define GL_ACCUM_RED_BITS
Definition: SDL_opengl.h:373
#define GL_INVALID_VALUE
Definition: SDL_opengl.h:714
int framebuffer_srgb_capable
Definition: SDL_sysvideo.h:326
unsigned char GLubyte
Definition: SDL_opengl.h:176
#define GL_ACCUM_GREEN_BITS
Definition: SDL_opengl.h:374
#define GL_STEREO
Definition: SDL_opengl.h:515
int share_with_current_context
Definition: SDL_sysvideo.h:324
unsigned int GLenum
Definition: SDL_opengl.h:169
GLenum pname
#define SDL_SetError
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 void
#define GL_ACCUM_BLUE_BITS
Definition: SDL_opengl.h:375
GLenum attachment
struct SDL_VideoDevice::@28 gl_config
void * SDL_GL_GetProcAddress(const char *proc)
Get the address of an OpenGL function.
Definition: SDL_video.c:2742
#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE
int SDL_GL_GetAttribute(SDL_GLattr attr, int *value)
Get the actual value for an attribute from the current context.
Definition: SDL_video.c:3030
#define GL_GREEN_BITS
Definition: SDL_opengl.h:507
#define SDL_Unsupported()
Definition: SDL_error.h:53
#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE

◆ SDL_GL_GetCurrentContext()

SDL_GLContext SDL_GL_GetCurrentContext ( void  )

Get the currently active OpenGL context.

Definition at line 3330 of file SDL_video.c.

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

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

3331 {
3332  if (!_this) {
3334  return NULL;
3335  }
3337 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
void * SDL_GLContext
An opaque handle to an OpenGL context.
Definition: SDL_video.h:172
#define SDL_TLSGet
#define NULL
Definition: begin_code.h:143
SDL_TLSID current_glctx_tls
Definition: SDL_sysvideo.h:341
static int SDL_UninitializedVideo()
Definition: SDL_video.c:425

◆ SDL_GL_GetCurrentWindow()

SDL_Window* SDL_GL_GetCurrentWindow ( void  )

Get the currently active OpenGL window.

Definition at line 3320 of file SDL_video.c.

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

Referenced by SDL_GL_MakeCurrent(), and SDL_GL_SwapWindow().

3321 {
3322  if (!_this) {
3324  return NULL;
3325  }
3327 }
SDL_TLSID current_glwin_tls
Definition: SDL_sysvideo.h:340
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
#define SDL_TLSGet
#define NULL
Definition: begin_code.h:143
The type used to identify a window.
Definition: SDL_sysvideo.h:71
static int SDL_UninitializedVideo()
Definition: SDL_video.c:425

◆ SDL_GL_GetDrawableSize()

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

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

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

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

See also
SDL_GetWindowSize()
SDL_CreateWindow()

Definition at line 3339 of file SDL_video.c.

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

3340 {
3341  CHECK_WINDOW_MAGIC(window,);
3342 
3343  if (_this->GL_GetDrawableSize) {
3344  _this->GL_GetDrawableSize(_this, window, w, h);
3345  } else {
3346  SDL_GetWindowSize(window, w, h);
3347  }
3348 }
void(* GL_GetDrawableSize)(_THIS, SDL_Window *window, int *w, int *h)
Definition: SDL_sysvideo.h:252
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
void SDL_GetWindowSize(SDL_Window *window, int *w, int *h)
Get the size of a window&#39;s client area.
Definition: SDL_video.c:1909
GLubyte GLubyte GLubyte GLubyte w
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
GLfloat GLfloat GLfloat GLfloat h

◆ SDL_GL_GetProcAddress()

void* SDL_GL_GetProcAddress ( const char *  proc)

Get the address of an OpenGL function.

Definition at line 2742 of file SDL_video.c.

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

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

2743 {
2744  void *func;
2745 
2746  if (!_this) {
2748  return NULL;
2749  }
2750  func = NULL;
2751  if (_this->GL_GetProcAddress) {
2752  if (_this->gl_config.driver_loaded) {
2753  func = _this->GL_GetProcAddress(_this, proc);
2754  } else {
2755  SDL_SetError("No GL driver has been loaded");
2756  }
2757  } else {
2758  SDL_SetError("No dynamic GL support in video driver");
2759  }
2760  return func;
2761 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
#define NULL
Definition: begin_code.h:143
#define SDL_SetError
GLenum func
static int SDL_UninitializedVideo()
Definition: SDL_video.c:425
struct SDL_VideoDevice::@28 gl_config
void *(* GL_GetProcAddress)(_THIS, const char *proc)
Definition: SDL_sysvideo.h:248

◆ SDL_GL_GetSwapInterval()

int SDL_GL_GetSwapInterval ( void  )

Get the swap interval for the current OpenGL context.

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

Definition at line 3365 of file SDL_video.c.

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

3366 {
3367  if (!_this) {
3368  return 0;
3369  } else if (SDL_GL_GetCurrentContext() == NULL) {
3370  return 0;
3371  } else if (_this->GL_GetSwapInterval) {
3372  return _this->GL_GetSwapInterval(_this);
3373  } else {
3374  return 0;
3375  }
3376 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
#define NULL
Definition: begin_code.h:143
SDL_GLContext SDL_GL_GetCurrentContext(void)
Get the currently active OpenGL context.
Definition: SDL_video.c:3330
int(* GL_GetSwapInterval)(_THIS)
Definition: SDL_sysvideo.h:254

◆ SDL_GL_LoadLibrary()

int SDL_GL_LoadLibrary ( const char *  path)

Dynamically load an OpenGL library.

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

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

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

Definition at line 2713 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, retval, SDL_SetError, SDL_strcmp, and SDL_UninitializedVideo().

Referenced by SDL_CreateWindow(), and SDL_RecreateWindow().

2714 {
2715  int retval;
2716 
2717  if (!_this) {
2718  return SDL_UninitializedVideo();
2719  }
2720  if (_this->gl_config.driver_loaded) {
2721  if (path && SDL_strcmp(path, _this->gl_config.driver_path) != 0) {
2722  return SDL_SetError("OpenGL library already loaded");
2723  }
2724  retval = 0;
2725  } else {
2726  if (!_this->GL_LoadLibrary) {
2727  return SDL_SetError("No dynamic GL support in video driver");
2728  }
2729  retval = _this->GL_LoadLibrary(_this, path);
2730  }
2731  if (retval == 0) {
2733  } else {
2734  if (_this->GL_UnloadLibrary) {
2736  }
2737  }
2738  return (retval);
2739 }
int(* GL_LoadLibrary)(_THIS, const char *path)
Definition: SDL_sysvideo.h:247
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
SDL_bool retval
char driver_path[256]
Definition: SDL_sysvideo.h:329
void(* GL_UnloadLibrary)(_THIS)
Definition: SDL_sysvideo.h:249
#define SDL_SetError
static int SDL_UninitializedVideo()
Definition: SDL_video.c:425
struct SDL_VideoDevice::@28 gl_config
GLsizei const GLchar *const * path
#define SDL_strcmp

◆ SDL_GL_MakeCurrent()

int SDL_GL_MakeCurrent ( SDL_Window window,
SDL_GLContext  context 
)

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

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

Definition at line 3289 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, SDL_WINDOW_OPENGL, and window.

Referenced by SDL_DestroyWindow(), and SDL_GL_DeleteContext().

3290 {
3291  int retval;
3292 
3293  if (window == SDL_GL_GetCurrentWindow() &&
3294  ctx == SDL_GL_GetCurrentContext()) {
3295  /* We're already current. */
3296  return 0;
3297  }
3298 
3299  if (!ctx) {
3300  window = NULL;
3301  } else {
3302  CHECK_WINDOW_MAGIC(window, -1);
3303 
3304  if (!(window->flags & SDL_WINDOW_OPENGL)) {
3305  return SDL_SetError("The specified window isn't an OpenGL window");
3306  }
3307  }
3308 
3309  retval = _this->GL_MakeCurrent(_this, window, ctx);
3310  if (retval == 0) {
3312  _this->current_glctx = ctx;
3315  }
3316  return retval;
3317 }
#define SDL_TLSSet
SDL_TLSID current_glwin_tls
Definition: SDL_sysvideo.h:340
static SDL_Window * window
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
SDL_bool retval
SDL_GLContext current_glctx
Definition: SDL_sysvideo.h:339
int(* GL_MakeCurrent)(_THIS, SDL_Window *window, SDL_GLContext context)
Definition: SDL_sysvideo.h:251
#define NULL
Definition: begin_code.h:143
#define SDL_SetError
SDL_TLSID current_glctx_tls
Definition: SDL_sysvideo.h:341
SDL_GLContext SDL_GL_GetCurrentContext(void)
Get the currently active OpenGL context.
Definition: SDL_video.c:3330
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
Uint32 flags
Definition: SDL_sysvideo.h:81
SDL_Window * SDL_GL_GetCurrentWindow(void)
Get the currently active OpenGL window.
Definition: SDL_video.c:3320
SDL_Window * current_glwin
Definition: SDL_sysvideo.h:338

◆ SDL_GL_ResetAttributes()

void SDL_GL_ResetAttributes ( void  )

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

Definition at line 2871 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::profile_mask, SDL_VideoDevice::red_size, SDL_VideoDevice::release_behavior, SDL_VideoDevice::retained_backing, SDL_GL_CONTEXT_PROFILE_ES, SDL_GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH, SDL_VideoDevice::share_with_current_context, SDL_VideoDevice::stencil_size, and SDL_VideoDevice::stereo.

Referenced by SDL_VideoInit().

2872 {
2873  if (!_this) {
2874  return;
2875  }
2876 
2877  _this->gl_config.red_size = 3;
2878  _this->gl_config.green_size = 3;
2879  _this->gl_config.blue_size = 2;
2880  _this->gl_config.alpha_size = 0;
2882  _this->gl_config.depth_size = 16;
2889  _this->gl_config.stereo = 0;
2893  _this->gl_config.accelerated = -1; /* accelerated or not, both are fine */
2895 #if SDL_VIDEO_OPENGL
2898 #elif SDL_VIDEO_OPENGL_ES2
2902 #elif SDL_VIDEO_OPENGL_ES
2906 #endif
2907  _this->gl_config.flags = 0;
2910 
2912 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
int framebuffer_srgb_capable
Definition: SDL_sysvideo.h:326
int share_with_current_context
Definition: SDL_sysvideo.h:324
struct SDL_VideoDevice::@28 gl_config

◆ SDL_GL_SetAttribute()

int SDL_GL_SetAttribute ( SDL_GLattr  attr,
int  value 
)

Set an OpenGL window attribute before window creation.

Definition at line 2915 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::profile_mask, SDL_VideoDevice::red_size, SDL_VideoDevice::release_behavior, 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_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_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_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.

2916 {
2917 #if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
2918  int retval;
2919 
2920  if (!_this) {
2921  return SDL_UninitializedVideo();
2922  }
2923  retval = 0;
2924  switch (attr) {
2925  case SDL_GL_RED_SIZE:
2927  break;
2928  case SDL_GL_GREEN_SIZE:
2930  break;
2931  case SDL_GL_BLUE_SIZE:
2933  break;
2934  case SDL_GL_ALPHA_SIZE:
2936  break;
2937  case SDL_GL_DOUBLEBUFFER:
2939  break;
2940  case SDL_GL_BUFFER_SIZE:
2942  break;
2943  case SDL_GL_DEPTH_SIZE:
2945  break;
2946  case SDL_GL_STENCIL_SIZE:
2948  break;
2949  case SDL_GL_ACCUM_RED_SIZE:
2951  break;
2954  break;
2957  break;
2960  break;
2961  case SDL_GL_STEREO:
2963  break;
2966  break;
2969  break;
2972  break;
2975  break;
2978  break;
2981  break;
2982  case SDL_GL_CONTEXT_EGL:
2983  /* FIXME: SDL_GL_CONTEXT_EGL to be deprecated in SDL 2.1 */
2984  if (value != 0) {
2986  } else {
2988  };
2989  break;
2990  case SDL_GL_CONTEXT_FLAGS:
2995  retval = SDL_SetError("Unknown OpenGL context flag %d", value);
2996  break;
2997  }
2999  break;
3001  if (value != 0 &&
3005  retval = SDL_SetError("Unknown OpenGL context profile %d", value);
3006  break;
3007  }
3009  break;
3012  break;
3015  break;
3018  break;
3019  default:
3020  retval = SDL_SetError("Unknown OpenGL attribute");
3021  break;
3022  }
3023  return retval;
3024 #else
3025  return SDL_Unsupported();
3026 #endif /* SDL_VIDEO_OPENGL */
3027 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
SDL_bool retval
GLsizei const GLfloat * value
int framebuffer_srgb_capable
Definition: SDL_sysvideo.h:326
int share_with_current_context
Definition: SDL_sysvideo.h:324
#define SDL_SetError
int SDL_GL_SetAttribute(SDL_GLattr attr, int value)
Set an OpenGL window attribute before window creation.
Definition: SDL_video.c:2915
static int SDL_UninitializedVideo()
Definition: SDL_video.c:425
struct SDL_VideoDevice::@28 gl_config
#define SDL_Unsupported()
Definition: SDL_error.h:53

◆ SDL_GL_SetSwapInterval()

int SDL_GL_SetSwapInterval ( int  interval)

Set the swap interval for the current OpenGL context.

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

Definition at line 3351 of file SDL_video.c.

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

3352 {
3353  if (!_this) {
3354  return SDL_UninitializedVideo();
3355  } else if (SDL_GL_GetCurrentContext() == NULL) {
3356  return SDL_SetError("No OpenGL context has been made current");
3357  } else if (_this->GL_SetSwapInterval) {
3358  return _this->GL_SetSwapInterval(_this, interval);
3359  } else {
3360  return SDL_SetError("Setting the swap interval is not supported");
3361  }
3362 }
int(* GL_SetSwapInterval)(_THIS, int interval)
Definition: SDL_sysvideo.h:253
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
#define NULL
Definition: begin_code.h:143
#define SDL_SetError
SDL_GLContext SDL_GL_GetCurrentContext(void)
Get the currently active OpenGL context.
Definition: SDL_video.c:3330
static int SDL_UninitializedVideo()
Definition: SDL_video.c:425

◆ SDL_GL_SwapWindow()

void SDL_GL_SwapWindow ( SDL_Window window)

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

Definition at line 3379 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.

3380 {
3381  CHECK_WINDOW_MAGIC(window,);
3382 
3383  if (!(window->flags & SDL_WINDOW_OPENGL)) {
3384  SDL_SetError("The specified window isn't an OpenGL window");
3385  return;
3386  }
3387 
3388  if (SDL_GL_GetCurrentWindow() != window) {
3389  SDL_SetError("The specified window has not been made current");
3390  return;
3391  }
3392 
3393  _this->GL_SwapWindow(_this, window);
3394 }
void(* GL_SwapWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:255
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
#define SDL_SetError
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
Uint32 flags
Definition: SDL_sysvideo.h:81
SDL_Window * SDL_GL_GetCurrentWindow(void)
Get the currently active OpenGL window.
Definition: SDL_video.c:3320

◆ SDL_GL_UnloadLibrary()

void SDL_GL_UnloadLibrary ( void  )

Unload the OpenGL library previously loaded by SDL_GL_LoadLibrary().

See also
SDL_GL_LoadLibrary()

Definition at line 2764 of file SDL_video.c.

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

Referenced by SDL_DestroyWindow(), and SDL_RecreateWindow().

2765 {
2766  if (!_this) {
2768  return;
2769  }
2770  if (_this->gl_config.driver_loaded > 0) {
2771  if (--_this->gl_config.driver_loaded > 0) {
2772  return;
2773  }
2774  if (_this->GL_UnloadLibrary) {
2776  }
2777  }
2778 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
void(* GL_UnloadLibrary)(_THIS)
Definition: SDL_sysvideo.h:249
static int SDL_UninitializedVideo()
Definition: SDL_video.c:425
struct SDL_VideoDevice::@28 gl_config

◆ SDL_HideWindow()

void SDL_HideWindow ( SDL_Window window)

Hide a window.

See also
SDL_ShowWindow()

Definition at line 2030 of file SDL_video.c.

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

Referenced by SDL_DestroyWindow(), and SDL_RecreateWindow().

2031 {
2032  CHECK_WINDOW_MAGIC(window,);
2033 
2034  if (!(window->flags & SDL_WINDOW_SHOWN)) {
2035  return;
2036  }
2037 
2038  window->is_hiding = SDL_TRUE;
2040 
2041  if (_this->HideWindow) {
2042  _this->HideWindow(_this, window);
2043  }
2044  window->is_hiding = SDL_FALSE;
2046 }
int SDL_SendWindowEvent(SDL_Window *window, Uint8 windowevent, int data1, int data2)
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
void(* HideWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:216
static int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen)
Definition: SDL_video.c:1152
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
Uint32 flags
Definition: SDL_sysvideo.h:81
SDL_bool is_hiding
Definition: SDL_sysvideo.h:98

◆ SDL_IsScreenSaverEnabled()

SDL_bool SDL_IsScreenSaverEnabled ( void  )

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

See also
SDL_EnableScreenSaver()
SDL_DisableScreenSaver()

Definition at line 2624 of file SDL_video.c.

References SDL_FALSE, SDL_TRUE, and SDL_VideoDevice::suspend_screensaver.

2625 {
2626  if (!_this) {
2627  return SDL_TRUE;
2628  }
2630 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
SDL_bool suspend_screensaver
Definition: SDL_sysvideo.h:291

◆ SDL_MaximizeWindow()

void SDL_MaximizeWindow ( SDL_Window window)

Make a window as large as possible.

See also
SDL_RestoreWindow()

Definition at line 2062 of file SDL_video.c.

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

Referenced by SDL_FinishWindowCreation().

2063 {
2064  CHECK_WINDOW_MAGIC(window,);
2065 
2066  if (window->flags & SDL_WINDOW_MAXIMIZED) {
2067  return;
2068  }
2069 
2070  /* !!! FIXME: should this check if the window is resizable? */
2071 
2072  if (_this->MaximizeWindow) {
2073  _this->MaximizeWindow(_this, window);
2074  }
2075 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
void(* MaximizeWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:218
Uint32 flags
Definition: SDL_sysvideo.h:81

◆ SDL_MinimizeWindow()

void SDL_MinimizeWindow ( SDL_Window window)

Minimize a window to an iconic representation.

See also
SDL_RestoreWindow()

Definition at line 2078 of file SDL_video.c.

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

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

2079 {
2080  CHECK_WINDOW_MAGIC(window,);
2081 
2082  if (window->flags & SDL_WINDOW_MINIMIZED) {
2083  return;
2084  }
2085 
2087 
2088  if (_this->MinimizeWindow) {
2089  _this->MinimizeWindow(_this, window);
2090  }
2091 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
static int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen)
Definition: SDL_video.c:1152
void(* MinimizeWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:219
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
Uint32 flags
Definition: SDL_sysvideo.h:81

◆ SDL_RaiseWindow()

void SDL_RaiseWindow ( SDL_Window window)

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

Definition at line 2049 of file SDL_video.c.

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

Referenced by SDL_ShowMessageBox().

2050 {
2051  CHECK_WINDOW_MAGIC(window,);
2052 
2053  if (!(window->flags & SDL_WINDOW_SHOWN)) {
2054  return;
2055  }
2056  if (_this->RaiseWindow) {
2057  _this->RaiseWindow(_this, window);
2058  }
2059 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
void(* RaiseWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:217
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
Uint32 flags
Definition: SDL_sysvideo.h:81

◆ SDL_RestoreWindow()

void SDL_RestoreWindow ( SDL_Window window)

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

See also
SDL_MaximizeWindow()
SDL_MinimizeWindow()

Definition at line 2094 of file SDL_video.c.

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

2095 {
2096  CHECK_WINDOW_MAGIC(window,);
2097 
2098  if (!(window->flags & (SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED))) {
2099  return;
2100  }
2101 
2102  if (_this->RestoreWindow) {
2103  _this->RestoreWindow(_this, window);
2104  }
2105 }
void(* RestoreWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:220
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
Uint32 flags
Definition: SDL_sysvideo.h:81

◆ SDL_SetWindowBordered()

void SDL_SetWindowBordered ( SDL_Window window,
SDL_bool  bordered 
)

Set the border state of a window.

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

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

Definition at line 1821 of file SDL_video.c.

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

1822 {
1823  CHECK_WINDOW_MAGIC(window,);
1824  if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
1825  const int want = (bordered != SDL_FALSE); /* normalize the flag. */
1826  const int have = ((window->flags & SDL_WINDOW_BORDERLESS) == 0);
1827  if ((want != have) && (_this->SetWindowBordered)) {
1828  if (want) {
1829  window->flags &= ~SDL_WINDOW_BORDERLESS;
1830  } else {
1831  window->flags |= SDL_WINDOW_BORDERLESS;
1832  }
1833  _this->SetWindowBordered(_this, window, (SDL_bool) want);
1834  }
1835  }
1836 }
void(* SetWindowBordered)(_THIS, SDL_Window *window, SDL_bool bordered)
Definition: SDL_sysvideo.h:221
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
SDL_bool
Definition: SDL_stdinc.h:130
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
Uint32 flags
Definition: SDL_sysvideo.h:81

◆ SDL_SetWindowBrightness()

int SDL_SetWindowBrightness ( SDL_Window window,
float  brightness 
)

Set the brightness (gamma correction) for a window.

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

Definition at line 2204 of file SDL_video.c.

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

2205 {
2206  Uint16 ramp[256];
2207  int status;
2208 
2209  CHECK_WINDOW_MAGIC(window, -1);
2210 
2211  SDL_CalculateGammaRamp(brightness, ramp);
2212  status = SDL_SetWindowGammaRamp(window, ramp, ramp, ramp);
2213  if (status == 0) {
2214  window->brightness = brightness;
2215  }
2216  return status;
2217 }
int SDL_SetWindowGammaRamp(SDL_Window *window, const Uint16 *red, const Uint16 *green, const Uint16 *blue)
Set the gamma ramp for a window.
Definition: SDL_video.c:2290
float brightness
Definition: SDL_sysvideo.h:91
uint16_t Uint16
An unsigned 16-bit integer type.
Definition: SDL_stdinc.h:151
#define SDL_CalculateGammaRamp
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120

◆ SDL_SetWindowData()

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

Associate an arbitrary named pointer with a window.

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

Definition at line 1666 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.

Referenced by SDL_CreateWindowTexture(), and SDL_DestroyWindowTexture().

1667 {
1668  SDL_WindowUserData *prev, *data;
1669 
1670  CHECK_WINDOW_MAGIC(window, NULL);
1671 
1672  /* Input validation */
1673  if (name == NULL || name[0] == '\0') {
1674  SDL_InvalidParamError("name");
1675  return NULL;
1676  }
1677 
1678  /* See if the named data already exists */
1679  prev = NULL;
1680  for (data = window->data; data; prev = data, data = data->next) {
1681  if (data->name && SDL_strcmp(data->name, name) == 0) {
1682  void *last_value = data->data;
1683 
1684  if (userdata) {
1685  /* Set the new value */
1686  data->data = userdata;
1687  } else {
1688  /* Delete this value */
1689  if (prev) {
1690  prev->next = data->next;
1691  } else {
1692  window->data = data->next;
1693  }
1694  SDL_free(data->name);
1695  SDL_free(data);
1696  }
1697  return last_value;
1698  }
1699  }
1700 
1701  /* Add new data to the window */
1702  if (userdata) {
1703  data = (SDL_WindowUserData *)SDL_malloc(sizeof(*data));
1704  data->name = SDL_strdup(name);
1705  data->data = userdata;
1706  data->next = window->data;
1707  window->data = data;
1708  }
1709  return NULL;
1710 }
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: SDL_opengl.h:1967
GLuint const GLchar * name
#define SDL_InvalidParamError(param)
Definition: SDL_error.h:54
struct SDL_WindowUserData * next
Definition: SDL_sysvideo.h:67
void SDL_free(void *mem)
#define NULL
Definition: begin_code.h:143
#define SDL_strdup
#define SDL_malloc
#define SDL_strcmp
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
SDL_WindowUserData * data
Definition: SDL_sysvideo.h:107

◆ SDL_SetWindowDisplayMode()

int SDL_SetWindowDisplayMode ( SDL_Window window,
const SDL_DisplayMode mode 
)

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

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

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

Definition at line 1069 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.

1070 {
1071  CHECK_WINDOW_MAGIC(window, -1);
1072 
1073  if (mode) {
1074  window->fullscreen_mode = *mode;
1075  } else {
1076  SDL_zero(window->fullscreen_mode);
1077  }
1078 
1080  SDL_DisplayMode fullscreen_mode;
1081  if (SDL_GetWindowDisplayMode(window, &fullscreen_mode) == 0) {
1082  SDL_SetDisplayModeForDisplay(SDL_GetDisplayForWindow(window), &fullscreen_mode);
1083  }
1084  }
1085  return 0;
1086 }
SDL_DisplayMode fullscreen_mode
Definition: SDL_sysvideo.h:87
#define FULLSCREEN_VISIBLE(W)
Definition: SDL_sysvideo.h:114
The structure that defines a display mode.
Definition: SDL_video.h:53
int SDL_GetWindowDisplayMode(SDL_Window *window, SDL_DisplayMode *mode)
Fill in information about the display mode used when a fullscreen window is visible.
Definition: SDL_video.c:1089
SDL_VideoDisplay * SDL_GetDisplayForWindow(SDL_Window *window)
Definition: SDL_video.c:1058
GLenum mode
#define SDL_zero(x)
Definition: SDL_stdinc.h:359
static int SDL_SetDisplayModeForDisplay(SDL_VideoDisplay *display, const SDL_DisplayMode *mode)
Definition: SDL_video.c:949
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
Uint32 flags
Definition: SDL_sysvideo.h:81

◆ SDL_SetWindowFullscreen()

int SDL_SetWindowFullscreen ( SDL_Window window,
Uint32  flags 
)

Set a window's fullscreen state.

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

Definition at line 2108 of file SDL_video.c.

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

Referenced by SDL_FinishWindowCreation().

2109 {
2110  Uint32 oldflags;
2111  CHECK_WINDOW_MAGIC(window, -1);
2112 
2114 
2115  if (flags == (window->flags & FULLSCREEN_MASK)) {
2116  return 0;
2117  }
2118 
2119  /* clear the previous flags and OR in the new ones */
2120  oldflags = window->flags & FULLSCREEN_MASK;
2121  window->flags &= ~FULLSCREEN_MASK;
2122  window->flags |= flags;
2123 
2124  if (SDL_UpdateFullscreenMode(window, FULLSCREEN_VISIBLE(window)) == 0) {
2125  return 0;
2126  }
2127 
2128  window->flags &= ~FULLSCREEN_MASK;
2129  window->flags |= oldflags;
2130  return -1;
2131 }
#define FULLSCREEN_VISIBLE(W)
Definition: SDL_sysvideo.h:114
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:159
static int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen)
Definition: SDL_video.c:1152
GLbitfield flags
#define FULLSCREEN_MASK
Definition: SDL_video.c:142
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
Uint32 flags
Definition: SDL_sysvideo.h:81

◆ SDL_SetWindowGammaRamp()

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

Set the gamma ramp for a window.

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

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

See also
SDL_GetWindowGammaRamp()

Definition at line 2290 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.

Referenced by SDL_SetWindowBrightness().

2293 {
2294  CHECK_WINDOW_MAGIC(window, -1);
2295 
2296  if (!_this->SetWindowGammaRamp) {
2297  return SDL_Unsupported();
2298  }
2299 
2300  if (!window->gamma) {
2301  if (SDL_GetWindowGammaRamp(window, NULL, NULL, NULL) < 0) {
2302  return -1;
2303  }
2304  SDL_assert(window->gamma != NULL);
2305  }
2306 
2307  if (red) {
2308  SDL_memcpy(&window->gamma[0*256], red, 256*sizeof(Uint16));
2309  }
2310  if (green) {
2311  SDL_memcpy(&window->gamma[1*256], green, 256*sizeof(Uint16));
2312  }
2313  if (blue) {
2314  SDL_memcpy(&window->gamma[2*256], blue, 256*sizeof(Uint16));
2315  }
2316  if (window->flags & SDL_WINDOW_INPUT_FOCUS) {
2317  return _this->SetWindowGammaRamp(_this, window, window->gamma);
2318  } else {
2319  return 0;
2320  }
2321 }
const GLubyte GLuint red
Definition: SDL_glfuncs.h:78
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
#define SDL_memcpy
GLbyte GLbyte blue
#define SDL_assert(condition)
Definition: SDL_assert.h:167
#define NULL
Definition: begin_code.h:143
GLbyte green
uint16_t Uint16
An unsigned 16-bit integer type.
Definition: SDL_stdinc.h:151
int SDL_GetWindowGammaRamp(SDL_Window *window, Uint16 *red, Uint16 *green, Uint16 *blue)
Get the gamma ramp for a window.
Definition: SDL_video.c:2324
Uint16 * gamma
Definition: SDL_sysvideo.h:92
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
Uint32 flags
Definition: SDL_sysvideo.h:81
int(* SetWindowGammaRamp)(_THIS, SDL_Window *window, const Uint16 *ramp)
Definition: SDL_sysvideo.h:224
#define SDL_Unsupported()
Definition: SDL_error.h:53

◆ SDL_SetWindowGrab()

void SDL_SetWindowGrab ( SDL_Window window,
SDL_bool  grabbed 
)

Set a window's input grab mode.

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

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

See also
SDL_GetWindowGrab()

Definition at line 2400 of file SDL_video.c.

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

Referenced by SDL_FinishWindowCreation().

2401 {
2402  CHECK_WINDOW_MAGIC(window,);
2403 
2404  if (!!grabbed == !!(window->flags & SDL_WINDOW_INPUT_GRABBED)) {
2405  return;
2406  }
2407  if (grabbed) {
2408  window->flags |= SDL_WINDOW_INPUT_GRABBED;
2409  } else {
2410  window->flags &= ~SDL_WINDOW_INPUT_GRABBED;
2411  }
2412  SDL_UpdateWindowGrab(window);
2413 }
void SDL_UpdateWindowGrab(SDL_Window *window)
Definition: SDL_video.c:2369
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
Uint32 flags
Definition: SDL_sysvideo.h:81

◆ SDL_SetWindowHitTest()

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

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

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

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

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

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

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

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

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

Definition at line 3767 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.

3768 {
3769  CHECK_WINDOW_MAGIC(window, -1);
3770 
3771  if (!_this->SetWindowHitTest) {
3772  return SDL_Unsupported();
3773  } else if (_this->SetWindowHitTest(window, callback != NULL) == -1) {
3774  return -1;
3775  }
3776 
3777  window->hit_test = callback;
3778  window->hit_test_data = userdata;
3779 
3780  return 0;
3781 }
int(* SetWindowHitTest)(SDL_Window *window, SDL_bool enabled)
Definition: SDL_sysvideo.h:287
void * hit_test_data
Definition: SDL_sysvideo.h:105
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
static Uint32 callback(Uint32 interval, void *param)
Definition: testtimer.c:34
#define NULL
Definition: begin_code.h:143
SDL_HitTest hit_test
Definition: SDL_sysvideo.h:104
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
#define SDL_Unsupported()
Definition: SDL_error.h:53

◆ SDL_SetWindowIcon()

void SDL_SetWindowIcon ( SDL_Window window,
SDL_Surface icon 
)

Set the icon for a window.

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

Definition at line 1644 of file SDL_video.c.

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

1645 {
1646  CHECK_WINDOW_MAGIC(window,);
1647 
1648  if (!icon) {
1649  return;
1650  }
1651 
1652  SDL_FreeSurface(window->icon);
1653 
1654  /* Convert the icon into ARGB8888 */
1656  if (!window->icon) {
1657  return;
1658  }
1659 
1660  if (_this->SetWindowIcon) {
1661  _this->SetWindowIcon(_this, window, window->icon);
1662  }
1663 }
#define SDL_ConvertSurfaceFormat
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
#define SDL_FreeSurface
void(* SetWindowIcon)(_THIS, SDL_Window *window, SDL_Surface *icon)
Definition: SDL_sysvideo.h:206
SDL_Surface * icon
Definition: SDL_sysvideo.h:76
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120

◆ SDL_SetWindowInputFocus()

int SDL_SetWindowInputFocus ( SDL_Window window)

Explicitly sets input focus to the window.

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

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

Definition at line 2277 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, SDL_Unsupported, and SDL_VideoDevice::SetWindowInputFocus.

2278 {
2279  CHECK_WINDOW_MAGIC(window, -1);
2280 
2281  if (!_this->SetWindowInputFocus) {
2282  return SDL_Unsupported();
2283  }
2284 
2285  return _this->SetWindowInputFocus(_this, window);
2286 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
int(* SetWindowInputFocus)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:214
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
#define SDL_Unsupported()
Definition: SDL_error.h:53

◆ SDL_SetWindowMaximumSize()

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

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

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

Definition at line 1979 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_SetWindowSize(), SDL_WINDOW_FULLSCREEN, SDL_VideoDevice::SetWindowMaximumSize, and SDL_Window::w.

1980 {
1981  CHECK_WINDOW_MAGIC(window,);
1982  if (max_w <= 0) {
1983  SDL_InvalidParamError("max_w");
1984  return;
1985  }
1986  if (max_h <= 0) {
1987  SDL_InvalidParamError("max_h");
1988  return;
1989  }
1990 
1991  if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
1992  window->max_w = max_w;
1993  window->max_h = max_h;
1994  if (_this->SetWindowMaximumSize) {
1995  _this->SetWindowMaximumSize(_this, window);
1996  }
1997  /* Ensure that window is not larger than maximal size */
1998  SDL_SetWindowSize(window, SDL_min(window->w, window->max_w), SDL_min(window->h, window->max_h));
1999  }
2000 }
#define SDL_min(x, y)
Definition: SDL_stdinc.h:349
void SDL_SetWindowSize(SDL_Window *window, int w, int h)
Set the size of a window&#39;s client area.
Definition: SDL_video.c:1857
#define SDL_InvalidParamError(param)
Definition: SDL_error.h:54
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
void(* SetWindowMaximumSize)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:210
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
Uint32 flags
Definition: SDL_sysvideo.h:81

◆ SDL_SetWindowMinimumSize()

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

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

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

Definition at line 1921 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, SDL_Window::flags, SDL_Window::h, SDL_Window::min_h, SDL_Window::min_w, SDL_InvalidParamError, SDL_max, SDL_SetWindowSize(), SDL_WINDOW_FULLSCREEN, SDL_VideoDevice::SetWindowMinimumSize, and SDL_Window::w.

1922 {
1923  CHECK_WINDOW_MAGIC(window,);
1924  if (min_w <= 0) {
1925  SDL_InvalidParamError("min_w");
1926  return;
1927  }
1928  if (min_h <= 0) {
1929  SDL_InvalidParamError("min_h");
1930  return;
1931  }
1932 
1933  if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
1934  window->min_w = min_w;
1935  window->min_h = min_h;
1936  if (_this->SetWindowMinimumSize) {
1937  _this->SetWindowMinimumSize(_this, window);
1938  }
1939  /* Ensure that window is not smaller than minimal size */
1940  SDL_SetWindowSize(window, SDL_max(window->w, window->min_w), SDL_max(window->h, window->min_h));
1941  }
1942 }
void SDL_SetWindowSize(SDL_Window *window, int w, int h)
Set the size of a window&#39;s client area.
Definition: SDL_video.c:1857
#define SDL_InvalidParamError(param)
Definition: SDL_error.h:54
#define SDL_max(x, y)
Definition: SDL_stdinc.h:350
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
void(* SetWindowMinimumSize)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:209
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
Uint32 flags
Definition: SDL_sysvideo.h:81

◆ SDL_SetWindowModalFor()

int SDL_SetWindowModalFor ( SDL_Window modal_window,
SDL_Window parent_window 
)

Sets the window as a modal for another window (TODO: reconsider this function and/or its name)

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

Definition at line 2264 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, SDL_Unsupported, and SDL_VideoDevice::SetWindowModalFor.

2265 {
2266  CHECK_WINDOW_MAGIC(modal_window, -1);
2267  CHECK_WINDOW_MAGIC(parent_window, -1);
2268 
2269  if (!_this->SetWindowModalFor) {
2270  return SDL_Unsupported();
2271  }
2272 
2273  return _this->SetWindowModalFor(_this, modal_window, parent_window);
2274 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
int(* SetWindowModalFor)(_THIS, SDL_Window *modal_window, SDL_Window *parent_window)
Definition: SDL_sysvideo.h:213
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
#define SDL_Unsupported()
Definition: SDL_error.h:53

◆ SDL_SetWindowOpacity()

int SDL_SetWindowOpacity ( SDL_Window window,
float  opacity 
)

Set the opacity for a window.

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

Definition at line 2228 of file SDL_video.c.

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

2229 {
2230  int retval;
2231  CHECK_WINDOW_MAGIC(window, -1);
2232 
2233  if (!_this->SetWindowOpacity) {
2234  return SDL_Unsupported();
2235  }
2236 
2237  if (opacity < 0.0f) {
2238  opacity = 0.0f;
2239  } else if (opacity > 1.0f) {
2240  opacity = 1.0f;
2241  }
2242 
2243  retval = _this->SetWindowOpacity(_this, window, opacity);
2244  if (retval == 0) {
2245  window->opacity = opacity;
2246  }
2247 
2248  return retval;
2249 }
GLfloat f
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
SDL_bool retval
float opacity
Definition: SDL_sysvideo.h:89
int(* SetWindowOpacity)(_THIS, SDL_Window *window, float opacity)
Definition: SDL_sysvideo.h:212
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
#define SDL_Unsupported()
Definition: SDL_error.h:53

◆ SDL_SetWindowPosition()

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

Set the position of a window.

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

Definition at line 1734 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.

1735 {
1736  CHECK_WINDOW_MAGIC(window,);
1737 
1739  int displayIndex = (x & 0xFFFF);
1740  SDL_Rect bounds;
1741  if (displayIndex > _this->num_displays) {
1742  displayIndex = 0;
1743  }
1744 
1745  SDL_zero(bounds);
1746 
1747  SDL_GetDisplayBounds(displayIndex, &bounds);
1748  if (SDL_WINDOWPOS_ISCENTERED(x)) {
1749  x = bounds.x + (bounds.w - window->w) / 2;
1750  }
1751  if (SDL_WINDOWPOS_ISCENTERED(y)) {
1752  y = bounds.y + (bounds.h - window->h) / 2;
1753  }
1754  }
1755 
1756  if ((window->flags & SDL_WINDOW_FULLSCREEN)) {
1757  if (!SDL_WINDOWPOS_ISUNDEFINED(x)) {
1758  window->windowed.x = x;
1759  }
1760  if (!SDL_WINDOWPOS_ISUNDEFINED(y)) {
1761  window->windowed.y = y;
1762  }
1763  } else {
1764  if (!SDL_WINDOWPOS_ISUNDEFINED(x)) {
1765  window->x = x;
1766  }
1767  if (!SDL_WINDOWPOS_ISUNDEFINED(y)) {
1768  window->y = y;
1769  }
1770 
1771  if (_this->SetWindowPosition) {
1772  _this->SetWindowPosition(_this, window);
1773  }
1775  }
1776 }
#define SDL_WINDOWPOS_ISUNDEFINED(X)
Definition: SDL_video.h:128
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
#define SDL_WINDOWPOS_ISCENTERED(X)
Definition: SDL_video.h:137
int SDL_SendWindowEvent(SDL_Window *window, Uint8 windowevent, int data1, int data2)
SDL_Rect windowed
Definition: SDL_sysvideo.h:85
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1567
#define SDL_zero(x)
Definition: SDL_stdinc.h:359
int x
Definition: SDL_rect.h:66
int SDL_GetDisplayBounds(int displayIndex, SDL_Rect *rect)
Get the desktop area represented by a display, with the primary display located at 0...
Definition: SDL_video.c:661
int w
Definition: SDL_rect.h:67
void(* SetWindowPosition)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:207
int h
Definition: SDL_rect.h:67
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
Uint32 flags
Definition: SDL_sysvideo.h:81
int y
Definition: SDL_rect.h:66
A rectangle, with the origin at the upper left.
Definition: SDL_rect.h:64

◆ SDL_SetWindowResizable()

void SDL_SetWindowResizable ( SDL_Window window,
SDL_bool  resizable 
)

Set the user-resizable state of a window.

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

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

Definition at line 1839 of file SDL_video.c.

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

1840 {
1841  CHECK_WINDOW_MAGIC(window,);
1842  if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
1843  const int want = (resizable != SDL_FALSE); /* normalize the flag. */
1844  const int have = ((window->flags & SDL_WINDOW_RESIZABLE) != 0);
1845  if ((want != have) && (_this->SetWindowResizable)) {
1846  if (want) {
1847  window->flags |= SDL_WINDOW_RESIZABLE;
1848  } else {
1849  window->flags &= ~SDL_WINDOW_RESIZABLE;
1850  }
1851  _this->SetWindowResizable(_this, window, (SDL_bool) want);
1852  }
1853  }
1854 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
SDL_bool
Definition: SDL_stdinc.h:130
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
void(* SetWindowResizable)(_THIS, SDL_Window *window, SDL_bool resizable)
Definition: SDL_sysvideo.h:222
Uint32 flags
Definition: SDL_sysvideo.h:81

◆ SDL_SetWindowSize()

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

Set the size of a window's client area.

Parameters
windowThe window to resize.
wThe width of the window, in screen coordinates. Must be >0.
hThe height of the window, in screen coordinates. Must be >0.
Note
You can't change the size of a fullscreen window, it automatically matches the size of the display mode.

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

Definition at line 1857 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.

Referenced by SDL_SetWindowMaximumSize(), and SDL_SetWindowMinimumSize().

1858 {
1859  CHECK_WINDOW_MAGIC(window,);
1860  if (w <= 0) {
1861  SDL_InvalidParamError("w");
1862  return;
1863  }
1864  if (h <= 0) {
1865  SDL_InvalidParamError("h");
1866  return;
1867  }
1868 
1869  /* Make sure we don't exceed any window size limits */
1870  if (window->min_w && w < window->min_w)
1871  {
1872  w = window->min_w;
1873  }
1874  if (window->max_w && w > window->max_w)
1875  {
1876  w = window->max_w;
1877  }
1878  if (window->min_h && h < window->min_h)
1879  {
1880  h = window->min_h;
1881  }
1882  if (window->max_h && h > window->max_h)
1883  {
1884  h = window->max_h;
1885  }
1886 
1887  window->windowed.w = w;
1888  window->windowed.h = h;
1889 
1890  if (window->flags & SDL_WINDOW_FULLSCREEN) {
1892  window->last_fullscreen_flags = 0;
1894  }
1895  } else {
1896  window->w = w;
1897  window->h = h;
1898  if (_this->SetWindowSize) {
1899  _this->SetWindowSize(_this, window);
1900  }
1901  if (window->w == w && window->h == h) {
1902  /* We didn't get a SDL_WINDOWEVENT_RESIZED event (by design) */
1903  SDL_OnWindowResized(window);
1904  }
1905  }
1906 }
#define FULLSCREEN_VISIBLE(W)
Definition: SDL_sysvideo.h:114
void(* SetWindowSize)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:208
#define SDL_InvalidParamError(param)
Definition: SDL_error.h:54
SDL_Rect windowed
Definition: SDL_sysvideo.h:85
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
static int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen)
Definition: SDL_video.c:1152
int w
Definition: SDL_rect.h:67
Uint32 last_fullscreen_flags
Definition: SDL_sysvideo.h:82
int h
Definition: SDL_rect.h:67
GLubyte GLubyte GLubyte GLubyte w
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
Uint32 flags
Definition: SDL_sysvideo.h:81
GLfloat GLfloat GLfloat GLfloat h
void SDL_OnWindowResized(SDL_Window *window)
Definition: SDL_video.c:2443

◆ SDL_SetWindowTitle()

void SDL_SetWindowTitle ( SDL_Window window,
const char *  title 
)

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

See also
SDL_GetWindowTitle()

Definition at line 1619 of file SDL_video.c.

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

Referenced by SDL_CreateWindow().

1620 {
1621  CHECK_WINDOW_MAGIC(window,);
1622 
1623  if (title == window->title) {
1624  return;
1625  }
1626  SDL_free(window->title);
1627 
1628  window->title = SDL_strdup(title ? title : "");
1629 
1630  if (_this->SetWindowTitle) {
1631  _this->SetWindowTitle(_this, window);
1632  }
1633 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
void SDL_free(void *mem)
char * title
Definition: SDL_sysvideo.h:75
#define SDL_strdup
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
void(* SetWindowTitle)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:205

◆ SDL_ShowWindow()

void SDL_ShowWindow ( SDL_Window window)

Show a window.

See also
SDL_HideWindow()

Definition at line 2015 of file SDL_video.c.

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

Referenced by SDL_FinishWindowCreation().

2016 {
2017  CHECK_WINDOW_MAGIC(window,);
2018 
2019  if (window->flags & SDL_WINDOW_SHOWN) {
2020  return;
2021  }
2022 
2023  if (_this->ShowWindow) {
2024  _this->ShowWindow(_this, window);
2025  }
2027 }
void(* ShowWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:215
int SDL_SendWindowEvent(SDL_Window *window, Uint8 windowevent, int data1, int data2)
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
Uint32 flags
Definition: SDL_sysvideo.h:81

◆ SDL_UpdateWindowSurface()

int SDL_UpdateWindowSurface ( SDL_Window window)

Copy the window surface to the screen.

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

Definition at line 2177 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.

2178 {
2179  SDL_Rect full_rect;
2180 
2181  CHECK_WINDOW_MAGIC(window, -1);
2182 
2183  full_rect.x = 0;
2184  full_rect.y = 0;
2185  full_rect.w = window->w;
2186  full_rect.h = window->h;
2187  return SDL_UpdateWindowSurfaceRects(window, &full_rect, 1);
2188 }
int SDL_UpdateWindowSurfaceRects(SDL_Window *window, const SDL_Rect *rects, int numrects)
Copy a number of rectangles on the window surface to the screen.
Definition: SDL_video.c:2191
int x
Definition: SDL_rect.h:66
int w
Definition: SDL_rect.h:67
int h
Definition: SDL_rect.h:67
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
int y
Definition: SDL_rect.h:66
A rectangle, with the origin at the upper left.
Definition: SDL_rect.h:64

◆ SDL_UpdateWindowSurfaceRects()

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

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

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

Definition at line 2191 of file SDL_video.c.

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

Referenced by SDL_UpdateWindowSurface().

2193 {
2194  CHECK_WINDOW_MAGIC(window, -1);
2195 
2196  if (!window->surface_valid) {
2197  return SDL_SetError("Window surface is invalid, please call SDL_GetWindowSurface() to get a new surface");
2198  }
2199 
2200  return _this->UpdateWindowFramebuffer(_this, window, rects, numrects);
2201 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
#define SDL_SetError
int(* UpdateWindowFramebuffer)(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects)
Definition: SDL_sysvideo.h:229
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
SDL_bool surface_valid
Definition: SDL_sysvideo.h:96

◆ SDL_VideoInit()

int SDL_VideoInit ( const char *  driver_name)

Initialize the video subsystem, optionally specifying a video driver.

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

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

See also
SDL_VideoQuit()

Definition at line 449 of file SDL_video.c.

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

Referenced by SDL_CreateWindow().

450 {
451  SDL_VideoDevice *video;
452  int index;
453  int i;
454 
455  /* Check to make sure we don't overwrite '_this' */
456  if (_this != NULL) {
457  SDL_VideoQuit();
458  }
459 
460 #if !SDL_TIMERS_DISABLED
461  SDL_TicksInit();
462 #endif
463 
464  /* Start the event loop */
466  SDL_KeyboardInit() < 0 ||
467  SDL_MouseInit() < 0 ||
468  SDL_TouchInit() < 0) {
469  return -1;
470  }
471 
472  /* Select the proper video driver */
473  index = 0;
474  video = NULL;
475  if (driver_name == NULL) {
476  driver_name = SDL_getenv("SDL_VIDEODRIVER");
477  }
478  if (driver_name != NULL) {
479  for (i = 0; bootstrap[i]; ++i) {
480  if (SDL_strncasecmp(bootstrap[i]->name, driver_name, SDL_strlen(driver_name)) == 0) {
481  if (bootstrap[i]->available()) {
482  video = bootstrap[i]->create(index);
483  break;
484  }
485  }
486  }
487  } else {
488  for (i = 0; bootstrap[i]; ++i) {
489  if (bootstrap[i]->available()) {
490  video = bootstrap[i]->create(index);
491  if (video != NULL) {
492  break;
493  }
494  }
495  }
496  }
497  if (video == NULL) {
498  if (driver_name) {
499  return SDL_SetError("%s not available", driver_name);
500  }
501  return SDL_SetError("No available video device");
502  }
503  _this = video;
504  _this->name = bootstrap[i]->name;
505  _this->next_object_id = 1;
506 
507 
508  /* Set some very sane GL defaults */
512 
515 
516  /* Initialize the video subsystem */
517  if (_this->VideoInit(_this) < 0) {
518  SDL_VideoQuit();
519  return -1;
520  }
521 
522  /* Make sure some displays were added */
523  if (_this->num_displays == 0) {
524  SDL_VideoQuit();
525  return SDL_SetError("The video driver did not add any displays");
526  }
527 
528  /* Add the renderer framebuffer emulation if desired */
533  }
534 
535  /* Disable the screen saver by default. This is a change from <= 2.0.1,
536  but most things using SDL are games or media players; you wouldn't
537  want a screensaver to trigger if you're playing exclusively with a
538  joystick, or passively watching a movie. Things that use SDL but
539  function more like a normal desktop app should explicitly reenable the
540  screensaver. */
543  }
544 
545  /* If we don't use a screen keyboard, turn on text input by default,
546  otherwise programs that expect to get text events without enabling
547  UNICODE input won't get any events.
548 
549  Actually, come to think of it, you needed to call SDL_EnableUNICODE(1)
550  in SDL 1.2 before you got text input events. Hmm...
551  */
554  }
555 
556  /* We're ready to go! */
557  return 0;
558 }
void SDL_GL_ResetAttributes()
Reset all previously set OpenGL context attributes to their default values.
Definition: SDL_video.c:2871
const char * name
Definition: SDL_sysvideo.h:149
#define SDL_INIT_EVENTS
Definition: SDL.h:81
void SDL_VideoQuit(void)
Shuts down the video subsystem.
Definition: SDL_video.c:2663
SDL_TLSID current_glwin_tls
Definition: SDL_sysvideo.h:340
#define SDL_HINT_VIDEO_ALLOW_SCREENSAVER
A variable controlling whether the screensaver is enabled.
Definition: SDL_hints.h:153
#define SDL_InitSubSystem
GLuint const GLchar * name
int SDL_KeyboardInit(void)
Definition: SDL_keyboard.c:554
#define SDL_strncasecmp
int SDL_MouseInit(void)
Definition: SDL_mouse.c:45
#define SDL_GetHintBoolean
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
static int SDL_UpdateWindowTexture(SDL_VideoDevice *unused, SDL_Window *window, const SDL_Rect *rects, int numrects)
Definition: SDL_video.c:354
#define SDL_TLSCreate
static int SDL_CreateWindowTexture(SDL_VideoDevice *unused, SDL_Window *window, Uint32 *format, void **pixels, int *pitch)
Definition: SDL_video.c:249
static void SDL_DestroyWindowTexture(SDL_VideoDevice *unused, SDL_Window *window)
Definition: SDL_video.c:384
GLuint index
void SDL_StartTextInput(void)
Start accepting Unicode text input events. This function will show the on-screen keyboard if supporte...
Definition: SDL_video.c:3528
#define SDL_getenv
void(* DestroyWindowFramebuffer)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:230
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
#define NULL
Definition: begin_code.h:143
#define SDL_SetError
static SDL_bool ShouldUseTextureFramebuffer()
Definition: SDL_video.c:164
#define SDL_strlen
SDL_TLSID current_glctx_tls
Definition: SDL_sysvideo.h:341
SDL_VideoDevice *(* create)(int devindex)
Definition: SDL_sysvideo.h:366
static VideoBootStrap * bootstrap[]
Definition: SDL_video.c:63
const char * name
Definition: SDL_sysvideo.h:363
struct SDL_VideoDevice::@28 gl_config
void SDL_TicksInit(void)
int(* VideoInit)(_THIS)
Definition: SDL_sysvideo.h:158
int(* UpdateWindowFramebuffer)(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects)
Definition: SDL_sysvideo.h:229
Uint32 next_object_id
Definition: SDL_sysvideo.h:297
SDL_bool SDL_HasScreenKeyboardSupport(void)
Returns whether the platform has some screen keyboard support.
Definition: SDL_video.c:3584
int(* CreateWindowFramebuffer)(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch)
Definition: SDL_sysvideo.h:228
int SDL_TouchInit(void)
Definition: SDL_touch.c:36
void SDL_DisableScreenSaver()
Prevent the screen from being blanked by a screensaver.
Definition: SDL_video.c:2648

◆ SDL_VideoQuit()

void SDL_VideoQuit ( void  )

Shuts down the video subsystem.

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

See also
SDL_VideoInit()

Definition at line 2663 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.

Referenced by SDL_VideoInit().

2664 {
2665  int i, j;
2666 
2667  if (!_this) {
2668  return;
2669  }
2670 
2671  /* Halt event processing before doing anything else */
2672  SDL_TouchQuit();
2673  SDL_MouseQuit();
2674  SDL_KeyboardQuit();
2676 
2678 
2679  /* Clean up the system video */
2680  while (_this->windows) {
2682  }
2683  _this->VideoQuit(_this);
2684 
2685  for (i = 0; i < _this->num_displays; ++i) {
2686  SDL_VideoDisplay *display = &_this->displays[i];
2687  for (j = display->num_display_modes; j--;) {
2688  SDL_free(display->display_modes[j].driverdata);
2689  display->display_modes[j].driverdata = NULL;
2690  }
2691  SDL_free(display->display_modes);
2692  display->display_modes = NULL;
2693  SDL_free(display->desktop_mode.driverdata);
2694  display->desktop_mode.driverdata = NULL;
2695  SDL_free(display->driverdata);
2696  display->driverdata = NULL;
2697  }
2698  if (_this->displays) {
2699  for (i = 0; i < _this->num_displays; ++i) {
2700  SDL_free(_this->displays[i].name);
2701  }
2703  _this->displays = NULL;
2704  _this->num_displays = 0;
2705  }
2708  _this->free(_this);
2709  _this = NULL;
2710 }
#define SDL_INIT_EVENTS
Definition: SDL.h:81
void(* free)(_THIS)
Definition: SDL_sysvideo.h:358
#define SDL_QuitSubSystem
void SDL_MouseQuit(void)
Definition: SDL_mouse.c:449
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
void SDL_free(void *mem)
void * driverdata
Definition: SDL_video.h:59
void SDL_DestroyWindow(SDL_Window *window)
Destroy a window.
Definition: SDL_video.c:2550
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int int in j)
Definition: SDL_x11sym.h:50
SDL_DisplayMode * display_modes
Definition: SDL_sysvideo.h:128
SDL_VideoDisplay * displays
Definition: SDL_sysvideo.h:293
SDL_Window * windows
Definition: SDL_sysvideo.h:294
void SDL_KeyboardQuit(void)
Definition: SDL_keyboard.c:817
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
#define NULL
Definition: begin_code.h:143
SDL_DisplayMode desktop_mode
Definition: SDL_sysvideo.h:129
void(* VideoQuit)(_THIS)
Definition: SDL_sysvideo.h:164
void SDL_EnableScreenSaver()
Allow the screen to be blanked by a screensaver.
Definition: SDL_video.c:2633
void SDL_TouchQuit(void)
Definition: SDL_touch.c:352
char * clipboard_text
Definition: SDL_sysvideo.h:298