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,
  SDL_WINDOW_VULKAN = 0x10000000
}
 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_DisplayEventID {
  SDL_DISPLAYEVENT_NONE,
  SDL_DISPLAYEVENT_ORIENTATION
}
 Event subtype for display events. More...
 
enum  SDL_DisplayOrientation {
  SDL_ORIENTATION_UNKNOWN,
  SDL_ORIENTATION_LANDSCAPE,
  SDL_ORIENTATION_LANDSCAPE_FLIPPED,
  SDL_ORIENTATION_PORTRAIT,
  SDL_ORIENTATION_PORTRAIT_FLIPPED
}
 
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,
  SDL_GL_CONTEXT_RESET_NOTIFICATION,
  SDL_GL_CONTEXT_NO_ERROR
}
 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_GLContextResetNotification {
  SDL_GL_CONTEXT_RESET_NO_NOTIFICATION = 0x0000,
  SDL_GL_CONTEXT_RESET_LOSE_CONTEXT = 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_GetDisplayUsableBounds (int displayIndex, SDL_Rect *rect)
 Get the usable desktop area represented by a display, with the primary display located at 0,0. More...
 
int SDL_GetDisplayDPI (int displayIndex, float *ddpi, float *hdpi, float *vdpi)
 Get the dots/pixels-per-inch for a display. More...
 
SDL_DisplayOrientation SDL_GetDisplayOrientation (int displayIndex)
 Get the orientation of a display. More...
 
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 138 of file SDL_video.h.

Referenced by SDLTest_CommonArg(), and SDLTest_CommonEvent().

◆ SDL_WINDOWPOS_CENTERED_MASK

#define SDL_WINDOWPOS_CENTERED_MASK   0x2FFF0000u

Used to indicate that the window position should be centered.

Definition at line 137 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 129 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 128 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 193 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 1039 of file SDL_video.h.

Enumeration Type Documentation

◆ SDL_DisplayEventID

Event subtype for display events.

Enumerator
SDL_DISPLAYEVENT_NONE 

Never used

SDL_DISPLAYEVENT_ORIENTATION 

Display orientation has changed to data1

Definition at line 175 of file SDL_video.h.

176 {
177  SDL_DISPLAYEVENT_NONE, /**< Never used */
178  SDL_DISPLAYEVENT_ORIENTATION /**< Display orientation has changed to data1 */
SDL_DisplayEventID
Event subtype for display events.
Definition: SDL_video.h:175

◆ SDL_DisplayOrientation

Enumerator
SDL_ORIENTATION_UNKNOWN 

The display orientation can't be determined

SDL_ORIENTATION_LANDSCAPE 

The display is in landscape mode, with the right side up, relative to portrait mode

SDL_ORIENTATION_LANDSCAPE_FLIPPED 

The display is in landscape mode, with the left side up, relative to portrait mode

SDL_ORIENTATION_PORTRAIT 

The display is in portrait mode

SDL_ORIENTATION_PORTRAIT_FLIPPED 

The display is in portrait mode, upside down

Definition at line 181 of file SDL_video.h.

182 {
183  SDL_ORIENTATION_UNKNOWN, /**< The display orientation can't be determined */
184  SDL_ORIENTATION_LANDSCAPE, /**< The display is in landscape mode, with the right side up, relative to portrait mode */
185  SDL_ORIENTATION_LANDSCAPE_FLIPPED, /**< The display is in landscape mode, with the left side up, relative to portrait mode */
186  SDL_ORIENTATION_PORTRAIT, /**< The display is in portrait mode */
187  SDL_ORIENTATION_PORTRAIT_FLIPPED /**< The display is in portrait mode, upside down */
SDL_DisplayOrientation
Definition: SDL_video.h:181

◆ 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 
SDL_GL_CONTEXT_RESET_NOTIFICATION 
SDL_GL_CONTEXT_NO_ERROR 

Definition at line 198 of file SDL_video.h.

199 {
227 } SDL_GLattr;
SDL_GLattr
OpenGL configuration attributes.
Definition: SDL_video.h:198

◆ 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 236 of file SDL_video.h.

◆ SDL_GLcontextReleaseFlag

Enumerator
SDL_GL_CONTEXT_RELEASE_BEHAVIOR_NONE 
SDL_GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH 

Definition at line 244 of file SDL_video.h.

◆ SDL_GLContextResetNotification

Enumerator
SDL_GL_CONTEXT_RESET_NO_NOTIFICATION 
SDL_GL_CONTEXT_RESET_LOSE_CONTEXT 

Definition at line 250 of file SDL_video.h.

◆ SDL_GLprofile

Enumerator
SDL_GL_CONTEXT_PROFILE_CORE 
SDL_GL_CONTEXT_PROFILE_COMPATIBILITY 
SDL_GL_CONTEXT_PROFILE_ES 

GLX_CONTEXT_ES2_PROFILE_BIT_EXT

Definition at line 229 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 1020 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 146 of file SDL_video.h.

147 {
148  SDL_WINDOWEVENT_NONE, /**< Never used */
149  SDL_WINDOWEVENT_SHOWN, /**< Window has been shown */
150  SDL_WINDOWEVENT_HIDDEN, /**< Window has been hidden */
151  SDL_WINDOWEVENT_EXPOSED, /**< Window has been exposed and should be
152  redrawn */
153  SDL_WINDOWEVENT_MOVED, /**< Window has been moved to data1, data2
154  */
155  SDL_WINDOWEVENT_RESIZED, /**< Window has been resized to data1xdata2 */
156  SDL_WINDOWEVENT_SIZE_CHANGED, /**< The window size has changed, either as
157  a result of an API call or through the
158  system or user changing the window size. */
159  SDL_WINDOWEVENT_MINIMIZED, /**< Window has been minimized */
160  SDL_WINDOWEVENT_MAXIMIZED, /**< Window has been maximized */
161  SDL_WINDOWEVENT_RESTORED, /**< Window has been restored to normal size
162  and position */
163  SDL_WINDOWEVENT_ENTER, /**< Window has gained mouse focus */
164  SDL_WINDOWEVENT_LEAVE, /**< Window has lost mouse focus */
165  SDL_WINDOWEVENT_FOCUS_GAINED, /**< Window has gained keyboard focus */
166  SDL_WINDOWEVENT_FOCUS_LOST, /**< Window has lost keyboard focus */
167  SDL_WINDOWEVENT_CLOSE, /**< The window manager requests that the window be closed */
168  SDL_WINDOWEVENT_TAKE_FOCUS, /**< Window is being offered a focus (should SetWindowInputFocus() on itself or a subwindow, or ignore) */
169  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:146

◆ 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. On macOS NSHighResolutionCapable must be set true in the application's Info.plist for this to have any effect.

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

SDL_WINDOW_VULKAN 

window usable for Vulkan surface

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  On macOS NSHighResolutionCapable must be set true in the
115  application's Info.plist for this to have any effect. */
116  SDL_WINDOW_MOUSE_CAPTURE = 0x00004000, /**< window has mouse captured (unrelated to INPUT_GRABBED) */
117  SDL_WINDOW_ALWAYS_ON_TOP = 0x00008000, /**< window should always be above others */
118  SDL_WINDOW_SKIP_TASKBAR = 0x00010000, /**< window should not be added to the taskbar */
119  SDL_WINDOW_UTILITY = 0x00020000, /**< window should be treated as a utility window */
120  SDL_WINDOW_TOOLTIP = 0x00040000, /**< window should be treated as a tooltip */
121  SDL_WINDOW_POPUP_MENU = 0x00080000, /**< window should be treated as a popup menu */
122  SDL_WINDOW_VULKAN = 0x10000000 /**< window usable for Vulkan surface */
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, SDL_WINDOW_VULKAN.
Returns
The created window, or NULL if window creation failed.

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

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

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

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

Definition at line 1405 of file SDL_video.c.

References SDL_Window::brightness, CREATE_FLAGS, SDL_VideoDevice::CreateSDLWindow, SDL_Window::flags, FULLSCREEN_VISIBLE, SDL_VideoDevice::GL_CreateContext, SDL_Rect::h, SDL_Window::h, SDL_Window::id, SDL_Window::is_destroying, SDL_VideoDevice::is_dummy, SDL_Window::last_fullscreen_flags, SDL_Window::magic, SDL_VideoDevice::name, SDL_Window::next, SDL_VideoDevice::next_object_id, NULL, SDL_Window::opacity, SDL_Window::prev, SDL_calloc, SDL_DestroyWindow(), SDL_FALSE, SDL_FinishWindowCreation(), SDL_GetDisplayBounds(), SDL_GetDisplayForWindow(), SDL_GetHintBoolean, SDL_GetIndexOfDisplay(), SDL_GL_LoadLibrary(), SDL_HINT_VIDEO_HIGHDPI_DISABLED, SDL_OutOfMemory, SDL_SetError, SDL_SetWindowTitle(), SDL_UpdateFullscreenMode(), SDL_VideoInit(), SDL_Vulkan_LoadLibrary(), SDL_WINDOW_ALLOW_HIGHDPI, SDL_WINDOW_FULLSCREEN, SDL_WINDOW_HIDDEN, SDL_WINDOW_MINIMIZED, SDL_WINDOW_OPENGL, SDL_WINDOW_POPUP_MENU, SDL_WINDOW_TOOLTIP, SDL_WINDOW_UTILITY, SDL_WINDOW_VULKAN, SDL_WINDOWPOS_ISCENTERED, SDL_WINDOWPOS_ISUNDEFINED, SDL_VideoDevice::Vulkan_CreateSurface, SDL_Window::w, SDL_Rect::w, SDL_VideoDevice::window_magic, SDL_Window::windowed, SDL_VideoDevice::windows, SDL_Window::x, SDL_Rect::x, SDL_Window::y, and SDL_Rect::y.

Referenced by ShouldUseTextureFramebuffer().

1406 {
1407  SDL_Window *window;
1408 
1409  if (!_this) {
1410  /* Initialize the video system if needed */
1411  if (SDL_VideoInit(NULL) < 0) {
1412  return NULL;
1413  }
1414  }
1415 
1416  if ((((flags & SDL_WINDOW_UTILITY) != 0) + ((flags & SDL_WINDOW_TOOLTIP) != 0) + ((flags & SDL_WINDOW_POPUP_MENU) != 0)) > 1) {
1417  SDL_SetError("Conflicting window flags specified");
1418  return NULL;
1419  }
1420 
1421  /* Some platforms can't create zero-sized windows */
1422  if (w < 1) {
1423  w = 1;
1424  }
1425  if (h < 1) {
1426  h = 1;
1427  }
1428 
1429  /* Some platforms blow up if the windows are too large. Raise it later? */
1430  if ((w > 16384) || (h > 16384)) {
1431  SDL_SetError("Window is too large.");
1432  return NULL;
1433  }
1434 
1435  /* Some platforms have OpenGL enabled by default */
1436 #if (SDL_VIDEO_OPENGL && __MACOSX__) || __IPHONEOS__ || __ANDROID__ || __NACL__
1437  if (!_this->is_dummy && !(flags & SDL_WINDOW_VULKAN)) {
1439  }
1440 #endif
1441  if (flags & SDL_WINDOW_OPENGL) {
1442  if (!_this->GL_CreateContext) {
1443  SDL_SetError("OpenGL support is either not configured in SDL "
1444  "or not available in current SDL video driver "
1445  "(%s) or platform", _this->name);
1446  return NULL;
1447  }
1448  if (SDL_GL_LoadLibrary(NULL) < 0) {
1449  return NULL;
1450  }
1451  }
1452 
1453  if (flags & SDL_WINDOW_VULKAN) {
1454  if (!_this->Vulkan_CreateSurface) {
1455  SDL_SetError("Vulkan support is either not configured in SDL "
1456  "or not available in current SDL video driver "
1457  "(%s) or platform", _this->name);
1458  return NULL;
1459  }
1460  if (flags & SDL_WINDOW_OPENGL) {
1461  SDL_SetError("Vulkan and OpenGL not supported on same window");
1462  return NULL;
1463  }
1464  if (SDL_Vulkan_LoadLibrary(NULL) < 0) {
1465  return NULL;
1466  }
1467  }
1468 
1469  /* Unless the user has specified the high-DPI disabling hint, respect the
1470  * SDL_WINDOW_ALLOW_HIGHDPI flag.
1471  */
1474  flags &= ~SDL_WINDOW_ALLOW_HIGHDPI;
1475  }
1476  }
1477 
1478  window = (SDL_Window *)SDL_calloc(1, sizeof(*window));
1479  if (!window) {
1480  SDL_OutOfMemory();
1481  return NULL;
1482  }
1483  window->magic = &_this->window_magic;
1484  window->id = _this->next_object_id++;
1485  window->x = x;
1486  window->y = y;
1487  window->w = w;
1488  window->h = h;
1491  SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
1492  int displayIndex;
1493  SDL_Rect bounds;
1494 
1495  displayIndex = SDL_GetIndexOfDisplay(display);
1496  SDL_GetDisplayBounds(displayIndex, &bounds);
1498  window->x = bounds.x + (bounds.w - w) / 2;
1499  }
1501  window->y = bounds.y + (bounds.h - h) / 2;
1502  }
1503  }
1504  window->windowed.x = window->x;
1505  window->windowed.y = window->y;
1506  window->windowed.w = window->w;
1507  window->windowed.h = window->h;
1508 
1509  if (flags & SDL_WINDOW_FULLSCREEN) {
1510  SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
1511  int displayIndex;
1512  SDL_Rect bounds;
1513 
1514  displayIndex = SDL_GetIndexOfDisplay(display);
1515  SDL_GetDisplayBounds(displayIndex, &bounds);
1516 
1517  window->x = bounds.x;
1518  window->y = bounds.y;
1519  window->w = bounds.w;
1520  window->h = bounds.h;
1521  }
1522 
1523  window->flags = ((flags & CREATE_FLAGS) | SDL_WINDOW_HIDDEN);
1524  window->last_fullscreen_flags = window->flags;
1525  window->opacity = 1.0f;
1526  window->brightness = 1.0f;
1527  window->next = _this->windows;
1528  window->is_destroying = SDL_FALSE;
1529 
1530  if (_this->windows) {
1531  _this->windows->prev = window;
1532  }
1533  _this->windows = window;
1534 
1535  if (_this->CreateSDLWindow && _this->CreateSDLWindow(_this, window) < 0) {
1536  SDL_DestroyWindow(window);
1537  return NULL;
1538  }
1539 
1540  /* Clear minimized if not on windows, only windows handles it at create rather than FinishWindowCreation,
1541  * but it's important or window focus will get broken on windows!
1542  */
1543 #if !defined(__WIN32__)
1544  if (window->flags & SDL_WINDOW_MINIMIZED) {
1545  window->flags &= ~SDL_WINDOW_MINIMIZED;
1546  }
1547 #endif
1548 
1549 #if __WINRT__ && (NTDDI_VERSION < NTDDI_WIN10)
1550  /* HACK: WinRT 8.x apps can't choose whether or not they are fullscreen
1551  or not. The user can choose this, via OS-provided UI, but this can't
1552  be set programmatically.
1553 
1554  Just look at what SDL's WinRT video backend code detected with regards
1555  to fullscreen (being active, or not), and figure out a return/error code
1556  from that.
1557  */
1558  flags = window->flags;
1559 #endif
1560 
1561  if (title) {
1562  SDL_SetWindowTitle(window, title);
1563  }
1565 
1566  /* If the window was created fullscreen, make sure the mode code matches */
1568 
1569  return window;
1570 }
#define SDL_WINDOWPOS_ISUNDEFINED(X)
Definition: SDL_video.h:131
SDL_Window * next
Definition: SDL_sysvideo.h:114
const char * name
Definition: SDL_sysvideo.h:152
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
#define FULLSCREEN_VISIBLE(W)
Definition: SDL_sysvideo.h:116
const void * magic
Definition: SDL_sysvideo.h:75
GLfloat GLfloat GLfloat GLfloat h
#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:652
int SDL_GL_LoadLibrary(const char *path)
Dynamically load an OpenGL library.
Definition: SDL_video.c:2878
void SDL_SetWindowTitle(SDL_Window *window, const char *title)
Set the title of a window, in UTF-8 format.
Definition: SDL_video.c:1749
#define SDL_WINDOWPOS_ISCENTERED(X)
Definition: SDL_video.h:140
SDL_bool is_destroying
Definition: SDL_sysvideo.h:101
SDL_bool is_dummy
Definition: SDL_sysvideo.h:313
SDL_Rect windowed
Definition: SDL_sysvideo.h:87
#define SDL_GetHintBoolean
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
#define CREATE_FLAGS
Definition: SDL_video.c:1347
float opacity
Definition: SDL_sysvideo.h:91
SDL_VideoDisplay * SDL_GetDisplayForWindow(SDL_Window *window)
Definition: SDL_video.c:1089
int SDL_GetIndexOfDisplay(SDL_VideoDisplay *display)
Definition: SDL_video.c:642
SDL_GLContext(* GL_CreateContext)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:258
SDL_bool(* Vulkan_CreateSurface)(_THIS, SDL_Window *window, VkInstance instance, VkSurfaceKHR *surface)
Definition: SDL_sysvideo.h:274
void SDL_DestroyWindow(SDL_Window *window)
Destroy a window.
Definition: SDL_video.c:2712
GLubyte GLubyte GLubyte GLubyte w
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574
int x
Definition: SDL_rect.h:79
static int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen)
Definition: SDL_video.c:1183
SDL_Window * windows
Definition: SDL_sysvideo.h:317
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:673
int w
Definition: SDL_rect.h:80
float brightness
Definition: SDL_sysvideo.h:93
#define NULL
Definition: begin_code.h:167
int(* CreateSDLWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:211
#define SDL_OutOfMemory()
Definition: SDL_error.h:52
Uint32 last_fullscreen_flags
Definition: SDL_sysvideo.h:84
#define SDL_SetError
GLbitfield flags
#define SDL_calloc
EGLSurface EGLNativeWindowType * window
Definition: eglext.h:1025
SDL_Window * prev
Definition: SDL_sysvideo.h:113
int SDL_VideoInit(const char *driver_name)
Initialize the video subsystem, optionally specifying a video driver.
Definition: SDL_video.c:461
int h
Definition: SDL_rect.h:80
The type used to identify a window.
Definition: SDL_sysvideo.h:73
static void SDL_FinishWindowCreation(SDL_Window *window, Uint32 flags)
Definition: SDL_video.c:1383
Uint32 id
Definition: SDL_sysvideo.h:76
int SDL_Vulkan_LoadLibrary(const char *path)
Dynamically load a Vulkan loader library.
Definition: SDL_video.c:4076
Uint32 flags
Definition: SDL_sysvideo.h:83
Uint32 next_object_id
Definition: SDL_sysvideo.h:320
int y
Definition: SDL_rect.h:79
A rectangle, with the origin at the upper left (integer).
Definition: SDL_rect.h:77

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

References SDL_Window::brightness, SDL_VideoDevice::CreateSDLWindowFrom, SDL_Window::flags, SDL_Window::id, SDL_Window::is_destroying, SDL_Window::last_fullscreen_flags, SDL_Window::magic, SDL_Window::next, SDL_VideoDevice::next_object_id, NULL, SDL_Window::opacity, PrepareDragAndDropSupport(), SDL_Window::prev, SDL_calloc, SDL_DestroyWindow(), SDL_FALSE, SDL_OutOfMemory, SDL_UninitializedVideo(), SDL_Unsupported, SDL_WINDOW_FOREIGN, SDL_VideoDevice::window_magic, and SDL_VideoDevice::windows.

1574 {
1575  SDL_Window *window;
1576 
1577  if (!_this) {
1579  return NULL;
1580  }
1581  if (!_this->CreateSDLWindowFrom) {
1582  SDL_Unsupported();
1583  return NULL;
1584  }
1585  window = (SDL_Window *)SDL_calloc(1, sizeof(*window));
1586  if (!window) {
1587  SDL_OutOfMemory();
1588  return NULL;
1589  }
1590  window->magic = &_this->window_magic;
1591  window->id = _this->next_object_id++;
1592  window->flags = SDL_WINDOW_FOREIGN;
1593  window->last_fullscreen_flags = window->flags;
1594  window->is_destroying = SDL_FALSE;
1595  window->opacity = 1.0f;
1596  window->brightness = 1.0f;
1597  window->next = _this->windows;
1598  if (_this->windows) {
1599  _this->windows->prev = window;
1600  }
1601  _this->windows = window;
1602 
1603  if (_this->CreateSDLWindowFrom(_this, window, data) < 0) {
1604  SDL_DestroyWindow(window);
1605  return NULL;
1606  }
1607 
1608  PrepareDragAndDropSupport(window);
1609 
1610  return window;
1611 }
SDL_Window * next
Definition: SDL_sysvideo.h:114
const void * magic
Definition: SDL_sysvideo.h:75
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: SDL_opengl.h:1974
SDL_bool is_destroying
Definition: SDL_sysvideo.h:101
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
float opacity
Definition: SDL_sysvideo.h:91
void SDL_DestroyWindow(SDL_Window *window)
Destroy a window.
Definition: SDL_video.c:2712
SDL_Window * windows
Definition: SDL_sysvideo.h:317
float brightness
Definition: SDL_sysvideo.h:93
#define NULL
Definition: begin_code.h:167
#define SDL_OutOfMemory()
Definition: SDL_error.h:52
Uint32 last_fullscreen_flags
Definition: SDL_sysvideo.h:84
#define SDL_calloc
EGLSurface EGLNativeWindowType * window
Definition: eglext.h:1025
SDL_Window * prev
Definition: SDL_sysvideo.h:113
The type used to identify a window.
Definition: SDL_sysvideo.h:73
Uint32 id
Definition: SDL_sysvideo.h:76
static int SDL_UninitializedVideo()
Definition: SDL_video.c:437
int(* CreateSDLWindowFrom)(_THIS, SDL_Window *window, const void *data)
Definition: SDL_sysvideo.h:212
static SDL_INLINE void PrepareDragAndDropSupport(SDL_Window *window)
Definition: SDL_video.c:1362
Uint32 flags
Definition: SDL_sysvideo.h:83
Uint32 next_object_id
Definition: SDL_sysvideo.h:320
#define SDL_Unsupported()
Definition: SDL_error.h:53

◆ SDL_DestroyWindow()

void SDL_DestroyWindow ( SDL_Window window)

Destroy a window.

Definition at line 2712 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, SDL_VideoDevice::current_glwin, SDL_Window::data, SDL_VideoDevice::DestroyWindow, SDL_VideoDevice::DestroyWindowFramebuffer, SDL_Surface::flags, SDL_Window::flags, SDL_VideoDisplay::fullscreen_window, SDL_Window::gamma, SDL_Window::icon, SDL_Window::is_destroying, SDL_Window::magic, SDL_WindowUserData::name, SDL_WindowUserData::next, SDL_Window::next, NULL, SDL_Window::prev, SDL_DONTFREE, SDL_free, SDL_FreeSurface, SDL_GetDisplayForWindow(), SDL_GetKeyboardFocus, SDL_GetMouseFocus, SDL_GL_MakeCurrent(), SDL_GL_UnloadLibrary(), SDL_HideWindow(), SDL_SetKeyboardFocus(), SDL_SetMouseFocus(), SDL_TRUE, SDL_Vulkan_UnloadLibrary(), SDL_WINDOW_OPENGL, SDL_WINDOW_VULKAN, SDL_Window::surface, SDL_Window::title, and SDL_VideoDevice::windows.

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

2713 {
2714  SDL_VideoDisplay *display;
2715 
2716  CHECK_WINDOW_MAGIC(window,);
2717 
2718  window->is_destroying = SDL_TRUE;
2719 
2720  /* Restore video mode, etc. */
2721  SDL_HideWindow(window);
2722 
2723  /* Make sure this window no longer has focus */
2724  if (SDL_GetKeyboardFocus() == window) {
2726  }
2727  if (SDL_GetMouseFocus() == window) {
2729  }
2730 
2731  /* make no context current if this is the current context window. */
2732  if (window->flags & SDL_WINDOW_OPENGL) {
2733  if (_this->current_glwin == window) {
2734  SDL_GL_MakeCurrent(window, NULL);
2735  }
2736  }
2737 
2738  if (window->surface) {
2739  window->surface->flags &= ~SDL_DONTFREE;
2740  SDL_FreeSurface(window->surface);
2741  }
2744  }
2745  if (_this->DestroyWindow) {
2746  _this->DestroyWindow(_this, window);
2747  }
2748  if (window->flags & SDL_WINDOW_OPENGL) {
2750  }
2751  if (window->flags & SDL_WINDOW_VULKAN) {
2753  }
2754 
2755  display = SDL_GetDisplayForWindow(window);
2756  if (display->fullscreen_window == window) {
2757  display->fullscreen_window = NULL;
2758  }
2759 
2760  /* Now invalidate magic */
2761  window->magic = NULL;
2762 
2763  /* Free memory associated with the window */
2764  SDL_free(window->title);
2765  SDL_FreeSurface(window->icon);
2766  SDL_free(window->gamma);
2767  while (window->data) {
2768  SDL_WindowUserData *data = window->data;
2769 
2770  window->data = data->next;
2771  SDL_free(data->name);
2772  SDL_free(data);
2773  }
2774 
2775  /* Unlink the window from the list */
2776  if (window->next) {
2777  window->next->prev = window->prev;
2778  }
2779  if (window->prev) {
2780  window->prev->next = window->next;
2781  } else {
2782  _this->windows = window->next;
2783  }
2784 
2785  SDL_free(window);
2786 }
SDL_Window * next
Definition: SDL_sysvideo.h:114
void SDL_SetKeyboardFocus(SDL_Window *window)
Definition: SDL_keyboard.c:630
const void * magic
Definition: SDL_sysvideo.h:75
#define SDL_DONTFREE
Definition: SDL_surface.h:55
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: SDL_opengl.h:1974
SDL_bool is_destroying
Definition: SDL_sysvideo.h:101
void SDL_SetMouseFocus(SDL_Window *window)
Definition: SDL_mouse.c:211
void SDL_HideWindow(SDL_Window *window)
Hide a window.
Definition: SDL_video.c:2168
#define SDL_GetKeyboardFocus
Uint32 flags
Definition: SDL_surface.h:72
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
struct SDL_WindowUserData * next
Definition: SDL_sysvideo.h:69
SDL_VideoDisplay * SDL_GetDisplayForWindow(SDL_Window *window)
Definition: SDL_video.c:1089
#define SDL_FreeSurface
#define SDL_free
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:3516
void SDL_GL_UnloadLibrary(void)
Unload the OpenGL library previously loaded by SDL_GL_LoadLibrary().
Definition: SDL_video.c:2929
void(* DestroyWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:235
char * title
Definition: SDL_sysvideo.h:77
SDL_Window * windows
Definition: SDL_sysvideo.h:317
SDL_Window * fullscreen_window
Definition: SDL_sysvideo.h:135
void(* DestroyWindowFramebuffer)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:238
#define NULL
Definition: begin_code.h:167
#define SDL_GetMouseFocus
SDL_Surface * icon
Definition: SDL_sysvideo.h:78
SDL_Window * prev
Definition: SDL_sysvideo.h:113
void SDL_Vulkan_UnloadLibrary(void)
Unload the Vulkan loader library previously loaded by SDL_Vulkan_LoadLibrary().
Definition: SDL_video.c:4115
Uint16 * gamma
Definition: SDL_sysvideo.h:94
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
Uint32 flags
Definition: SDL_sysvideo.h:83
SDL_Surface * surface
Definition: SDL_sysvideo.h:97
SDL_Window * current_glwin
Definition: SDL_sysvideo.h:363
SDL_WindowUserData * data
Definition: SDL_sysvideo.h:109

◆ SDL_DisableScreenSaver()

void SDL_DisableScreenSaver ( void  )

Prevent the screen from being blanked by a screensaver.

See also
SDL_IsScreenSaverEnabled()
SDL_EnableScreenSaver()

Definition at line 2813 of file SDL_video.c.

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

Referenced by SDL_VideoInit().

2814 {
2815  if (!_this) {
2816  return;
2817  }
2818  if (_this->suspend_screensaver) {
2819  return;
2820  }
2822  if (_this->SuspendScreenSaver) {
2824  }
2825 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
SDL_bool suspend_screensaver
Definition: SDL_sysvideo.h:314
void(* SuspendScreenSaver)(_THIS)
Definition: SDL_sysvideo.h:284

◆ SDL_EnableScreenSaver()

void SDL_EnableScreenSaver ( void  )

Allow the screen to be blanked by a screensaver.

See also
SDL_IsScreenSaverEnabled()
SDL_DisableScreenSaver()

Definition at line 2798 of file SDL_video.c.

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

Referenced by SDL_VideoQuit().

2799 {
2800  if (!_this) {
2801  return;
2802  }
2803  if (!_this->suspend_screensaver) {
2804  return;
2805  }
2807  if (_this->SuspendScreenSaver) {
2809  }
2810 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
SDL_bool suspend_screensaver
Definition: SDL_sysvideo.h:314
void(* SuspendScreenSaver)(_THIS)
Definition: SDL_sysvideo.h:284

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

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

962 {
963  SDL_VideoDisplay *display;
964 
965  CHECK_DISPLAY_INDEX(displayIndex, NULL);
966 
967  display = &_this->displays[displayIndex];
968  return SDL_GetClosestDisplayModeForDisplay(display, mode, closest);
969 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
SDL_VideoDisplay * displays
Definition: SDL_sysvideo.h:316
#define NULL
Definition: begin_code.h:167
static SDL_DisplayMode * SDL_GetClosestDisplayModeForDisplay(SDL_VideoDisplay *display, const SDL_DisplayMode *mode, SDL_DisplayMode *closest)
Definition: SDL_video.c:852
#define CHECK_DISPLAY_INDEX(displayIndex, retval)
Definition: SDL_video.c:131

◆ SDL_GetCurrentDisplayMode()

int SDL_GetCurrentDisplayMode ( int  displayIndex,
SDL_DisplayMode mode 
)

Fill in information about the current display mode.

Definition at line 838 of file SDL_video.c.

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

839 {
840  SDL_VideoDisplay *display;
841 
842  CHECK_DISPLAY_INDEX(displayIndex, -1);
843 
844  display = &_this->displays[displayIndex];
845  if (mode) {
846  *mode = display->current_mode;
847  }
848  return 0;
849 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
SDL_DisplayMode current_mode
Definition: SDL_sysvideo.h:132
SDL_VideoDisplay * displays
Definition: SDL_sysvideo.h:316
#define CHECK_DISPLAY_INDEX(displayIndex, retval)
Definition: SDL_video.c:131

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

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

574 {
575  if (!_this) {
577  return NULL;
578  }
579  return _this->name;
580 }
const char * name
Definition: SDL_sysvideo.h:152
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
#define NULL
Definition: begin_code.h:167
static int SDL_UninitializedVideo()
Definition: SDL_video.c:437

◆ SDL_GetDesktopDisplayMode()

int SDL_GetDesktopDisplayMode ( int  displayIndex,
SDL_DisplayMode mode 
)

Fill in information about the desktop display mode.

Definition at line 824 of file SDL_video.c.

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

825 {
826  SDL_VideoDisplay *display;
827 
828  CHECK_DISPLAY_INDEX(displayIndex, -1);
829 
830  display = &_this->displays[displayIndex];
831  if (mode) {
832  *mode = display->desktop_mode;
833  }
834  return 0;
835 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
SDL_VideoDisplay * displays
Definition: SDL_sysvideo.h:316
SDL_DisplayMode desktop_mode
Definition: SDL_sysvideo.h:131
#define CHECK_DISPLAY_INDEX(displayIndex, retval)
Definition: SDL_video.c:131

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

674 {
675  CHECK_DISPLAY_INDEX(displayIndex, -1);
676 
677  if (rect) {
678  SDL_VideoDisplay *display = &_this->displays[displayIndex];
679 
680  if (_this->GetDisplayBounds) {
681  if (_this->GetDisplayBounds(_this, display, rect) == 0) {
682  return 0;
683  }
684  }
685 
686  /* Assume that the displays are left to right */
687  if (displayIndex == 0) {
688  rect->x = 0;
689  rect->y = 0;
690  } else {
691  SDL_GetDisplayBounds(displayIndex-1, rect);
692  rect->x += rect->w;
693  }
694  rect->w = display->current_mode.w;
695  rect->h = display->current_mode.h;
696  }
697  return 0; /* !!! FIXME: should this be an error if (rect==NULL) ? */
698 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
SDL_DisplayMode current_mode
Definition: SDL_sysvideo.h:132
SDL_VideoDisplay * displays
Definition: SDL_sysvideo.h:316
int(* GetDisplayBounds)(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect)
Definition: SDL_sysvideo.h:182
int x
Definition: SDL_rect.h:79
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:673
int w
Definition: SDL_rect.h:80
int h
Definition: SDL_rect.h:80
#define CHECK_DISPLAY_INDEX(displayIndex, retval)
Definition: SDL_video.c:131
int y
Definition: SDL_rect.h:79

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

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

721 {
722  SDL_VideoDisplay *display;
723 
724  CHECK_DISPLAY_INDEX(displayIndex, -1);
725 
726  display = &_this->displays[displayIndex];
727 
728  if (_this->GetDisplayDPI) {
729  if (_this->GetDisplayDPI(_this, display, ddpi, hdpi, vdpi) == 0) {
730  return 0;
731  }
732  } else {
733  return SDL_Unsupported();
734  }
735 
736  return -1;
737 }
int(* GetDisplayDPI)(_THIS, SDL_VideoDisplay *display, float *ddpi, float *hdpi, float *vdpi)
Definition: SDL_sysvideo.h:192
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
SDL_VideoDisplay * displays
Definition: SDL_sysvideo.h:316
#define CHECK_DISPLAY_INDEX(displayIndex, retval)
Definition: SDL_video.c:131
#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 806 of file SDL_video.c.

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

807 {
808  SDL_VideoDisplay *display;
809 
810  CHECK_DISPLAY_INDEX(displayIndex, -1);
811 
812  display = &_this->displays[displayIndex];
814  return SDL_SetError("index must be in the range of 0 - %d",
815  SDL_GetNumDisplayModesForDisplay(display) - 1);
816  }
817  if (mode) {
818  *mode = display->display_modes[index];
819  }
820  return 0;
821 }
static int SDL_GetNumDisplayModesForDisplay(SDL_VideoDisplay *display)
Definition: SDL_video.c:787
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
SDL_DisplayMode * display_modes
Definition: SDL_sysvideo.h:130
SDL_VideoDisplay * displays
Definition: SDL_sysvideo.h:316
GLuint index
#define SDL_SetError
#define CHECK_DISPLAY_INDEX(displayIndex, retval)
Definition: SDL_video.c:131

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

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

666 {
667  CHECK_DISPLAY_INDEX(displayIndex, NULL);
668 
669  return _this->displays[displayIndex].name;
670 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
SDL_VideoDisplay * displays
Definition: SDL_sysvideo.h:316
#define NULL
Definition: begin_code.h:167
#define CHECK_DISPLAY_INDEX(displayIndex, retval)
Definition: SDL_video.c:131

◆ SDL_GetDisplayOrientation()

SDL_DisplayOrientation SDL_GetDisplayOrientation ( int  displayIndex)

Get the orientation of a display.

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

Definition at line 740 of file SDL_video.c.

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

741 {
742  SDL_VideoDisplay *display;
743 
745 
746  display = &_this->displays[displayIndex];
747  return display->orientation;
748 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
SDL_VideoDisplay * displays
Definition: SDL_sysvideo.h:316
#define CHECK_DISPLAY_INDEX(displayIndex, retval)
Definition: SDL_video.c:131
SDL_DisplayOrientation orientation
Definition: SDL_sysvideo.h:133

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

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

701 {
702  CHECK_DISPLAY_INDEX(displayIndex, -1);
703 
704  if (rect) {
705  SDL_VideoDisplay *display = &_this->displays[displayIndex];
706 
708  if (_this->GetDisplayUsableBounds(_this, display, rect) == 0) {
709  return 0;
710  }
711  }
712 
713  /* Oh well, just give the entire display bounds. */
714  return SDL_GetDisplayBounds(displayIndex, rect);
715  }
716  return 0; /* !!! FIXME: should this be an error if (rect==NULL) ? */
717 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
SDL_VideoDisplay * displays
Definition: SDL_sysvideo.h:316
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:673
#define CHECK_DISPLAY_INDEX(displayIndex, retval)
Definition: SDL_video.c:131
int(* GetDisplayUsableBounds)(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect)
Definition: SDL_sysvideo.h:187

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

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

2576 {
2578  return _this->grabbed_window;
2579 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
#define SDL_assert(condition)
Definition: SDL_assert.h:169
SDL_Window * grabbed_window
Definition: SDL_sysvideo.h:318
Uint32 flags
Definition: SDL_sysvideo.h:83

◆ SDL_GetNumDisplayModes()

int SDL_GetNumDisplayModes ( int  displayIndex)

Returns the number of available display modes.

See also
SDL_GetDisplayMode()

Definition at line 798 of file SDL_video.c.

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

799 {
800  CHECK_DISPLAY_INDEX(displayIndex, -1);
801 
802  return SDL_GetNumDisplayModesForDisplay(&_this->displays[displayIndex]);
803 }
static int SDL_GetNumDisplayModesForDisplay(SDL_VideoDisplay *display)
Definition: SDL_video.c:787
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
SDL_VideoDisplay * displays
Definition: SDL_sysvideo.h:316
#define CHECK_DISPLAY_INDEX(displayIndex, retval)
Definition: SDL_video.c:131

◆ SDL_GetNumVideoDisplays()

int SDL_GetNumVideoDisplays ( void  )

Returns the number of available video displays.

See also
SDL_GetDisplayBounds()

Definition at line 632 of file SDL_video.c.

References SDL_VideoDevice::num_displays, and SDL_UninitializedVideo().

633 {
634  if (!_this) {
636  return 0;
637  }
638  return _this->num_displays;
639 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
static int SDL_UninitializedVideo()
Definition: SDL_video.c:437

◆ SDL_GetNumVideoDrivers()

int SDL_GetNumVideoDrivers ( void  )

Get the number of video drivers compiled into SDL.

See also
SDL_GetVideoDriver()

Definition at line 443 of file SDL_video.c.

References SDL_arraysize.

Referenced by SDL_GetVideoDriver().

444 {
445  return SDL_arraysize(bootstrap) - 1;
446 }
static VideoBootStrap * bootstrap[]
Definition: SDL_video.c:60
#define SDL_arraysize(array)
Definition: SDL_stdinc.h:115

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

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

450 {
451  if (index >= 0 && index < SDL_GetNumVideoDrivers()) {
452  return bootstrap[index]->name;
453  }
454  return NULL;
455 }
int SDL_GetNumVideoDrivers(void)
Get the number of video drivers compiled into SDL.
Definition: SDL_video.c:443
GLuint index
#define NULL
Definition: begin_code.h:167
static VideoBootStrap * bootstrap[]
Definition: SDL_video.c:60
const char * name
Definition: SDL_sysvideo.h:399

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

References CHECK_WINDOW_MAGIC, SDL_VideoDevice::GetWindowBordersSize, and SDL_Unsupported.

2047 {
2048  int dummy = 0;
2049 
2050  if (!top) { top = &dummy; }
2051  if (!left) { left = &dummy; }
2052  if (!right) { right = &dummy; }
2053  if (!bottom) { bottom = &dummy; }
2054 
2055  /* Always initialize, so applications don't have to care */
2056  *top = *left = *bottom = *right = 0;
2057 
2058  CHECK_WINDOW_MAGIC(window, -1);
2059 
2060  if (!_this->GetWindowBordersSize) {
2061  return SDL_Unsupported();
2062  }
2063 
2064  return _this->GetWindowBordersSize(_this, window, top, left, bottom, right);
2065 }
GLdouble GLdouble right
GLint GLint bottom
int(* GetWindowBordersSize)(_THIS, SDL_Window *window, int *top, int *left, int *bottom, int *right)
Definition: SDL_sysvideo.h:219
GLdouble GLdouble GLdouble GLdouble top
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
#define SDL_Unsupported()
Definition: SDL_error.h:53
GLint left

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

References SDL_Window::brightness, and CHECK_WINDOW_MAGIC.

2372 {
2373  CHECK_WINDOW_MAGIC(window, 1.0f);
2374 
2375  return window->brightness;
2376 }
GLfloat f
float brightness
Definition: SDL_sysvideo.h:93
#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 1843 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().

1844 {
1846 
1847  CHECK_WINDOW_MAGIC(window, NULL);
1848 
1849  /* Input validation */
1850  if (name == NULL || name[0] == '\0') {
1851  SDL_InvalidParamError("name");
1852  return NULL;
1853  }
1854 
1855  for (data = window->data; data; data = data->next) {
1856  if (data->name && SDL_strcmp(data->name, name) == 0) {
1857  return data->data;
1858  }
1859  }
1860  return NULL;
1861 }
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: SDL_opengl.h:1974
#define SDL_InvalidParamError(param)
Definition: SDL_error.h:54
GLuint const GLchar * name
struct SDL_WindowUserData * next
Definition: SDL_sysvideo.h:69
#define NULL
Definition: begin_code.h:167
#define SDL_strcmp
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
SDL_WindowUserData * data
Definition: SDL_sysvideo.h:109

◆ 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 1029 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_Window::w, SDL_Rect::w, SDL_Point::x, SDL_Rect::x, SDL_Window::x, SDL_Point::y, SDL_Window::y, and SDL_Rect::y.

Referenced by SDL_GetDisplayForWindow(), and SDL_GetWindowPosition().

1030 {
1031  int displayIndex;
1032  int i, dist;
1033  int closest = -1;
1034  int closest_dist = 0x7FFFFFFF;
1035  SDL_Point center;
1036  SDL_Point delta;
1037  SDL_Rect rect;
1038 
1039  CHECK_WINDOW_MAGIC(window, -1);
1040 
1041  if (SDL_WINDOWPOS_ISUNDEFINED(window->x) ||
1042  SDL_WINDOWPOS_ISCENTERED(window->x)) {
1043  displayIndex = (window->x & 0xFFFF);
1044  if (displayIndex >= _this->num_displays) {
1045  displayIndex = 0;
1046  }
1047  return displayIndex;
1048  }
1049  if (SDL_WINDOWPOS_ISUNDEFINED(window->y) ||
1050  SDL_WINDOWPOS_ISCENTERED(window->y)) {
1051  displayIndex = (window->y & 0xFFFF);
1052  if (displayIndex >= _this->num_displays) {
1053  displayIndex = 0;
1054  }
1055  return displayIndex;
1056  }
1057 
1058  /* Find the display containing the window */
1059  for (i = 0; i < _this->num_displays; ++i) {
1060  SDL_VideoDisplay *display = &_this->displays[i];
1061 
1062  if (display->fullscreen_window == window) {
1063  return i;
1064  }
1065  }
1066  center.x = window->x + window->w / 2;
1067  center.y = window->y + window->h / 2;
1068  for (i = 0; i < _this->num_displays; ++i) {
1069  SDL_GetDisplayBounds(i, &rect);
1070  if (SDL_EnclosePoints(&center, 1, &rect, NULL)) {
1071  return i;
1072  }
1073 
1074  delta.x = center.x - (rect.x + rect.w / 2);
1075  delta.y = center.y - (rect.y + rect.h / 2);
1076  dist = (delta.x*delta.x + delta.y*delta.y);
1077  if (dist < closest_dist) {
1078  closest = i;
1079  closest_dist = dist;
1080  }
1081  }
1082  if (closest < 0) {
1083  SDL_SetError("Couldn't find any displays");
1084  }
1085  return closest;
1086 }
#define SDL_WINDOWPOS_ISUNDEFINED(X)
Definition: SDL_video.h:131
SDL_Rect rect
Definition: testrelative.c:27
The structure that defines a point (integer)
Definition: SDL_rect.h:48
#define SDL_WINDOWPOS_ISCENTERED(X)
Definition: SDL_video.h:140
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:316
int x
Definition: SDL_rect.h:79
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:673
int w
Definition: SDL_rect.h:80
SDL_Window * fullscreen_window
Definition: SDL_sysvideo.h:135
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:167
#define SDL_SetError
int h
Definition: SDL_rect.h:80
#define SDL_EnclosePoints
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
int y
Definition: SDL_rect.h:79
A rectangle, with the origin at the upper left (integer).
Definition: SDL_rect.h:77

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

1121 {
1122  SDL_DisplayMode fullscreen_mode;
1123  SDL_VideoDisplay *display;
1124 
1125  CHECK_WINDOW_MAGIC(window, -1);
1126 
1127  if (!mode) {
1128  return SDL_InvalidParamError("mode");
1129  }
1130 
1131  fullscreen_mode = window->fullscreen_mode;
1132  if (!fullscreen_mode.w) {
1133  fullscreen_mode.w = window->windowed.w;
1134  }
1135  if (!fullscreen_mode.h) {
1136  fullscreen_mode.h = window->windowed.h;
1137  }
1138 
1139  display = SDL_GetDisplayForWindow(window);
1140 
1141  /* if in desktop size mode, just return the size of the desktop */
1143  fullscreen_mode = display->desktop_mode;
1145  &fullscreen_mode,
1146  &fullscreen_mode)) {
1147  return SDL_SetError("Couldn't find display mode match");
1148  }
1149 
1150  if (mode) {
1151  *mode = fullscreen_mode;
1152  }
1153  return 0;
1154 }
SDL_DisplayMode fullscreen_mode
Definition: SDL_sysvideo.h:89
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:87
SDL_VideoDisplay * SDL_GetDisplayForWindow(SDL_Window *window)
Definition: SDL_video.c:1089
int w
Definition: SDL_rect.h:80
SDL_DisplayMode desktop_mode
Definition: SDL_sysvideo.h:131
#define SDL_SetError
int h
Definition: SDL_rect.h:80
static SDL_DisplayMode * SDL_GetClosestDisplayModeForDisplay(SDL_VideoDisplay *display, const SDL_DisplayMode *mode, SDL_DisplayMode *closest)
Definition: SDL_video.c:852
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
Uint32 flags
Definition: SDL_sysvideo.h:83

◆ SDL_GetWindowFlags()

Uint32 SDL_GetWindowFlags ( SDL_Window window)

Get the window flags.

Definition at line 1741 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, and SDL_Window::flags.

Referenced by SDL_ShowMessageBox().

1742 {
1743  CHECK_WINDOW_MAGIC(window, 0);
1744 
1745  return window->flags;
1746 }
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
Uint32 flags
Definition: SDL_sysvideo.h:83

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

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

1726 {
1727  SDL_Window *window;
1728 
1729  if (!_this) {
1730  return NULL;
1731  }
1732  for (window = _this->windows; window; window = window->next) {
1733  if (window->id == id) {
1734  return window;
1735  }
1736  }
1737  return NULL;
1738 }
SDL_Window * next
Definition: SDL_sysvideo.h:114
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
SDL_Window * windows
Definition: SDL_sysvideo.h:317
#define NULL
Definition: begin_code.h:167
EGLSurface EGLNativeWindowType * window
Definition: eglext.h:1025
The type used to identify a window.
Definition: SDL_sysvideo.h:73
Uint32 id
Definition: SDL_sysvideo.h:76

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

2478 {
2479  CHECK_WINDOW_MAGIC(window, -1);
2480 
2481  if (!window->gamma) {
2482  int i;
2483 
2484  window->gamma = (Uint16 *)SDL_malloc(256*6*sizeof(Uint16));
2485  if (!window->gamma) {
2486  return SDL_OutOfMemory();
2487  }
2488  window->saved_gamma = window->gamma + 3*256;
2489 
2490  if (_this->GetWindowGammaRamp) {
2491  if (_this->GetWindowGammaRamp(_this, window, window->gamma) < 0) {
2492  return -1;
2493  }
2494  } else {
2495  /* Create an identity gamma ramp */
2496  for (i = 0; i < 256; ++i) {
2497  Uint16 value = (Uint16)((i << 8) | i);
2498 
2499  window->gamma[0*256+i] = value;
2500  window->gamma[1*256+i] = value;
2501  window->gamma[2*256+i] = value;
2502  }
2503  }
2504  SDL_memcpy(window->saved_gamma, window->gamma, 3*256*sizeof(Uint16));
2505  }
2506 
2507  if (red) {
2508  SDL_memcpy(red, &window->gamma[0*256], 256*sizeof(Uint16));
2509  }
2510  if (green) {
2511  SDL_memcpy(green, &window->gamma[1*256], 256*sizeof(Uint16));
2512  }
2513  if (blue) {
2514  SDL_memcpy(blue, &window->gamma[2*256], 256*sizeof(Uint16));
2515  }
2516  return 0;
2517 }
uint16_t Uint16
Definition: SDL_stdinc.h:191
GLbyte green
Uint16 * saved_gamma
Definition: SDL_sysvideo.h:95
const GLubyte GLuint red
Definition: SDL_glfuncs.h:79
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
#define SDL_memcpy
GLsizei const GLfloat * value
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
GLbyte GLbyte blue
int(* GetWindowGammaRamp)(_THIS, SDL_Window *window, Uint16 *ramp)
Definition: SDL_sysvideo.h:233
#define SDL_malloc
Uint16 * gamma
Definition: SDL_sysvideo.h:94
#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 2567 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.

2568 {
2569  CHECK_WINDOW_MAGIC(window, SDL_FALSE);
2571  return window == _this->grabbed_window;
2572 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
#define SDL_assert(condition)
Definition: SDL_assert.h:169
SDL_Window * grabbed_window
Definition: SDL_sysvideo.h:318
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
Uint32 flags
Definition: SDL_sysvideo.h:83

◆ SDL_GetWindowID()

Uint32 SDL_GetWindowID ( SDL_Window window)

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

Definition at line 1717 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, and SDL_Window::id.

1718 {
1719  CHECK_WINDOW_MAGIC(window, 0);
1720 
1721  return window->id;
1722 }
Uint32 id
Definition: SDL_sysvideo.h:76
#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 2141 of file SDL_video.c.

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

2142 {
2143  CHECK_WINDOW_MAGIC(window,);
2144  if (max_w) {
2145  *max_w = window->max_w;
2146  }
2147  if (max_h) {
2148  *max_h = window->max_h;
2149  }
2150 }
#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 2099 of file SDL_video.c.

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

2100 {
2101  CHECK_WINDOW_MAGIC(window,);
2102  if (min_w) {
2103  *min_w = window->min_w;
2104  }
2105  if (min_h) {
2106  *min_h = window->min_h;
2107  }
2108 }
#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 2403 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, and SDL_Window::opacity.

2404 {
2405  CHECK_WINDOW_MAGIC(window, -1);
2406 
2407  if (out_opacity) {
2408  *out_opacity = window->opacity;
2409  }
2410 
2411  return 0;
2412 }
float opacity
Definition: SDL_sysvideo.h:91
#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 1157 of file SDL_video.c.

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

1158 {
1159  SDL_VideoDisplay *display;
1160 
1162 
1163  display = SDL_GetDisplayForWindow(window);
1164  return display->current_mode.format;
1165 }
SDL_VideoDisplay * SDL_GetDisplayForWindow(SDL_Window *window)
Definition: SDL_video.c:1089
SDL_DisplayMode current_mode
Definition: SDL_sysvideo.h:132
#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 1908 of file SDL_video.c.

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

1909 {
1910  CHECK_WINDOW_MAGIC(window,);
1911 
1912  /* Fullscreen windows are always at their display's origin */
1913  if (window->flags & SDL_WINDOW_FULLSCREEN) {
1914  int displayIndex;
1915 
1916  if (x) {
1917  *x = 0;
1918  }
1919  if (y) {
1920  *y = 0;
1921  }
1922 
1923  /* Find the window's monitor and update to the
1924  monitor offset. */
1925  displayIndex = SDL_GetWindowDisplayIndex(window);
1926  if (displayIndex >= 0) {
1927  SDL_Rect bounds;
1928 
1929  SDL_zero(bounds);
1930 
1931  SDL_GetDisplayBounds(displayIndex, &bounds);
1932  if (x) {
1933  *x = bounds.x;
1934  }
1935  if (y) {
1936  *y = bounds.y;
1937  }
1938  }
1939  } else {
1940  if (x) {
1941  *x = window->x;
1942  }
1943  if (y) {
1944  *y = window->y;
1945  }
1946  }
1947 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
#define SDL_zero(x)
Definition: SDL_stdinc.h:416
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574
int x
Definition: SDL_rect.h:79
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:673
#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:1029
Uint32 flags
Definition: SDL_sysvideo.h:83
int y
Definition: SDL_rect.h:79
A rectangle, with the origin at the upper left (integer).
Definition: SDL_rect.h:77

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

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

Referenced by SDL_GL_GetDrawableSize(), and SDL_Vulkan_GetDrawableSize().

2035 {
2036  CHECK_WINDOW_MAGIC(window,);
2037  if (w) {
2038  *w = window->w;
2039  }
2040  if (h) {
2041  *h = window->h;
2042  }
2043 }
GLfloat GLfloat GLfloat GLfloat h
GLubyte GLubyte GLubyte GLubyte w
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120

◆ 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 2309 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.

2310 {
2311  CHECK_WINDOW_MAGIC(window, NULL);
2312 
2313  if (!window->surface_valid) {
2314  if (window->surface) {
2315  window->surface->flags &= ~SDL_DONTFREE;
2316  SDL_FreeSurface(window->surface);
2317  }
2318  window->surface = SDL_CreateWindowFramebuffer(window);
2319  if (window->surface) {
2320  window->surface_valid = SDL_TRUE;
2321  window->surface->flags |= SDL_DONTFREE;
2322  }
2323  }
2324  return window->surface;
2325 }
#define SDL_DONTFREE
Definition: SDL_surface.h:55
Uint32 flags
Definition: SDL_surface.h:72
#define SDL_FreeSurface
#define NULL
Definition: begin_code.h:167
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
SDL_bool surface_valid
Definition: SDL_sysvideo.h:98
SDL_Surface * surface
Definition: SDL_sysvideo.h:97
static SDL_Surface * SDL_CreateWindowFramebuffer(SDL_Window *window)
Definition: SDL_video.c:2285

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

References CHECK_WINDOW_MAGIC, and SDL_Window::title.

1767 {
1768  CHECK_WINDOW_MAGIC(window, "");
1769 
1770  return window->title ? window->title : "";
1771 }
char * title
Definition: SDL_sysvideo.h:77
#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 3493 of file SDL_video.c.

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

Referenced by ShouldUseTextureFramebuffer().

3494 {
3496  CHECK_WINDOW_MAGIC(window, NULL);
3497 
3498  if (!(window->flags & SDL_WINDOW_OPENGL)) {
3499  SDL_SetError("The specified window isn't an OpenGL window");
3500  return NULL;
3501  }
3502 
3503  ctx = _this->GL_CreateContext(_this, window);
3504 
3505  /* Creating a context is assumed to make it current in the SDL driver. */
3506  if (ctx) {
3508  _this->current_glctx = ctx;
3511  }
3512  return ctx;
3513 }
#define SDL_TLSSet
SDL_TLSID current_glwin_tls
Definition: SDL_sysvideo.h:365
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
void * SDL_GLContext
An opaque handle to an OpenGL context.
Definition: SDL_video.h:193
SDL_GLContext current_glctx
Definition: SDL_sysvideo.h:364
SDL_GLContext(* GL_CreateContext)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:258
#define NULL
Definition: begin_code.h:167
#define SDL_SetError
EGLSurface EGLNativeWindowType * window
Definition: eglext.h:1025
SDL_TLSID current_glctx_tls
Definition: SDL_sysvideo.h:366
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
Uint32 flags
Definition: SDL_sysvideo.h:83
SDL_Window * current_glwin
Definition: SDL_sysvideo.h:363
EGLContext ctx
Definition: eglext.h:208

◆ SDL_GL_DeleteContext()

void SDL_GL_DeleteContext ( SDL_GLContext  context)

Delete an OpenGL context.

See also
SDL_GL_CreateContext()

Definition at line 3624 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().

3625 {
3626  if (!_this || !context) {
3627  return;
3628  }
3629 
3630  if (SDL_GL_GetCurrentContext() == context) {
3632  }
3633 
3635 }
static screen_context_t context
Definition: video.c:25
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:3516
#define NULL
Definition: begin_code.h:167
SDL_GLContext SDL_GL_GetCurrentContext(void)
Get the currently active OpenGL context.
Definition: SDL_video.c:3557
void(* GL_DeleteContext)(_THIS, SDL_GLContext context)
Definition: SDL_sysvideo.h:264

◆ 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 2954 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.

Referenced by SDL_GL_DeduceMaxSupportedESProfile().

2955 {
2956 #if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
2957  const GLubyte *(APIENTRY * glGetStringFunc) (GLenum);
2958  const char *extensions;
2959  const char *start;
2960  const char *where, *terminator;
2961 
2962  /* Extension names should not have spaces. */
2963  where = SDL_strchr(extension, ' ');
2964  if (where || *extension == '\0') {
2965  return SDL_FALSE;
2966  }
2967  /* See if there's an environment variable override */
2968  start = SDL_getenv(extension);
2969  if (start && *start == '0') {
2970  return SDL_FALSE;
2971  }
2972 
2973  /* Lookup the available extensions */
2974 
2975  glGetStringFunc = SDL_GL_GetProcAddress("glGetString");
2976  if (!glGetStringFunc) {
2977  return SDL_FALSE;
2978  }
2979 
2980  if (isAtLeastGL3((const char *) glGetStringFunc(GL_VERSION))) {
2981  const GLubyte *(APIENTRY * glGetStringiFunc) (GLenum, GLuint);
2982  void (APIENTRY * glGetIntegervFunc) (GLenum pname, GLint * params);
2983  GLint num_exts = 0;
2984  GLint i;
2985 
2986  glGetStringiFunc = SDL_GL_GetProcAddress("glGetStringi");
2987  glGetIntegervFunc = SDL_GL_GetProcAddress("glGetIntegerv");
2988  if ((!glGetStringiFunc) || (!glGetIntegervFunc)) {
2989  return SDL_FALSE;
2990  }
2991 
2992  #ifndef GL_NUM_EXTENSIONS
2993  #define GL_NUM_EXTENSIONS 0x821D
2994  #endif
2995  glGetIntegervFunc(GL_NUM_EXTENSIONS, &num_exts);
2996  for (i = 0; i < num_exts; i++) {
2997  const char *thisext = (const char *) glGetStringiFunc(GL_EXTENSIONS, i);
2998  if (SDL_strcmp(thisext, extension) == 0) {
2999  return SDL_TRUE;
3000  }
3001  }
3002 
3003  return SDL_FALSE;
3004  }
3005 
3006  /* Try the old way with glGetString(GL_EXTENSIONS) ... */
3007 
3008  extensions = (const char *) glGetStringFunc(GL_EXTENSIONS);
3009  if (!extensions) {
3010  return SDL_FALSE;
3011  }
3012  /*
3013  * It takes a bit of care to be fool-proof about parsing the OpenGL
3014  * extensions string. Don't be fooled by sub-strings, etc.
3015  */
3016 
3017  start = extensions;
3018 
3019  for (;;) {
3020  where = SDL_strstr(start, extension);
3021  if (!where)
3022  break;
3023 
3024  terminator = where + SDL_strlen(extension);
3025  if (where == extensions || *(where - 1) == ' ')
3026  if (*terminator == ' ' || *terminator == '\0')
3027  return SDL_TRUE;
3028 
3029  start = terminator;
3030  }
3031  return SDL_FALSE;
3032 #else
3033  return SDL_FALSE;
3034 #endif
3035 }
#define APIENTRY
Definition: SDL_opengl.h:139
int GLint
Definition: SDL_opengl.h:182
#define GL_EXTENSIONS
Definition: SDL_opengl.h:716
GLuint start
Definition: SDL_opengl.h:1571
#define GL_VERSION
Definition: SDL_opengl.h:715
#define SDL_strchr
#define GL_NUM_EXTENSIONS
static SDL_INLINE SDL_bool isAtLeastGL3(const char *verstr)
Definition: SDL_video.c:2947
unsigned char GLubyte
Definition: SDL_opengl.h:183
#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:176
unsigned int GLuint
Definition: SDL_opengl.h:185
#define SDL_strlen
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
const GLfloat * params
void * SDL_GL_GetProcAddress(const char *proc)
Get the address of an OpenGL function.
Definition: SDL_video.c:2907
#define SDL_strcmp
GLenum pname
#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.

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

Definition at line 3244 of file SDL_video.c.

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

3245 {
3246 #if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
3247  GLenum (APIENTRY *glGetErrorFunc) (void);
3248  GLenum attrib = 0;
3249  GLenum error = 0;
3250 
3251  /*
3252  * Some queries in Core Profile desktop OpenGL 3+ contexts require
3253  * glGetFramebufferAttachmentParameteriv instead of glGetIntegerv. Note that
3254  * the enums we use for the former function don't exist in OpenGL ES 2, and
3255  * the function itself doesn't exist prior to OpenGL 3 and OpenGL ES 2.
3256  */
3257 #if SDL_VIDEO_OPENGL
3258  const GLubyte *(APIENTRY *glGetStringFunc) (GLenum name);
3259  void (APIENTRY *glGetFramebufferAttachmentParameterivFunc) (GLenum target, GLenum attachment, GLenum pname, GLint* params);
3260  GLenum attachment = GL_BACK_LEFT;
3261  GLenum attachmentattrib = 0;
3262 #endif
3263 
3264  if (!value) {
3265  return SDL_InvalidParamError("value");
3266  }
3267 
3268  /* Clear value in any case */
3269  *value = 0;
3270 
3271  if (!_this) {
3272  return SDL_UninitializedVideo();
3273  }
3274 
3275  switch (attr) {
3276  case SDL_GL_RED_SIZE:
3277 #if SDL_VIDEO_OPENGL
3278  attachmentattrib = GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE;
3279 #endif
3280  attrib = GL_RED_BITS;
3281  break;
3282  case SDL_GL_BLUE_SIZE:
3283 #if SDL_VIDEO_OPENGL
3284  attachmentattrib = GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE;
3285 #endif
3286  attrib = GL_BLUE_BITS;
3287  break;
3288  case SDL_GL_GREEN_SIZE:
3289 #if SDL_VIDEO_OPENGL
3290  attachmentattrib = GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE;
3291 #endif
3292  attrib = GL_GREEN_BITS;
3293  break;
3294  case SDL_GL_ALPHA_SIZE:
3295 #if SDL_VIDEO_OPENGL
3296  attachmentattrib = GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE;
3297 #endif
3298  attrib = GL_ALPHA_BITS;
3299  break;
3300  case SDL_GL_DOUBLEBUFFER:
3301 #if SDL_VIDEO_OPENGL
3302  attrib = GL_DOUBLEBUFFER;
3303  break;
3304 #else
3305  /* OpenGL ES 1.0 and above specifications have EGL_SINGLE_BUFFER */
3306  /* parameter which switches double buffer to single buffer. OpenGL ES */
3307  /* SDL driver must set proper value after initialization */
3309  return 0;
3310 #endif
3311  case SDL_GL_DEPTH_SIZE:
3312 #if SDL_VIDEO_OPENGL
3313  attachment = GL_DEPTH;
3314  attachmentattrib = GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE;
3315 #endif
3316  attrib = GL_DEPTH_BITS;
3317  break;
3318  case SDL_GL_STENCIL_SIZE:
3319 #if SDL_VIDEO_OPENGL
3320  attachment = GL_STENCIL;
3321  attachmentattrib = GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE;
3322 #endif
3323  attrib = GL_STENCIL_BITS;
3324  break;
3325 #if SDL_VIDEO_OPENGL
3326  case SDL_GL_ACCUM_RED_SIZE:
3327  attrib = GL_ACCUM_RED_BITS;
3328  break;
3330  attrib = GL_ACCUM_GREEN_BITS;
3331  break;
3333  attrib = GL_ACCUM_BLUE_BITS;
3334  break;
3336  attrib = GL_ACCUM_ALPHA_BITS;
3337  break;
3338  case SDL_GL_STEREO:
3339  attrib = GL_STEREO;
3340  break;
3341 #else
3342  case SDL_GL_ACCUM_RED_SIZE:
3346  case SDL_GL_STEREO:
3347  /* none of these are supported in OpenGL ES */
3348  *value = 0;
3349  return 0;
3350 #endif
3352  attrib = GL_SAMPLE_BUFFERS;
3353  break;
3355  attrib = GL_SAMPLES;
3356  break;
3358 #if SDL_VIDEO_OPENGL
3359  attrib = GL_CONTEXT_RELEASE_BEHAVIOR;
3360 #else
3362 #endif
3363  break;
3364  case SDL_GL_BUFFER_SIZE:
3365  {
3366  int rsize = 0, gsize = 0, bsize = 0, asize = 0;
3367 
3368  /* There doesn't seem to be a single flag in OpenGL for this! */
3369  if (SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &rsize) < 0) {
3370  return -1;
3371  }
3372  if (SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &gsize) < 0) {
3373  return -1;
3374  }
3375  if (SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &bsize) < 0) {
3376  return -1;
3377  }
3378  if (SDL_GL_GetAttribute(SDL_GL_ALPHA_SIZE, &asize) < 0) {
3379  return -1;
3380  }
3381 
3382  *value = rsize + gsize + bsize + asize;
3383  return 0;
3384  }
3386  {
3387  /* FIXME: How do we get this information? */
3388  *value = (_this->gl_config.accelerated != 0);
3389  return 0;
3390  }
3392  {
3394  return 0;
3395  }
3397  {
3399  return 0;
3400  }
3402  {
3404  return 0;
3405  }
3406  case SDL_GL_CONTEXT_EGL:
3407  /* FIXME: SDL_GL_CONTEXT_EGL to be deprecated in SDL 2.1 */
3408  {
3410  *value = 1;
3411  }
3412  else {
3413  *value = 0;
3414  }
3415  return 0;
3416  }
3417  case SDL_GL_CONTEXT_FLAGS:
3418  {
3419  *value = _this->gl_config.flags;
3420  return 0;
3421  }
3423  {
3425  return 0;
3426  }
3428  {
3430  return 0;
3431  }
3433  {
3435  return 0;
3436  }
3438  {
3440  return 0;
3441  }
3442  default:
3443  return SDL_SetError("Unknown OpenGL attribute");
3444  }
3445 
3446 #if SDL_VIDEO_OPENGL
3447  glGetStringFunc = SDL_GL_GetProcAddress("glGetString");
3448  if (!glGetStringFunc) {
3449  return -1;
3450  }
3451 
3452  if (attachmentattrib && isAtLeastGL3((const char *) glGetStringFunc(GL_VERSION))) {
3453  glGetFramebufferAttachmentParameterivFunc = SDL_GL_GetProcAddress("glGetFramebufferAttachmentParameteriv");
3454 
3455  if (glGetFramebufferAttachmentParameterivFunc) {
3456  glGetFramebufferAttachmentParameterivFunc(GL_FRAMEBUFFER, attachment, attachmentattrib, (GLint *) value);
3457  } else {
3458  return -1;
3459  }
3460  } else
3461 #endif
3462  {
3463  void (APIENTRY *glGetIntegervFunc) (GLenum pname, GLint * params);
3464  glGetIntegervFunc = SDL_GL_GetProcAddress("glGetIntegerv");
3465  if (glGetIntegervFunc) {
3466  glGetIntegervFunc(attrib, (GLint *) value);
3467  } else {
3468  return -1;
3469  }
3470  }
3471 
3472  glGetErrorFunc = SDL_GL_GetProcAddress("glGetError");
3473  if (!glGetErrorFunc) {
3474  return -1;
3475  }
3476 
3477  error = glGetErrorFunc();
3478  if (error != GL_NO_ERROR) {
3479  if (error == GL_INVALID_ENUM) {
3480  return SDL_SetError("OpenGL error: GL_INVALID_ENUM");
3481  } else if (error == GL_INVALID_VALUE) {
3482  return SDL_SetError("OpenGL error: GL_INVALID_VALUE");
3483  }
3484  return SDL_SetError("OpenGL error: %08X", error);
3485  }
3486  return 0;
3487 #else
3488  return SDL_Unsupported();
3489 #endif /* SDL_VIDEO_OPENGL */
3490 }
#define GL_STENCIL_BITS
Definition: SDL_opengl.h:474
#define GL_INVALID_ENUM
Definition: SDL_opengl.h:720
#define GL_SAMPLE_BUFFERS
Definition: SDL_opengl.h:1839
#define GL_BACK_LEFT
Definition: SDL_opengl.h:499
#define GL_DOUBLEBUFFER
Definition: SDL_opengl.h:521
#define APIENTRY
Definition: SDL_opengl.h:139
#define GL_RED_BITS
Definition: SDL_opengl.h:513
int GLint
Definition: SDL_opengl.h:182
#define GL_CONTEXT_RELEASE_BEHAVIOR
#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE
#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE
#define GL_SAMPLES
Definition: SDL_opengl.h:1840
#define GL_DEPTH_BITS
Definition: SDL_opengl.h:328
#define GL_VERSION
Definition: SDL_opengl.h:715
#define SDL_InvalidParamError(param)
Definition: SDL_error.h:54
#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE
#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE
#define GL_ACCUM_ALPHA_BITS
Definition: SDL_opengl.h:383
#define GL_FRAMEBUFFER
GLuint const GLchar * name
#define GL_NO_ERROR
Definition: SDL_opengl.h:719
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
#define GL_BLUE_BITS
Definition: SDL_opengl.h:515
static SDL_INLINE SDL_bool isAtLeastGL3(const char *verstr)
Definition: SDL_video.c:2947
#define GL_STENCIL
Definition: SDL_opengl.h:526
#define GL_ALPHA_BITS
Definition: SDL_opengl.h:512
GLsizei const GLfloat * value
#define GL_DEPTH
Definition: SDL_opengl.h:525
#define GL_ACCUM_RED_BITS
Definition: SDL_opengl.h:380
#define GL_INVALID_VALUE
Definition: SDL_opengl.h:721
int framebuffer_srgb_capable
Definition: SDL_sysvideo.h:350
unsigned char GLubyte
Definition: SDL_opengl.h:183
#define GL_CONTEXT_RELEASE_BEHAVIOR_KHR
Definition: gl2ext.h:83
#define GL_ACCUM_GREEN_BITS
Definition: SDL_opengl.h:381
#define GL_STEREO
Definition: SDL_opengl.h:522
int share_with_current_context
Definition: SDL_sysvideo.h:347
GLenum target
unsigned int GLenum
Definition: SDL_opengl.h:176
#define SDL_SetError
#define GL_ACCUM_BLUE_BITS
Definition: SDL_opengl.h:382
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
GLenum attachment
static int SDL_UninitializedVideo()
Definition: SDL_video.c:437
const GLfloat * params
void * SDL_GL_GetProcAddress(const char *proc)
Get the address of an OpenGL function.
Definition: SDL_video.c:2907
#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:3244
#define GL_GREEN_BITS
Definition: SDL_opengl.h:514
GLenum pname
#define SDL_Unsupported()
Definition: SDL_error.h:53
struct SDL_VideoDevice::@262 gl_config
#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE

◆ SDL_GL_GetCurrentContext()

SDL_GLContext SDL_GL_GetCurrentContext ( void  )

Get the currently active OpenGL context.

Definition at line 3557 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().

3558 {
3559  if (!_this) {
3561  return NULL;
3562  }
3564 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
void * SDL_GLContext
An opaque handle to an OpenGL context.
Definition: SDL_video.h:193
#define SDL_TLSGet
#define NULL
Definition: begin_code.h:167
SDL_TLSID current_glctx_tls
Definition: SDL_sysvideo.h:366
static int SDL_UninitializedVideo()
Definition: SDL_video.c:437

◆ SDL_GL_GetCurrentWindow()

SDL_Window* SDL_GL_GetCurrentWindow ( void  )

Get the currently active OpenGL window.

Definition at line 3547 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().

3548 {
3549  if (!_this) {
3551  return NULL;
3552  }
3554 }
SDL_TLSID current_glwin_tls
Definition: SDL_sysvideo.h:365
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
#define SDL_TLSGet
#define NULL
Definition: begin_code.h:167
The type used to identify a window.
Definition: SDL_sysvideo.h:73
static int SDL_UninitializedVideo()
Definition: SDL_video.c:437

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

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

3567 {
3568  CHECK_WINDOW_MAGIC(window,);
3569 
3570  if (_this->GL_GetDrawableSize) {
3571  _this->GL_GetDrawableSize(_this, window, w, h);
3572  } else {
3573  SDL_GetWindowSize(window, w, h);
3574  }
3575 }
GLfloat GLfloat GLfloat GLfloat h
void(* GL_GetDrawableSize)(_THIS, SDL_Window *window, int *w, int *h)
Definition: SDL_sysvideo.h:260
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
GLubyte GLubyte GLubyte GLubyte w
void SDL_GetWindowSize(SDL_Window *window, int *w, int *h)
Get the size of a window&#39;s client area.
Definition: SDL_video.c:2034
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120

◆ SDL_GL_GetProcAddress()

void* SDL_GL_GetProcAddress ( const char *  proc)

Get the address of an OpenGL function.

Definition at line 2907 of file SDL_video.c.

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

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

2908 {
2909  void *func;
2910 
2911  if (!_this) {
2913  return NULL;
2914  }
2915  func = NULL;
2916  if (_this->GL_GetProcAddress) {
2917  if (_this->gl_config.driver_loaded) {
2918  func = _this->GL_GetProcAddress(_this, proc);
2919  } else {
2920  SDL_SetError("No GL driver has been loaded");
2921  }
2922  } else {
2923  SDL_SetError("No dynamic GL support in current SDL video driver (%s)", _this->name);
2924  }
2925  return func;
2926 }
const char * name
Definition: SDL_sysvideo.h:152
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
#define NULL
Definition: begin_code.h:167
#define SDL_SetError
GLenum func
static int SDL_UninitializedVideo()
Definition: SDL_video.c:437
void *(* GL_GetProcAddress)(_THIS, const char *proc)
Definition: SDL_sysvideo.h:256
struct SDL_VideoDevice::@262 gl_config

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

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

3593 {
3594  if (!_this) {
3595  return 0;
3596  } else if (SDL_GL_GetCurrentContext() == NULL) {
3597  return 0;
3598  } else if (_this->GL_GetSwapInterval) {
3599  return _this->GL_GetSwapInterval(_this);
3600  } else {
3601  return 0;
3602  }
3603 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
#define NULL
Definition: begin_code.h:167
SDL_GLContext SDL_GL_GetCurrentContext(void)
Get the currently active OpenGL context.
Definition: SDL_video.c:3557
int(* GL_GetSwapInterval)(_THIS)
Definition: SDL_sysvideo.h:262

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

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

Referenced by SDL_CreateWindow(), and SDL_RecreateWindow().

2879 {
2880  int retval;
2881 
2882  if (!_this) {
2883  return SDL_UninitializedVideo();
2884  }
2885  if (_this->gl_config.driver_loaded) {
2886  if (path && SDL_strcmp(path, _this->gl_config.driver_path) != 0) {
2887  return SDL_SetError("OpenGL library already loaded");
2888  }
2889  retval = 0;
2890  } else {
2891  if (!_this->GL_LoadLibrary) {
2892  return SDL_SetError("No dynamic GL support in current SDL video driver (%s)", _this->name);
2893  }
2894  retval = _this->GL_LoadLibrary(_this, path);
2895  }
2896  if (retval == 0) {
2898  } else {
2899  if (_this->GL_UnloadLibrary) {
2901  }
2902  }
2903  return (retval);
2904 }
const char * name
Definition: SDL_sysvideo.h:152
int(* GL_LoadLibrary)(_THIS, const char *path)
Definition: SDL_sysvideo.h:255
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
SDL_bool retval
char driver_path[256]
Definition: SDL_sysvideo.h:354
void(* GL_UnloadLibrary)(_THIS)
Definition: SDL_sysvideo.h:257
#define SDL_SetError
static int SDL_UninitializedVideo()
Definition: SDL_video.c:437
GLsizei const GLchar *const * path
#define SDL_strcmp
struct SDL_VideoDevice::@262 gl_config

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

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

Referenced by SDL_DestroyWindow(), and SDL_GL_DeleteContext().

3517 {
3518  int retval;
3519 
3520  if (window == SDL_GL_GetCurrentWindow() &&
3522  /* We're already current. */
3523  return 0;
3524  }
3525 
3526  if (!ctx) {
3527  window = NULL;
3528  } else {
3529  CHECK_WINDOW_MAGIC(window, -1);
3530 
3531  if (!(window->flags & SDL_WINDOW_OPENGL)) {
3532  return SDL_SetError("The specified window isn't an OpenGL window");
3533  }
3534  }
3535 
3536  retval = _this->GL_MakeCurrent(_this, window, ctx);
3537  if (retval == 0) {
3539  _this->current_glctx = ctx;
3542  }
3543  return retval;
3544 }
#define SDL_TLSSet
SDL_TLSID current_glwin_tls
Definition: SDL_sysvideo.h:365
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
SDL_bool retval
SDL_GLContext current_glctx
Definition: SDL_sysvideo.h:364
int(* GL_MakeCurrent)(_THIS, SDL_Window *window, SDL_GLContext context)
Definition: SDL_sysvideo.h:259
#define NULL
Definition: begin_code.h:167
#define SDL_SetError
EGLSurface EGLNativeWindowType * window
Definition: eglext.h:1025
SDL_TLSID current_glctx_tls
Definition: SDL_sysvideo.h:366
SDL_GLContext SDL_GL_GetCurrentContext(void)
Get the currently active OpenGL context.
Definition: SDL_video.c:3557
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
Uint32 flags
Definition: SDL_sysvideo.h:83
SDL_Window * SDL_GL_GetCurrentWindow(void)
Get the currently active OpenGL window.
Definition: SDL_video.c:3547
SDL_Window * current_glwin
Definition: SDL_sysvideo.h:363
EGLContext ctx
Definition: eglext.h:208

◆ SDL_GL_ResetAttributes()

void SDL_GL_ResetAttributes ( void  )

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

Definition at line 3069 of file SDL_video.c.

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

Referenced by SDL_VideoInit().

3070 {
3071  if (!_this) {
3072  return;
3073  }
3074 
3075  _this->gl_config.red_size = 3;
3076  _this->gl_config.green_size = 3;
3077  _this->gl_config.blue_size = 2;
3078  _this->gl_config.alpha_size = 0;
3080  _this->gl_config.depth_size = 16;
3087  _this->gl_config.stereo = 0;
3091  _this->gl_config.accelerated = -1; /* accelerated or not, both are fine */
3092 
3097  } else {
3098 #if SDL_VIDEO_OPENGL
3102 #elif SDL_VIDEO_OPENGL_ES2
3106 #elif SDL_VIDEO_OPENGL_ES
3110 #endif
3111  }
3112 
3113  _this->gl_config.flags = 0;
3115  _this->gl_config.no_error = 0;
3118 
3120 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
int framebuffer_srgb_capable
Definition: SDL_sysvideo.h:350
int share_with_current_context
Definition: SDL_sysvideo.h:347
void(* GL_DefaultProfileConfig)(_THIS, int *mask, int *major, int *minor)
Definition: SDL_sysvideo.h:265
struct SDL_VideoDevice::@262 gl_config

◆ SDL_GL_SetAttribute()

int SDL_GL_SetAttribute ( SDL_GLattr  attr,
int  value 
)

Set an OpenGL window attribute before window creation.

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

Definition at line 3123 of file SDL_video.c.

References SDL_VideoDevice::accelerated, SDL_VideoDevice::accum_alpha_size, SDL_VideoDevice::accum_blue_size, SDL_VideoDevice::accum_green_size, SDL_VideoDevice::accum_red_size, SDL_VideoDevice::alpha_size, SDL_VideoDevice::blue_size, SDL_VideoDevice::buffer_size, SDL_VideoDevice::depth_size, SDL_VideoDevice::double_buffer, SDL_VideoDevice::flags, SDL_VideoDevice::framebuffer_srgb_capable, SDL_VideoDevice::gl_config, SDL_VideoDevice::green_size, SDL_VideoDevice::major_version, SDL_VideoDevice::minor_version, SDL_VideoDevice::multisamplebuffers, SDL_VideoDevice::multisamplesamples, SDL_VideoDevice::no_error, SDL_VideoDevice::profile_mask, SDL_VideoDevice::red_size, SDL_VideoDevice::release_behavior, SDL_VideoDevice::reset_notification, SDL_VideoDevice::retained_backing, retval, SDL_GL_ACCELERATED_VISUAL, SDL_GL_ACCUM_ALPHA_SIZE, SDL_GL_ACCUM_BLUE_SIZE, SDL_GL_ACCUM_GREEN_SIZE, SDL_GL_ACCUM_RED_SIZE, SDL_GL_ALPHA_SIZE, SDL_GL_BLUE_SIZE, SDL_GL_BUFFER_SIZE, SDL_GL_CONTEXT_DEBUG_FLAG, SDL_GL_CONTEXT_EGL, SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG, SDL_GL_CONTEXT_MAJOR_VERSION, SDL_GL_CONTEXT_MINOR_VERSION, SDL_GL_CONTEXT_NO_ERROR, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY, SDL_GL_CONTEXT_PROFILE_CORE, SDL_GL_CONTEXT_PROFILE_ES, SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_RELEASE_BEHAVIOR, SDL_GL_CONTEXT_RESET_ISOLATION_FLAG, SDL_GL_CONTEXT_RESET_NOTIFICATION, SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG, SDL_GL_DEPTH_SIZE, SDL_GL_DOUBLEBUFFER, SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, SDL_GL_GREEN_SIZE, SDL_GL_MULTISAMPLEBUFFERS, SDL_GL_MULTISAMPLESAMPLES, SDL_GL_RED_SIZE, SDL_GL_RETAINED_BACKING, SDL_GL_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.

3124 {
3125 #if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
3126  int retval;
3127 
3128  if (!_this) {
3129  return SDL_UninitializedVideo();
3130  }
3131  retval = 0;
3132  switch (attr) {
3133  case SDL_GL_RED_SIZE:
3135  break;
3136  case SDL_GL_GREEN_SIZE:
3138  break;
3139  case SDL_GL_BLUE_SIZE:
3141  break;
3142  case SDL_GL_ALPHA_SIZE:
3144  break;
3145  case SDL_GL_DOUBLEBUFFER:
3147  break;
3148  case SDL_GL_BUFFER_SIZE:
3150  break;
3151  case SDL_GL_DEPTH_SIZE:
3153  break;
3154  case SDL_GL_STENCIL_SIZE:
3156  break;
3157  case SDL_GL_ACCUM_RED_SIZE:
3159  break;
3162  break;
3165  break;
3168  break;
3169  case SDL_GL_STEREO:
3171  break;
3174  break;
3177  break;
3180  break;
3183  break;
3186  break;
3189  break;
3190  case SDL_GL_CONTEXT_EGL:
3191  /* FIXME: SDL_GL_CONTEXT_EGL to be deprecated in SDL 2.1 */
3192  if (value != 0) {
3194  } else {
3196  };
3197  break;
3198  case SDL_GL_CONTEXT_FLAGS:
3203  retval = SDL_SetError("Unknown OpenGL context flag %d", value);
3204  break;
3205  }
3207  break;
3209  if (value != 0 &&
3213  retval = SDL_SetError("Unknown OpenGL context profile %d", value);
3214  break;
3215  }
3217  break;
3220  break;
3223  break;
3226  break;
3229  break;
3232  break;
3233  default:
3234  retval = SDL_SetError("Unknown OpenGL attribute");
3235  break;
3236  }
3237  return retval;
3238 #else
3239  return SDL_Unsupported();
3240 #endif /* SDL_VIDEO_OPENGL */
3241 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
SDL_bool retval
GLsizei const GLfloat * value
int framebuffer_srgb_capable
Definition: SDL_sysvideo.h:350
int share_with_current_context
Definition: SDL_sysvideo.h:347
#define SDL_SetError
int SDL_GL_SetAttribute(SDL_GLattr attr, int value)
Set an OpenGL window attribute before window creation.
Definition: SDL_video.c:3123
static int SDL_UninitializedVideo()
Definition: SDL_video.c:437
#define SDL_Unsupported()
Definition: SDL_error.h:53
struct SDL_VideoDevice::@262 gl_config

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

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

3579 {
3580  if (!_this) {
3581  return SDL_UninitializedVideo();
3582  } else if (SDL_GL_GetCurrentContext() == NULL) {
3583  return SDL_SetError("No OpenGL context has been made current");
3584  } else if (_this->GL_SetSwapInterval) {
3585  return _this->GL_SetSwapInterval(_this, interval);
3586  } else {
3587  return SDL_SetError("Setting the swap interval is not supported");
3588  }
3589 }
int(* GL_SetSwapInterval)(_THIS, int interval)
Definition: SDL_sysvideo.h:261
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
#define NULL
Definition: begin_code.h:167
#define SDL_SetError
SDL_GLContext SDL_GL_GetCurrentContext(void)
Get the currently active OpenGL context.
Definition: SDL_video.c:3557
static int SDL_UninitializedVideo()
Definition: SDL_video.c:437

◆ 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 3606 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.

3607 {
3608  CHECK_WINDOW_MAGIC(window,);
3609 
3610  if (!(window->flags & SDL_WINDOW_OPENGL)) {
3611  SDL_SetError("The specified window isn't an OpenGL window");
3612  return;
3613  }
3614 
3615  if (SDL_GL_GetCurrentWindow() != window) {
3616  SDL_SetError("The specified window has not been made current");
3617  return;
3618  }
3619 
3620  _this->GL_SwapWindow(_this, window);
3621 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
#define SDL_SetError
int(* GL_SwapWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:263
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
Uint32 flags
Definition: SDL_sysvideo.h:83
SDL_Window * SDL_GL_GetCurrentWindow(void)
Get the currently active OpenGL window.
Definition: SDL_video.c:3547

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

2930 {
2931  if (!_this) {
2933  return;
2934  }
2935  if (_this->gl_config.driver_loaded > 0) {
2936  if (--_this->gl_config.driver_loaded > 0) {
2937  return;
2938  }
2939  if (_this->GL_UnloadLibrary) {
2941  }
2942  }
2943 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
void(* GL_UnloadLibrary)(_THIS)
Definition: SDL_sysvideo.h:257
static int SDL_UninitializedVideo()
Definition: SDL_video.c:437
struct SDL_VideoDevice::@262 gl_config

◆ SDL_HideWindow()

void SDL_HideWindow ( SDL_Window window)

Hide a window.

See also
SDL_ShowWindow()

Definition at line 2168 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().

2169 {
2170  CHECK_WINDOW_MAGIC(window,);
2171 
2172  if (!(window->flags & SDL_WINDOW_SHOWN)) {
2173  return;
2174  }
2175 
2176  window->is_hiding = SDL_TRUE;
2178 
2179  if (_this->HideWindow) {
2180  _this->HideWindow(_this, window);
2181  }
2182  window->is_hiding = SDL_FALSE;
2184 }
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:224
static int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen)
Definition: SDL_video.c:1183
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
Uint32 flags
Definition: SDL_sysvideo.h:83
SDL_bool is_hiding
Definition: SDL_sysvideo.h:100

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

References SDL_FALSE, SDL_TRUE, and SDL_VideoDevice::suspend_screensaver.

2790 {
2791  if (!_this) {
2792  return SDL_TRUE;
2793  }
2795 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
SDL_bool suspend_screensaver
Definition: SDL_sysvideo.h:314

◆ SDL_MaximizeWindow()

void SDL_MaximizeWindow ( SDL_Window window)

Make a window as large as possible.

See also
SDL_RestoreWindow()

Definition at line 2200 of file SDL_video.c.

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

Referenced by SDL_FinishWindowCreation().

2201 {
2202  CHECK_WINDOW_MAGIC(window,);
2203 
2204  if (window->flags & SDL_WINDOW_MAXIMIZED) {
2205  return;
2206  }
2207 
2208  /* !!! FIXME: should this check if the window is resizable? */
2209 
2210  if (_this->MaximizeWindow) {
2211  _this->MaximizeWindow(_this, window);
2212  }
2213 }
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:226
Uint32 flags
Definition: SDL_sysvideo.h:83

◆ SDL_MinimizeWindow()

void SDL_MinimizeWindow ( SDL_Window window)

Minimize a window to an iconic representation.

See also
SDL_RestoreWindow()

Definition at line 2225 of file SDL_video.c.

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

2226 {
2227  CHECK_WINDOW_MAGIC(window,);
2228 
2229  if (window->flags & SDL_WINDOW_MINIMIZED) {
2230  return;
2231  }
2232 
2233  if (!CanMinimizeWindow(window)) {
2234  return;
2235  }
2236 
2238 
2239  if (_this->MinimizeWindow) {
2240  _this->MinimizeWindow(_this, window);
2241  }
2242 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
static SDL_bool CanMinimizeWindow(SDL_Window *window)
Definition: SDL_video.c:2216
static int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen)
Definition: SDL_video.c:1183
void(* MinimizeWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:227
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
Uint32 flags
Definition: SDL_sysvideo.h:83

◆ SDL_RaiseWindow()

void SDL_RaiseWindow ( SDL_Window window)

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

Definition at line 2187 of file SDL_video.c.

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

Referenced by SDL_ShowMessageBox().

2188 {
2189  CHECK_WINDOW_MAGIC(window,);
2190 
2191  if (!(window->flags & SDL_WINDOW_SHOWN)) {
2192  return;
2193  }
2194  if (_this->RaiseWindow) {
2195  _this->RaiseWindow(_this, window);
2196  }
2197 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
void(* RaiseWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:225
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
Uint32 flags
Definition: SDL_sysvideo.h:83

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

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

2246 {
2247  CHECK_WINDOW_MAGIC(window,);
2248 
2249  if (!(window->flags & (SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED))) {
2250  return;
2251  }
2252 
2253  if (_this->RestoreWindow) {
2254  _this->RestoreWindow(_this, window);
2255  }
2256 }
void(* RestoreWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:228
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:83

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

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

1951 {
1952  CHECK_WINDOW_MAGIC(window,);
1953  if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
1954  const int want = (bordered != SDL_FALSE); /* normalize the flag. */
1955  const int have = ((window->flags & SDL_WINDOW_BORDERLESS) == 0);
1956  if ((want != have) && (_this->SetWindowBordered)) {
1957  if (want) {
1958  window->flags &= ~SDL_WINDOW_BORDERLESS;
1959  } else {
1960  window->flags |= SDL_WINDOW_BORDERLESS;
1961  }
1962  _this->SetWindowBordered(_this, window, (SDL_bool) want);
1963  }
1964  }
1965 }
void(* SetWindowBordered)(_THIS, SDL_Window *window, SDL_bool bordered)
Definition: SDL_sysvideo.h:229
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
SDL_bool
Definition: SDL_stdinc.h:161
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
Uint32 flags
Definition: SDL_sysvideo.h:83

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

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

2356 {
2357  Uint16 ramp[256];
2358  int status;
2359 
2360  CHECK_WINDOW_MAGIC(window, -1);
2361 
2362  SDL_CalculateGammaRamp(brightness, ramp);
2363  status = SDL_SetWindowGammaRamp(window, ramp, ramp, ramp);
2364  if (status == 0) {
2365  window->brightness = brightness;
2366  }
2367  return status;
2368 }
uint16_t Uint16
Definition: SDL_stdinc.h:191
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:2441
float brightness
Definition: SDL_sysvideo.h:93
#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 1796 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().

1797 {
1798  SDL_WindowUserData *prev, *data;
1799 
1800  CHECK_WINDOW_MAGIC(window, NULL);
1801 
1802  /* Input validation */
1803  if (name == NULL || name[0] == '\0') {
1804  SDL_InvalidParamError("name");
1805  return NULL;
1806  }
1807 
1808  /* See if the named data already exists */
1809  prev = NULL;
1810  for (data = window->data; data; prev = data, data = data->next) {
1811  if (data->name && SDL_strcmp(data->name, name) == 0) {
1812  void *last_value = data->data;
1813 
1814  if (userdata) {
1815  /* Set the new value */
1816  data->data = userdata;
1817  } else {
1818  /* Delete this value */
1819  if (prev) {
1820  prev->next = data->next;
1821  } else {
1822  window->data = data->next;
1823  }
1824  SDL_free(data->name);
1825  SDL_free(data);
1826  }
1827  return last_value;
1828  }
1829  }
1830 
1831  /* Add new data to the window */
1832  if (userdata) {
1833  data = (SDL_WindowUserData *)SDL_malloc(sizeof(*data));
1834  data->name = SDL_strdup(name);
1835  data->data = userdata;
1836  data->next = window->data;
1837  window->data = data;
1838  }
1839  return NULL;
1840 }
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: SDL_opengl.h:1974
#define SDL_InvalidParamError(param)
Definition: SDL_error.h:54
GLuint const GLchar * name
struct SDL_WindowUserData * next
Definition: SDL_sysvideo.h:69
#define SDL_free
#define NULL
Definition: begin_code.h:167
#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:109

◆ 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 1100 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.

1101 {
1102  CHECK_WINDOW_MAGIC(window, -1);
1103 
1104  if (mode) {
1105  window->fullscreen_mode = *mode;
1106  } else {
1107  SDL_zero(window->fullscreen_mode);
1108  }
1109 
1111  SDL_DisplayMode fullscreen_mode;
1112  if (SDL_GetWindowDisplayMode(window, &fullscreen_mode) == 0) {
1113  SDL_SetDisplayModeForDisplay(SDL_GetDisplayForWindow(window), &fullscreen_mode);
1114  }
1115  }
1116  return 0;
1117 }
SDL_DisplayMode fullscreen_mode
Definition: SDL_sysvideo.h:89
#define FULLSCREEN_VISIBLE(W)
Definition: SDL_sysvideo.h:116
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:1120
SDL_VideoDisplay * SDL_GetDisplayForWindow(SDL_Window *window)
Definition: SDL_video.c:1089
GLenum mode
#define SDL_zero(x)
Definition: SDL_stdinc.h:416
static int SDL_SetDisplayModeForDisplay(SDL_VideoDisplay *display, const SDL_DisplayMode *mode)
Definition: SDL_video.c:972
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
Uint32 flags
Definition: SDL_sysvideo.h:83

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

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

Referenced by SDL_FinishWindowCreation().

2260 {
2261  Uint32 oldflags;
2262  CHECK_WINDOW_MAGIC(window, -1);
2263 
2265 
2266  if (flags == (window->flags & FULLSCREEN_MASK)) {
2267  return 0;
2268  }
2269 
2270  /* clear the previous flags and OR in the new ones */
2271  oldflags = window->flags & FULLSCREEN_MASK;
2272  window->flags &= ~FULLSCREEN_MASK;
2273  window->flags |= flags;
2274 
2275  if (SDL_UpdateFullscreenMode(window, FULLSCREEN_VISIBLE(window)) == 0) {
2276  return 0;
2277  }
2278 
2279  window->flags &= ~FULLSCREEN_MASK;
2280  window->flags |= oldflags;
2281  return -1;
2282 }
#define FULLSCREEN_VISIBLE(W)
Definition: SDL_sysvideo.h:116
static int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen)
Definition: SDL_video.c:1183
GLbitfield flags
uint32_t Uint32
Definition: SDL_stdinc.h:203
#define FULLSCREEN_MASK
Definition: SDL_video.c:144
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
Uint32 flags
Definition: SDL_sysvideo.h:83

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

2444 {
2445  CHECK_WINDOW_MAGIC(window, -1);
2446 
2447  if (!_this->SetWindowGammaRamp) {
2448  return SDL_Unsupported();
2449  }
2450 
2451  if (!window->gamma) {
2452  if (SDL_GetWindowGammaRamp(window, NULL, NULL, NULL) < 0) {
2453  return -1;
2454  }
2455  SDL_assert(window->gamma != NULL);
2456  }
2457 
2458  if (red) {
2459  SDL_memcpy(&window->gamma[0*256], red, 256*sizeof(Uint16));
2460  }
2461  if (green) {
2462  SDL_memcpy(&window->gamma[1*256], green, 256*sizeof(Uint16));
2463  }
2464  if (blue) {
2465  SDL_memcpy(&window->gamma[2*256], blue, 256*sizeof(Uint16));
2466  }
2467  if (window->flags & SDL_WINDOW_INPUT_FOCUS) {
2468  return _this->SetWindowGammaRamp(_this, window, window->gamma);
2469  } else {
2470  return 0;
2471  }
2472 }
uint16_t Uint16
Definition: SDL_stdinc.h:191
GLbyte green
const GLubyte GLuint red
Definition: SDL_glfuncs.h:79
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
#define SDL_memcpy
#define SDL_assert(condition)
Definition: SDL_assert.h:169
#define NULL
Definition: begin_code.h:167
GLbyte GLbyte blue
int SDL_GetWindowGammaRamp(SDL_Window *window, Uint16 *red, Uint16 *green, Uint16 *blue)
Get the gamma ramp for a window.
Definition: SDL_video.c:2475
Uint16 * gamma
Definition: SDL_sysvideo.h:94
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
Uint32 flags
Definition: SDL_sysvideo.h:83
int(* SetWindowGammaRamp)(_THIS, SDL_Window *window, const Uint16 *ramp)
Definition: SDL_sysvideo.h:232
#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 2551 of file SDL_video.c.

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

Referenced by SDL_FinishWindowCreation().

2552 {
2553  CHECK_WINDOW_MAGIC(window,);
2554 
2555  if (!!grabbed == !!(window->flags & SDL_WINDOW_INPUT_GRABBED)) {
2556  return;
2557  }
2558  if (grabbed) {
2559  window->flags |= SDL_WINDOW_INPUT_GRABBED;
2560  } else {
2561  window->flags &= ~SDL_WINDOW_INPUT_GRABBED;
2562  }
2563  SDL_UpdateWindowGrab(window);
2564 }
void SDL_UpdateWindowGrab(SDL_Window *window)
Definition: SDL_video.c:2520
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
Uint32 flags
Definition: SDL_sysvideo.h:83

◆ 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 3998 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.

3999 {
4000  CHECK_WINDOW_MAGIC(window, -1);
4001 
4002  if (!_this->SetWindowHitTest) {
4003  return SDL_Unsupported();
4004  } else if (_this->SetWindowHitTest(window, callback != NULL) == -1) {
4005  return -1;
4006  }
4007 
4008  window->hit_test = callback;
4009  window->hit_test_data = userdata;
4010 
4011  return 0;
4012 }
int(* SetWindowHitTest)(SDL_Window *window, SDL_bool enabled)
Definition: SDL_sysvideo.h:306
void * hit_test_data
Definition: SDL_sysvideo.h:107
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:167
SDL_HitTest hit_test
Definition: SDL_sysvideo.h:106
#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 1774 of file SDL_video.c.

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

1775 {
1776  CHECK_WINDOW_MAGIC(window,);
1777 
1778  if (!icon) {
1779  return;
1780  }
1781 
1782  SDL_FreeSurface(window->icon);
1783 
1784  /* Convert the icon into ARGB8888 */
1786  if (!window->icon) {
1787  return;
1788  }
1789 
1790  if (_this->SetWindowIcon) {
1791  _this->SetWindowIcon(_this, window, window->icon);
1792  }
1793 }
#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:214
SDL_Surface * icon
Definition: SDL_sysvideo.h:78
#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 2428 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, SDL_Unsupported, and SDL_VideoDevice::SetWindowInputFocus.

2429 {
2430  CHECK_WINDOW_MAGIC(window, -1);
2431 
2432  if (!_this->SetWindowInputFocus) {
2433  return SDL_Unsupported();
2434  }
2435 
2436  return _this->SetWindowInputFocus(_this, window);
2437 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
int(* SetWindowInputFocus)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:222
#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 2111 of file SDL_video.c.

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

2112 {
2113  CHECK_WINDOW_MAGIC(window,);
2114  if (max_w <= 0) {
2115  SDL_InvalidParamError("max_w");
2116  return;
2117  }
2118  if (max_h <= 0) {
2119  SDL_InvalidParamError("max_h");
2120  return;
2121  }
2122 
2123  if (max_w <= window->min_w || max_h <= window->min_h) {
2124  SDL_SetError("SDL_SetWindowMaximumSize(): Tried to set maximum size smaller than minimum size");
2125  return;
2126  }
2127 
2128  window->max_w = max_w;
2129  window->max_h = max_h;
2130 
2131  if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
2132  if (_this->SetWindowMaximumSize) {
2133  _this->SetWindowMaximumSize(_this, window);
2134  }
2135  /* Ensure that window is not larger than maximal size */
2136  SDL_SetWindowSize(window, SDL_min(window->w, window->max_w), SDL_min(window->h, window->max_h));
2137  }
2138 }
#define SDL_min(x, y)
Definition: SDL_stdinc.h:406
void SDL_SetWindowSize(SDL_Window *window, int w, int h)
Set the size of a window&#39;s client area.
Definition: SDL_video.c:1986
#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:218
#define SDL_SetError
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
Uint32 flags
Definition: SDL_sysvideo.h:83

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

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

2069 {
2070  CHECK_WINDOW_MAGIC(window,);
2071  if (min_w <= 0) {
2072  SDL_InvalidParamError("min_w");
2073  return;
2074  }
2075  if (min_h <= 0) {
2076  SDL_InvalidParamError("min_h");
2077  return;
2078  }
2079 
2080  if ((window->max_w && min_w >= window->max_w) ||
2081  (window->max_h && min_h >= window->max_h)) {
2082  SDL_SetError("SDL_SetWindowMinimumSize(): Tried to set minimum size larger than maximum size");
2083  return;
2084  }
2085 
2086  window->min_w = min_w;
2087  window->min_h = min_h;
2088 
2089  if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
2090  if (_this->SetWindowMinimumSize) {
2091  _this->SetWindowMinimumSize(_this, window);
2092  }
2093  /* Ensure that window is not smaller than minimal size */
2094  SDL_SetWindowSize(window, SDL_max(window->w, window->min_w), SDL_max(window->h, window->min_h));
2095  }
2096 }
void SDL_SetWindowSize(SDL_Window *window, int w, int h)
Set the size of a window&#39;s client area.
Definition: SDL_video.c:1986
#define SDL_InvalidParamError(param)
Definition: SDL_error.h:54
#define SDL_max(x, y)
Definition: SDL_stdinc.h:407
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
void(* SetWindowMinimumSize)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:217
#define SDL_SetError
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
Uint32 flags
Definition: SDL_sysvideo.h:83

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

References CHECK_WINDOW_MAGIC, SDL_Unsupported, and SDL_VideoDevice::SetWindowModalFor.

2416 {
2417  CHECK_WINDOW_MAGIC(modal_window, -1);
2418  CHECK_WINDOW_MAGIC(parent_window, -1);
2419 
2420  if (!_this->SetWindowModalFor) {
2421  return SDL_Unsupported();
2422  }
2423 
2424  return _this->SetWindowModalFor(_this, modal_window, parent_window);
2425 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
int(* SetWindowModalFor)(_THIS, SDL_Window *modal_window, SDL_Window *parent_window)
Definition: SDL_sysvideo.h:221
#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 2379 of file SDL_video.c.

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

2380 {
2381  int retval;
2382  CHECK_WINDOW_MAGIC(window, -1);
2383 
2384  if (!_this->SetWindowOpacity) {
2385  return SDL_Unsupported();
2386  }
2387 
2388  if (opacity < 0.0f) {
2389  opacity = 0.0f;
2390  } else if (opacity > 1.0f) {
2391  opacity = 1.0f;
2392  }
2393 
2394  retval = _this->SetWindowOpacity(_this, window, opacity);
2395  if (retval == 0) {
2396  window->opacity = opacity;
2397  }
2398 
2399  return retval;
2400 }
GLfloat f
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
SDL_bool retval
float opacity
Definition: SDL_sysvideo.h:91
int(* SetWindowOpacity)(_THIS, SDL_Window *window, float opacity)
Definition: SDL_sysvideo.h:220
#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 1864 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_WINDOW_FULLSCREEN, SDL_WINDOWPOS_ISCENTERED, SDL_WINDOWPOS_ISUNDEFINED, SDL_zero, SDL_VideoDevice::SetWindowPosition, SDL_Window::w, SDL_Rect::w, SDL_Window::windowed, SDL_Window::x, SDL_Rect::x, SDL_Window::y, and SDL_Rect::y.

1865 {
1866  CHECK_WINDOW_MAGIC(window,);
1867 
1869  int displayIndex = (x & 0xFFFF);
1870  SDL_Rect bounds;
1871  if (displayIndex >= _this->num_displays) {
1872  displayIndex = 0;
1873  }
1874 
1875  SDL_zero(bounds);
1876 
1877  SDL_GetDisplayBounds(displayIndex, &bounds);
1878  if (SDL_WINDOWPOS_ISCENTERED(x)) {
1879  x = bounds.x + (bounds.w - window->w) / 2;
1880  }
1881  if (SDL_WINDOWPOS_ISCENTERED(y)) {
1882  y = bounds.y + (bounds.h - window->h) / 2;
1883  }
1884  }
1885 
1886  if ((window->flags & SDL_WINDOW_FULLSCREEN)) {
1887  if (!SDL_WINDOWPOS_ISUNDEFINED(x)) {
1888  window->windowed.x = x;
1889  }
1890  if (!SDL_WINDOWPOS_ISUNDEFINED(y)) {
1891  window->windowed.y = y;
1892  }
1893  } else {
1894  if (!SDL_WINDOWPOS_ISUNDEFINED(x)) {
1895  window->x = x;
1896  }
1897  if (!SDL_WINDOWPOS_ISUNDEFINED(y)) {
1898  window->y = y;
1899  }
1900 
1901  if (_this->SetWindowPosition) {
1902  _this->SetWindowPosition(_this, window);
1903  }
1904  }
1905 }
#define SDL_WINDOWPOS_ISUNDEFINED(X)
Definition: SDL_video.h:131
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
#define SDL_WINDOWPOS_ISCENTERED(X)
Definition: SDL_video.h:140
SDL_Rect windowed
Definition: SDL_sysvideo.h:87
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
#define SDL_zero(x)
Definition: SDL_stdinc.h:416
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574
int x
Definition: SDL_rect.h:79
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:673
int w
Definition: SDL_rect.h:80
void(* SetWindowPosition)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:215
int h
Definition: SDL_rect.h:80
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
Uint32 flags
Definition: SDL_sysvideo.h:83
int y
Definition: SDL_rect.h:79
A rectangle, with the origin at the upper left (integer).
Definition: SDL_rect.h:77

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

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

1969 {
1970  CHECK_WINDOW_MAGIC(window,);
1971  if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
1972  const int want = (resizable != SDL_FALSE); /* normalize the flag. */
1973  const int have = ((window->flags & SDL_WINDOW_RESIZABLE) != 0);
1974  if ((want != have) && (_this->SetWindowResizable)) {
1975  if (want) {
1976  window->flags |= SDL_WINDOW_RESIZABLE;
1977  } else {
1978  window->flags &= ~SDL_WINDOW_RESIZABLE;
1979  }
1980  _this->SetWindowResizable(_this, window, (SDL_bool) want);
1981  }
1982  }
1983 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
SDL_bool
Definition: SDL_stdinc.h:161
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
void(* SetWindowResizable)(_THIS, SDL_Window *window, SDL_bool resizable)
Definition: SDL_sysvideo.h:230
Uint32 flags
Definition: SDL_sysvideo.h:83

◆ SDL_SetWindowSize()

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

Set the size of a window's client area.

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

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

See also
SDL_GetWindowSize()
SDL_SetWindowDisplayMode()

Definition at line 1986 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, SDL_Window::flags, FULLSCREEN_VISIBLE, SDL_Window::h, SDL_Rect::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().

1987 {
1988  CHECK_WINDOW_MAGIC(window,);
1989  if (w <= 0) {
1990  SDL_InvalidParamError("w");
1991  return;
1992  }
1993  if (h <= 0) {
1994  SDL_InvalidParamError("h");
1995  return;
1996  }
1997 
1998  /* Make sure we don't exceed any window size limits */
1999  if (window->min_w && w < window->min_w) {
2000  w = window->min_w;
2001  }
2002  if (window->max_w && w > window->max_w) {
2003  w = window->max_w;
2004  }
2005  if (window->min_h && h < window->min_h) {
2006  h = window->min_h;
2007  }
2008  if (window->max_h && h > window->max_h) {
2009  h = window->max_h;
2010  }
2011 
2012  window->windowed.w = w;
2013  window->windowed.h = h;
2014 
2015  if (window->flags & SDL_WINDOW_FULLSCREEN) {
2017  window->last_fullscreen_flags = 0;
2019  }
2020  } else {
2021  window->w = w;
2022  window->h = h;
2023  if (_this->SetWindowSize) {
2024  _this->SetWindowSize(_this, window);
2025  }
2026  if (window->w == w && window->h == h) {
2027  /* We didn't get a SDL_WINDOWEVENT_RESIZED event (by design) */
2028  SDL_OnWindowResized(window);
2029  }
2030  }
2031 }
#define FULLSCREEN_VISIBLE(W)
Definition: SDL_sysvideo.h:116
GLfloat GLfloat GLfloat GLfloat h
void(* SetWindowSize)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:216
#define SDL_InvalidParamError(param)
Definition: SDL_error.h:54
SDL_Rect windowed
Definition: SDL_sysvideo.h:87
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
GLubyte GLubyte GLubyte GLubyte w
static int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen)
Definition: SDL_video.c:1183
int w
Definition: SDL_rect.h:80
Uint32 last_fullscreen_flags
Definition: SDL_sysvideo.h:84
int h
Definition: SDL_rect.h:80
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
Uint32 flags
Definition: SDL_sysvideo.h:83
void SDL_OnWindowResized(SDL_Window *window)
Definition: SDL_video.c:2594

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

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

Referenced by SDL_CreateWindow().

1750 {
1751  CHECK_WINDOW_MAGIC(window,);
1752 
1753  if (title == window->title) {
1754  return;
1755  }
1756  SDL_free(window->title);
1757 
1758  window->title = SDL_strdup(title ? title : "");
1759 
1760  if (_this->SetWindowTitle) {
1761  _this->SetWindowTitle(_this, window);
1762  }
1763 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
#define SDL_free
char * title
Definition: SDL_sysvideo.h:77
#define SDL_strdup
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
void(* SetWindowTitle)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:213

◆ SDL_ShowWindow()

void SDL_ShowWindow ( SDL_Window window)

Show a window.

See also
SDL_HideWindow()

Definition at line 2153 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().

2154 {
2155  CHECK_WINDOW_MAGIC(window,);
2156 
2157  if (window->flags & SDL_WINDOW_SHOWN) {
2158  return;
2159  }
2160 
2161  if (_this->ShowWindow) {
2162  _this->ShowWindow(_this, window);
2163  }
2165 }
void(* ShowWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:223
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:83

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

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

2329 {
2330  SDL_Rect full_rect;
2331 
2332  CHECK_WINDOW_MAGIC(window, -1);
2333 
2334  full_rect.x = 0;
2335  full_rect.y = 0;
2336  full_rect.w = window->w;
2337  full_rect.h = window->h;
2338  return SDL_UpdateWindowSurfaceRects(window, &full_rect, 1);
2339 }
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:2342
int x
Definition: SDL_rect.h:79
int w
Definition: SDL_rect.h:80
int h
Definition: SDL_rect.h:80
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
int y
Definition: SDL_rect.h:79
A rectangle, with the origin at the upper left (integer).
Definition: SDL_rect.h:77

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

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

Referenced by SDL_UpdateWindowSurface().

2344 {
2345  CHECK_WINDOW_MAGIC(window, -1);
2346 
2347  if (!window->surface_valid) {
2348  return SDL_SetError("Window surface is invalid, please call SDL_GetWindowSurface() to get a new surface");
2349  }
2350 
2351  return _this->UpdateWindowFramebuffer(_this, window, rects, numrects);
2352 }
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:237
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:120
SDL_bool surface_valid
Definition: SDL_sysvideo.h:98

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

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

Referenced by SDL_CreateWindow().

462 {
463  SDL_VideoDevice *video;
464  int index;
465  int i;
466 
467  /* Check to make sure we don't overwrite '_this' */
468  if (_this != NULL) {
469  SDL_VideoQuit();
470  }
471 
472 #if !SDL_TIMERS_DISABLED
473  SDL_TicksInit();
474 #endif
475 
476  /* Start the event loop */
478  SDL_KeyboardInit() < 0 ||
479  SDL_MouseInit() < 0 ||
480  SDL_TouchInit() < 0) {
481  return -1;
482  }
483 
484  /* Select the proper video driver */
485  index = 0;
486  video = NULL;
487  if (driver_name == NULL) {
488  driver_name = SDL_getenv("SDL_VIDEODRIVER");
489  }
490  if (driver_name != NULL) {
491  for (i = 0; bootstrap[i]; ++i) {
492  if (SDL_strncasecmp(bootstrap[i]->name, driver_name, SDL_strlen(driver_name)) == 0) {
493  if (bootstrap[i]->available()) {
494  video = bootstrap[i]->create(index);
495  break;
496  }
497  }
498  }
499  } else {
500  for (i = 0; bootstrap[i]; ++i) {
501  if (bootstrap[i]->available()) {
502  video = bootstrap[i]->create(index);
503  if (video != NULL) {
504  break;
505  }
506  }
507  }
508  }
509  if (video == NULL) {
510  if (driver_name) {
511  return SDL_SetError("%s not available", driver_name);
512  }
513  return SDL_SetError("No available video device");
514  }
515  _this = video;
516  _this->name = bootstrap[i]->name;
517  _this->next_object_id = 1;
518 
519 
520  /* Set some very sane GL defaults */
524 
527 
528  /* Initialize the video subsystem */
529  if (_this->VideoInit(_this) < 0) {
530  SDL_VideoQuit();
531  return -1;
532  }
533 
534  /* Make sure some displays were added */
535  if (_this->num_displays == 0) {
536  SDL_VideoQuit();
537  return SDL_SetError("The video driver did not add any displays");
538  }
539 
540  /* Add the renderer framebuffer emulation if desired */
545  }
546 
547  /* Disable the screen saver by default. This is a change from <= 2.0.1,
548  but most things using SDL are games or media players; you wouldn't
549  want a screensaver to trigger if you're playing exclusively with a
550  joystick, or passively watching a movie. Things that use SDL but
551  function more like a normal desktop app should explicitly reenable the
552  screensaver. */
555  }
556 
557  /* If we don't use a screen keyboard, turn on text input by default,
558  otherwise programs that expect to get text events without enabling
559  UNICODE input won't get any events.
560 
561  Actually, come to think of it, you needed to call SDL_EnableUNICODE(1)
562  in SDL 1.2 before you got text input events. Hmm...
563  */
566  }
567 
568  /* We're ready to go! */
569  return 0;
570 }
void SDL_GL_ResetAttributes()
Reset all previously set OpenGL context attributes to their default values.
Definition: SDL_video.c:3069
const char * name
Definition: SDL_sysvideo.h:152
#define SDL_INIT_EVENTS
Definition: SDL.h:83
void SDL_VideoQuit(void)
Shuts down the video subsystem.
Definition: SDL_video.c:2828
SDL_TLSID current_glwin_tls
Definition: SDL_sysvideo.h:365
static int available()
Definition: video.c:356
#define SDL_HINT_VIDEO_ALLOW_SCREENSAVER
A variable controlling whether the screensaver is enabled.
Definition: SDL_hints.h:165
#define SDL_InitSubSystem
int SDL_KeyboardInit(void)
Definition: SDL_keyboard.c:562
#define SDL_strncasecmp
GLuint const GLchar * name
int SDL_MouseInit(void)
Definition: SDL_mouse.c:135
#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:366
#define SDL_TLSCreate
static int SDL_CreateWindowTexture(SDL_VideoDevice *unused, SDL_Window *window, Uint32 *format, void **pixels, int *pitch)
Definition: SDL_video.c:256
static void SDL_DestroyWindowTexture(SDL_VideoDevice *unused, SDL_Window *window)
Definition: SDL_video.c:396
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:3755
#define SDL_getenv
void(* DestroyWindowFramebuffer)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:238
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:167
#define SDL_SetError
static SDL_bool ShouldUseTextureFramebuffer()
Definition: SDL_video.c:166
#define SDL_strlen
SDL_TLSID current_glctx_tls
Definition: SDL_sysvideo.h:366
void SDL_TicksInit(void)
SDL_VideoDevice *(* create)(int devindex)
Definition: SDL_sysvideo.h:402
static VideoBootStrap * bootstrap[]
Definition: SDL_video.c:60
const char * name
Definition: SDL_sysvideo.h:399
int(* VideoInit)(_THIS)
Definition: SDL_sysvideo.h:161
int(* UpdateWindowFramebuffer)(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects)
Definition: SDL_sysvideo.h:237
Uint32 next_object_id
Definition: SDL_sysvideo.h:320
SDL_bool SDL_HasScreenKeyboardSupport(void)
Returns whether the platform has some screen keyboard support.
Definition: SDL_video.c:3811
int(* CreateWindowFramebuffer)(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch)
Definition: SDL_sysvideo.h:236
int SDL_TouchInit(void)
Definition: SDL_touch.c:46
void SDL_DisableScreenSaver()
Prevent the screen from being blanked by a screensaver.
Definition: SDL_video.c:2813
struct SDL_VideoDevice::@262 gl_config

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

2829 {
2830  int i, j;
2831 
2832  if (!_this) {
2833  return;
2834  }
2835 
2836  /* Halt event processing before doing anything else */
2837  SDL_TouchQuit();
2838  SDL_MouseQuit();
2839  SDL_KeyboardQuit();
2841 
2843 
2844  /* Clean up the system video */
2845  while (_this->windows) {
2847  }
2848  _this->VideoQuit(_this);
2849 
2850  for (i = 0; i < _this->num_displays; ++i) {
2851  SDL_VideoDisplay *display = &_this->displays[i];
2852  for (j = display->num_display_modes; j--;) {
2853  SDL_free(display->display_modes[j].driverdata);
2854  display->display_modes[j].driverdata = NULL;
2855  }
2856  SDL_free(display->display_modes);
2857  display->display_modes = NULL;
2858  SDL_free(display->desktop_mode.driverdata);
2859  display->desktop_mode.driverdata = NULL;
2860  SDL_free(display->driverdata);
2861  display->driverdata = NULL;
2862  }
2863  if (_this->displays) {
2864  for (i = 0; i < _this->num_displays; ++i) {
2865  SDL_free(_this->displays[i].name);
2866  }
2868  _this->displays = NULL;
2869  _this->num_displays = 0;
2870  }
2873  _this->free(_this);
2874  _this = NULL;
2875 }
#define SDL_INIT_EVENTS
Definition: SDL.h:83
void(* free)(_THIS)
Definition: SDL_sysvideo.h:394
#define SDL_QuitSubSystem
void SDL_MouseQuit(void)
Definition: SDL_mouse.c:665
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
#define SDL_free
void * driverdata
Definition: SDL_video.h:59
void SDL_DestroyWindow(SDL_Window *window)
Destroy a window.
Definition: SDL_video.c:2712
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:130
SDL_VideoDisplay * displays
Definition: SDL_sysvideo.h:316
SDL_Window * windows
Definition: SDL_sysvideo.h:317
void SDL_KeyboardQuit(void)
Definition: SDL_keyboard.c:832
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:167
SDL_DisplayMode desktop_mode
Definition: SDL_sysvideo.h:131
void(* VideoQuit)(_THIS)
Definition: SDL_sysvideo.h:167
void SDL_EnableScreenSaver()
Allow the screen to be blanked by a screensaver.
Definition: SDL_video.c:2798
void SDL_TouchQuit(void)
Definition: SDL_touch.c:473
char * clipboard_text
Definition: SDL_sysvideo.h:321