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

Detailed Description

Header file for SDL video functions.

Definition in file SDL_video.h.

Macro Definition Documentation

◆ SDL_WINDOWPOS_CENTERED

◆ SDL_WINDOWPOS_CENTERED_DISPLAY

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

Definition at line 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 175 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 1012 of file SDL_video.h.

Enumeration Type Documentation

◆ SDL_GLattr

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

OpenGL configuration attributes.

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

Definition at line 180 of file SDL_video.h.

181 {
209 } SDL_GLattr;
SDL_GLattr
OpenGL configuration attributes.
Definition: SDL_video.h:180

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

◆ SDL_GLcontextReleaseFlag

Enumerator
SDL_GL_CONTEXT_RELEASE_BEHAVIOR_NONE 
SDL_GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH 

Definition at line 226 of file SDL_video.h.

◆ SDL_GLContextResetNotification

Enumerator
SDL_GL_CONTEXT_RESET_NO_NOTIFICATION 
SDL_GL_CONTEXT_RESET_LOSE_CONTEXT 

Definition at line 232 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 211 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 993 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 1348 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_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_OPENGL, SDL_WINDOW_POPUP_MENU, SDL_WINDOW_TOOLTIP, SDL_WINDOW_UTILITY, SDL_WINDOW_VULKAN, SDL_WINDOWPOS_ISCENTERED, SDL_WINDOWPOS_ISUNDEFINED, SDL_VideoDevice::Vulkan_CreateSurface, SDL_Rect::w, SDL_Window::w, SDL_VideoDevice::window_magic, SDL_Window::windowed, SDL_VideoDevice::windows, SDL_Rect::x, SDL_Window::x, SDL_Rect::y, and SDL_Window::y.

Referenced by ShouldUseTextureFramebuffer().

1349 {
1350  SDL_Window *window;
1351 
1352  if (!_this) {
1353  /* Initialize the video system if needed */
1354  if (SDL_VideoInit(NULL) < 0) {
1355  return NULL;
1356  }
1357  }
1358 
1359  if ((((flags & SDL_WINDOW_UTILITY) != 0) + ((flags & SDL_WINDOW_TOOLTIP) != 0) + ((flags & SDL_WINDOW_POPUP_MENU) != 0)) > 1) {
1360  SDL_SetError("Conflicting window flags specified");
1361  return NULL;
1362  }
1363 
1364  /* Some platforms can't create zero-sized windows */
1365  if (w < 1) {
1366  w = 1;
1367  }
1368  if (h < 1) {
1369  h = 1;
1370  }
1371 
1372  /* Some platforms blow up if the windows are too large. Raise it later? */
1373  if ((w > 16384) || (h > 16384)) {
1374  SDL_SetError("Window is too large.");
1375  return NULL;
1376  }
1377 
1378  /* Some platforms have OpenGL enabled by default */
1379 #if (SDL_VIDEO_OPENGL && __MACOSX__) || __IPHONEOS__ || __ANDROID__ || __NACL__
1380  if (!_this->is_dummy && !(flags & SDL_WINDOW_VULKAN)) {
1382  }
1383 #endif
1384  if (flags & SDL_WINDOW_OPENGL) {
1385  if (!_this->GL_CreateContext) {
1386  SDL_SetError("No OpenGL support in video driver");
1387  return NULL;
1388  }
1389  if (SDL_GL_LoadLibrary(NULL) < 0) {
1390  return NULL;
1391  }
1392  }
1393 
1394  if (flags & SDL_WINDOW_VULKAN) {
1395  if (!_this->Vulkan_CreateSurface) {
1396  SDL_SetError("Vulkan support is either not configured in SDL "
1397  "or not available in video driver");
1398  return NULL;
1399  }
1400  if (flags & SDL_WINDOW_OPENGL) {
1401  SDL_SetError("Vulkan and OpenGL not supported on same window");
1402  return NULL;
1403  }
1404  if (SDL_Vulkan_LoadLibrary(NULL) < 0) {
1405  return NULL;
1406  }
1407  }
1408 
1409  /* Unless the user has specified the high-DPI disabling hint, respect the
1410  * SDL_WINDOW_ALLOW_HIGHDPI flag.
1411  */
1414  flags &= ~SDL_WINDOW_ALLOW_HIGHDPI;
1415  }
1416  }
1417 
1418  window = (SDL_Window *)SDL_calloc(1, sizeof(*window));
1419  if (!window) {
1420  SDL_OutOfMemory();
1421  return NULL;
1422  }
1423  window->magic = &_this->window_magic;
1424  window->id = _this->next_object_id++;
1425  window->x = x;
1426  window->y = y;
1427  window->w = w;
1428  window->h = h;
1431  SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
1432  int displayIndex;
1433  SDL_Rect bounds;
1434 
1435  displayIndex = SDL_GetIndexOfDisplay(display);
1436  SDL_GetDisplayBounds(displayIndex, &bounds);
1438  window->x = bounds.x + (bounds.w - w) / 2;
1439  }
1441  window->y = bounds.y + (bounds.h - h) / 2;
1442  }
1443  }
1444  window->windowed.x = window->x;
1445  window->windowed.y = window->y;
1446  window->windowed.w = window->w;
1447  window->windowed.h = window->h;
1448 
1449  if (flags & SDL_WINDOW_FULLSCREEN) {
1450  SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
1451  int displayIndex;
1452  SDL_Rect bounds;
1453 
1454  displayIndex = SDL_GetIndexOfDisplay(display);
1455  SDL_GetDisplayBounds(displayIndex, &bounds);
1456 
1457  window->x = bounds.x;
1458  window->y = bounds.y;
1459  window->w = bounds.w;
1460  window->h = bounds.h;
1461  }
1462 
1463  window->flags = ((flags & CREATE_FLAGS) | SDL_WINDOW_HIDDEN);
1464  window->last_fullscreen_flags = window->flags;
1465  window->opacity = 1.0f;
1466  window->brightness = 1.0f;
1467  window->next = _this->windows;
1468  window->is_destroying = SDL_FALSE;
1469 
1470  if (_this->windows) {
1471  _this->windows->prev = window;
1472  }
1473  _this->windows = window;
1474 
1475  if (_this->CreateSDLWindow && _this->CreateSDLWindow(_this, window) < 0) {
1476  SDL_DestroyWindow(window);
1477  return NULL;
1478  }
1479 
1480 #if __WINRT__ && (NTDDI_VERSION < NTDDI_WIN10)
1481  /* HACK: WinRT 8.x apps can't choose whether or not they are fullscreen
1482  or not. The user can choose this, via OS-provided UI, but this can't
1483  be set programmatically.
1484 
1485  Just look at what SDL's WinRT video backend code detected with regards
1486  to fullscreen (being active, or not), and figure out a return/error code
1487  from that.
1488  */
1489  flags = window->flags;
1490 #endif
1491 
1492  if (title) {
1493  SDL_SetWindowTitle(window, title);
1494  }
1496 
1497  /* If the window was created fullscreen, make sure the mode code matches */
1499 
1500  return window;
1501 }
#define SDL_WINDOWPOS_ISUNDEFINED(X)
Definition: SDL_video.h:131
SDL_Window * next
Definition: SDL_sysvideo.h:114
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:536
int SDL_GL_LoadLibrary(const char *path)
Dynamically load an OpenGL library.
Definition: SDL_video.c:2776
void SDL_SetWindowTitle(SDL_Window *window, const char *title)
Set the title of a window, in UTF-8 format.
Definition: SDL_video.c:1668
#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:309
SDL_Rect windowed
Definition: SDL_sysvideo.h:87
#define SDL_GetHintBoolean
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
#define CREATE_FLAGS
Definition: SDL_video.c:1324
float opacity
Definition: SDL_sysvideo.h:91
SDL_VideoDisplay * SDL_GetDisplayForWindow(SDL_Window *window)
Definition: SDL_video.c:1073
SDL_GLContext(* GL_CreateContext)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:257
SDL_bool(* Vulkan_CreateSurface)(_THIS, SDL_Window *window, VkInstance instance, VkSurfaceKHR *surface)
Definition: SDL_sysvideo.h:273
void SDL_DestroyWindow(SDL_Window *window)
Destroy a window.
Definition: SDL_video.c:2610
GLubyte GLubyte GLubyte GLubyte w
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574
int x
Definition: SDL_rect.h:66
static int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen)
Definition: SDL_video.c:1167
SDL_Window * windows
Definition: SDL_sysvideo.h:313
int SDL_GetDisplayBounds(int displayIndex, SDL_Rect *rect)
Get the desktop area represented by a display, with the primary display located at 0...
Definition: SDL_video.c:676
int w
Definition: SDL_rect.h:67
float brightness
Definition: SDL_sysvideo.h:93
#define NULL
Definition: begin_code.h:164
int(* CreateSDLWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:210
#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:464
int h
Definition: SDL_rect.h:67
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:1328
Uint32 id
Definition: SDL_sysvideo.h:76
int SDL_Vulkan_LoadLibrary(const char *path)
Dynamically load a Vulkan loader library.
Definition: SDL_video.c:3972
static int SDL_GetIndexOfDisplay(SDL_VideoDisplay *display)
Definition: SDL_video.c:645
Uint32 flags
Definition: SDL_sysvideo.h:83
Uint32 next_object_id
Definition: SDL_sysvideo.h:316
int y
Definition: SDL_rect.h:66
A rectangle, with the origin at the upper left.
Definition: SDL_rect.h:64

◆ SDL_CreateWindowFrom()

SDL_Window* SDL_CreateWindowFrom ( const void data)

Create an SDL window from an existing native window.

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

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

1505 {
1506  SDL_Window *window;
1507 
1508  if (!_this) {
1510  return NULL;
1511  }
1512  if (!_this->CreateSDLWindowFrom) {
1513  SDL_Unsupported();
1514  return NULL;
1515  }
1516  window = (SDL_Window *)SDL_calloc(1, sizeof(*window));
1517  if (!window) {
1518  SDL_OutOfMemory();
1519  return NULL;
1520  }
1521  window->magic = &_this->window_magic;
1522  window->id = _this->next_object_id++;
1523  window->flags = SDL_WINDOW_FOREIGN;
1524  window->last_fullscreen_flags = window->flags;
1525  window->is_destroying = SDL_FALSE;
1526  window->opacity = 1.0f;
1527  window->brightness = 1.0f;
1528  window->next = _this->windows;
1529  if (_this->windows) {
1530  _this->windows->prev = window;
1531  }
1532  _this->windows = window;
1533 
1534  if (_this->CreateSDLWindowFrom(_this, window, data) < 0) {
1535  SDL_DestroyWindow(window);
1536  return NULL;
1537  }
1538  return window;
1539 }
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:121
float opacity
Definition: SDL_sysvideo.h:91
void SDL_DestroyWindow(SDL_Window *window)
Destroy a window.
Definition: SDL_video.c:2610
SDL_Window * windows
Definition: SDL_sysvideo.h:313
float brightness
Definition: SDL_sysvideo.h:93
#define NULL
Definition: begin_code.h:164
#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:440
int(* CreateSDLWindowFrom)(_THIS, SDL_Window *window, const void *data)
Definition: SDL_sysvideo.h:211
Uint32 flags
Definition: SDL_sysvideo.h:83
Uint32 next_object_id
Definition: SDL_sysvideo.h:316
#define SDL_Unsupported()
Definition: SDL_error.h:53

◆ SDL_DestroyWindow()

void SDL_DestroyWindow ( SDL_Window window)

Destroy a window.

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

2611 {
2612  SDL_VideoDisplay *display;
2613 
2614  CHECK_WINDOW_MAGIC(window,);
2615 
2616  window->is_destroying = SDL_TRUE;
2617 
2618  /* Restore video mode, etc. */
2619  SDL_HideWindow(window);
2620 
2621  /* Make sure this window no longer has focus */
2622  if (SDL_GetKeyboardFocus() == window) {
2624  }
2625  if (SDL_GetMouseFocus() == window) {
2627  }
2628 
2629  /* make no context current if this is the current context window. */
2630  if (window->flags & SDL_WINDOW_OPENGL) {
2631  if (_this->current_glwin == window) {
2632  SDL_GL_MakeCurrent(window, NULL);
2633  }
2634  }
2635 
2636  if (window->surface) {
2637  window->surface->flags &= ~SDL_DONTFREE;
2638  SDL_FreeSurface(window->surface);
2639  }
2642  }
2643  if (_this->DestroyWindow) {
2644  _this->DestroyWindow(_this, window);
2645  }
2646  if (window->flags & SDL_WINDOW_OPENGL) {
2648  }
2649  if (window->flags & SDL_WINDOW_VULKAN) {
2651  }
2652 
2653  display = SDL_GetDisplayForWindow(window);
2654  if (display->fullscreen_window == window) {
2655  display->fullscreen_window = NULL;
2656  }
2657 
2658  /* Now invalidate magic */
2659  window->magic = NULL;
2660 
2661  /* Free memory associated with the window */
2662  SDL_free(window->title);
2663  SDL_FreeSurface(window->icon);
2664  SDL_free(window->gamma);
2665  while (window->data) {
2666  SDL_WindowUserData *data = window->data;
2667 
2668  window->data = data->next;
2669  SDL_free(data->name);
2670  SDL_free(data);
2671  }
2672 
2673  /* Unlink the window from the list */
2674  if (window->next) {
2675  window->next->prev = window->prev;
2676  }
2677  if (window->prev) {
2678  window->prev->next = window->next;
2679  } else {
2680  _this->windows = window->next;
2681  }
2682 
2683  SDL_free(window);
2684 }
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:151
void SDL_HideWindow(SDL_Window *window)
Hide a window.
Definition: SDL_video.c:2088
#define SDL_GetKeyboardFocus
Uint32 flags
Definition: SDL_surface.h:71
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
struct SDL_WindowUserData * next
Definition: SDL_sysvideo.h:69
SDL_VideoDisplay * SDL_GetDisplayForWindow(SDL_Window *window)
Definition: SDL_video.c:1073
#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:3414
void SDL_GL_UnloadLibrary(void)
Unload the OpenGL library previously loaded by SDL_GL_LoadLibrary().
Definition: SDL_video.c:2827
void(* DestroyWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:234
char * title
Definition: SDL_sysvideo.h:77
SDL_Window * windows
Definition: SDL_sysvideo.h:313
SDL_Window * fullscreen_window
Definition: SDL_sysvideo.h:134
void(* DestroyWindowFramebuffer)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:237
#define NULL
Definition: begin_code.h:164
#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:4009
Uint16 * gamma
Definition: SDL_sysvideo.h:94
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:123
Uint32 flags
Definition: SDL_sysvideo.h:83
SDL_Surface * surface
Definition: SDL_sysvideo.h:97
SDL_Window * current_glwin
Definition: SDL_sysvideo.h:359
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 2711 of file SDL_video.c.

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

Referenced by SDL_VideoInit().

2712 {
2713  if (!_this) {
2714  return;
2715  }
2716  if (_this->suspend_screensaver) {
2717  return;
2718  }
2720  if (_this->SuspendScreenSaver) {
2722  }
2723 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
SDL_bool suspend_screensaver
Definition: SDL_sysvideo.h:310
void(* SuspendScreenSaver)(_THIS)
Definition: SDL_sysvideo.h:283

◆ SDL_EnableScreenSaver()

void SDL_EnableScreenSaver ( void  )

Allow the screen to be blanked by a screensaver.

See also
SDL_IsScreenSaverEnabled()
SDL_DisableScreenSaver()

Definition at line 2696 of file SDL_video.c.

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

Referenced by SDL_VideoQuit().

2697 {
2698  if (!_this) {
2699  return;
2700  }
2701  if (!_this->suspend_screensaver) {
2702  return;
2703  }
2705  if (_this->SuspendScreenSaver) {
2707  }
2708 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
SDL_bool suspend_screensaver
Definition: SDL_sysvideo.h:310
void(* SuspendScreenSaver)(_THIS)
Definition: SDL_sysvideo.h:283

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

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

954 {
955  SDL_VideoDisplay *display;
956 
957  CHECK_DISPLAY_INDEX(displayIndex, NULL);
958 
959  display = &_this->displays[displayIndex];
960  return SDL_GetClosestDisplayModeForDisplay(display, mode, closest);
961 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
SDL_VideoDisplay * displays
Definition: SDL_sysvideo.h:312
#define NULL
Definition: begin_code.h:164
static SDL_DisplayMode * SDL_GetClosestDisplayModeForDisplay(SDL_VideoDisplay *display, const SDL_DisplayMode *mode, SDL_DisplayMode *closest)
Definition: SDL_video.c:844
#define CHECK_DISPLAY_INDEX(displayIndex, retval)
Definition: SDL_video.c:134

◆ SDL_GetCurrentDisplayMode()

int SDL_GetCurrentDisplayMode ( int  displayIndex,
SDL_DisplayMode mode 
)

Fill in information about the current display mode.

Definition at line 830 of file SDL_video.c.

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

831 {
832  SDL_VideoDisplay *display;
833 
834  CHECK_DISPLAY_INDEX(displayIndex, -1);
835 
836  display = &_this->displays[displayIndex];
837  if (mode) {
838  *mode = display->current_mode;
839  }
840  return 0;
841 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
SDL_DisplayMode current_mode
Definition: SDL_sysvideo.h:132
SDL_VideoDisplay * displays
Definition: SDL_sysvideo.h:312
#define CHECK_DISPLAY_INDEX(displayIndex, retval)
Definition: SDL_video.c:134

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

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

577 {
578  if (!_this) {
580  return NULL;
581  }
582  return _this->name;
583 }
const char * name
Definition: SDL_sysvideo.h:151
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
#define NULL
Definition: begin_code.h:164
static int SDL_UninitializedVideo()
Definition: SDL_video.c:440

◆ SDL_GetDesktopDisplayMode()

int SDL_GetDesktopDisplayMode ( int  displayIndex,
SDL_DisplayMode mode 
)

Fill in information about the desktop display mode.

Definition at line 816 of file SDL_video.c.

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

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

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

References CHECK_DISPLAY_INDEX, SDL_VideoDisplay::current_mode, SDL_VideoDevice::displays, SDL_VideoDevice::GetDisplayBounds, SDL_DisplayMode::h, SDL_Rect::h, SDL_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().

677 {
678  CHECK_DISPLAY_INDEX(displayIndex, -1);
679 
680  if (rect) {
681  SDL_VideoDisplay *display = &_this->displays[displayIndex];
682 
683  if (_this->GetDisplayBounds) {
684  if (_this->GetDisplayBounds(_this, display, rect) == 0) {
685  return 0;
686  }
687  }
688 
689  /* Assume that the displays are left to right */
690  if (displayIndex == 0) {
691  rect->x = 0;
692  rect->y = 0;
693  } else {
694  SDL_GetDisplayBounds(displayIndex-1, rect);
695  rect->x += rect->w;
696  }
697  rect->w = display->current_mode.w;
698  rect->h = display->current_mode.h;
699  }
700  return 0; /* !!! FIXME: should this be an error if (rect==NULL) ? */
701 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
SDL_DisplayMode current_mode
Definition: SDL_sysvideo.h:132
SDL_VideoDisplay * displays
Definition: SDL_sysvideo.h:312
int(* GetDisplayBounds)(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect)
Definition: SDL_sysvideo.h:181
int x
Definition: SDL_rect.h:66
int SDL_GetDisplayBounds(int displayIndex, SDL_Rect *rect)
Get the desktop area represented by a display, with the primary display located at 0...
Definition: SDL_video.c:676
int w
Definition: SDL_rect.h:67
int h
Definition: SDL_rect.h:67
#define CHECK_DISPLAY_INDEX(displayIndex, retval)
Definition: SDL_video.c:134
int y
Definition: SDL_rect.h:66

◆ SDL_GetDisplayDPI()

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

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

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

Definition at line 723 of file SDL_video.c.

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

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

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

799 {
800  SDL_VideoDisplay *display;
801 
802  CHECK_DISPLAY_INDEX(displayIndex, -1);
803 
804  display = &_this->displays[displayIndex];
806  return SDL_SetError("index must be in the range of 0 - %d",
807  SDL_GetNumDisplayModesForDisplay(display) - 1);
808  }
809  if (mode) {
810  *mode = display->display_modes[index];
811  }
812  return 0;
813 }
static int SDL_GetNumDisplayModesForDisplay(SDL_VideoDisplay *display)
Definition: SDL_video.c:779
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
SDL_DisplayMode * display_modes
Definition: SDL_sysvideo.h:130
SDL_VideoDisplay * displays
Definition: SDL_sysvideo.h:312
GLuint index
#define SDL_SetError
#define CHECK_DISPLAY_INDEX(displayIndex, retval)
Definition: SDL_video.c:134

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

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

669 {
670  CHECK_DISPLAY_INDEX(displayIndex, NULL);
671 
672  return _this->displays[displayIndex].name;
673 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
SDL_VideoDisplay * displays
Definition: SDL_sysvideo.h:312
#define NULL
Definition: begin_code.h:164
#define CHECK_DISPLAY_INDEX(displayIndex, retval)
Definition: SDL_video.c:134

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

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

704 {
705  CHECK_DISPLAY_INDEX(displayIndex, -1);
706 
707  if (rect) {
708  SDL_VideoDisplay *display = &_this->displays[displayIndex];
709 
711  if (_this->GetDisplayUsableBounds(_this, display, rect) == 0) {
712  return 0;
713  }
714  }
715 
716  /* Oh well, just give the entire display bounds. */
717  return SDL_GetDisplayBounds(displayIndex, rect);
718  }
719  return 0; /* !!! FIXME: should this be an error if (rect==NULL) ? */
720 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
SDL_VideoDisplay * displays
Definition: SDL_sysvideo.h:312
int SDL_GetDisplayBounds(int displayIndex, SDL_Rect *rect)
Get the desktop area represented by a display, with the primary display located at 0...
Definition: SDL_video.c:676
#define CHECK_DISPLAY_INDEX(displayIndex, retval)
Definition: SDL_video.c:134
int(* GetDisplayUsableBounds)(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect)
Definition: SDL_sysvideo.h:191

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

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

2483 {
2485  return _this->grabbed_window;
2486 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
#define SDL_assert(condition)
Definition: SDL_assert.h:169
SDL_Window * grabbed_window
Definition: SDL_sysvideo.h:314
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 790 of file SDL_video.c.

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

791 {
792  CHECK_DISPLAY_INDEX(displayIndex, -1);
793 
794  return SDL_GetNumDisplayModesForDisplay(&_this->displays[displayIndex]);
795 }
static int SDL_GetNumDisplayModesForDisplay(SDL_VideoDisplay *display)
Definition: SDL_video.c:779
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
SDL_VideoDisplay * displays
Definition: SDL_sysvideo.h:312
#define CHECK_DISPLAY_INDEX(displayIndex, retval)
Definition: SDL_video.c:134

◆ SDL_GetNumVideoDisplays()

int SDL_GetNumVideoDisplays ( void  )

Returns the number of available video displays.

See also
SDL_GetDisplayBounds()

Definition at line 635 of file SDL_video.c.

References SDL_VideoDevice::num_displays, and SDL_UninitializedVideo().

636 {
637  if (!_this) {
639  return 0;
640  }
641  return _this->num_displays;
642 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
static int SDL_UninitializedVideo()
Definition: SDL_video.c:440

◆ SDL_GetNumVideoDrivers()

int SDL_GetNumVideoDrivers ( void  )

Get the number of video drivers compiled into SDL.

See also
SDL_GetVideoDriver()

Definition at line 446 of file SDL_video.c.

References SDL_arraysize.

Referenced by SDL_GetVideoDriver().

447 {
448  return SDL_arraysize(bootstrap) - 1;
449 }
static VideoBootStrap * bootstrap[]
Definition: SDL_video.c:60
#define SDL_arraysize(array)
Definition: SDL_stdinc.h:93

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

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

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

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

References CHECK_WINDOW_MAGIC, SDL_VideoDevice::GetWindowBordersSize, and SDL_Unsupported.

1967 {
1968  int dummy = 0;
1969 
1970  if (!top) { top = &dummy; }
1971  if (!left) { left = &dummy; }
1972  if (!right) { right = &dummy; }
1973  if (!bottom) { bottom = &dummy; }
1974 
1975  /* Always initialize, so applications don't have to care */
1976  *top = *left = *bottom = *right = 0;
1977 
1978  CHECK_WINDOW_MAGIC(window, -1);
1979 
1980  if (!_this->GetWindowBordersSize) {
1981  return SDL_Unsupported();
1982  }
1983 
1984  return _this->GetWindowBordersSize(_this, window, top, left, bottom, right);
1985 }
GLdouble GLdouble right
GLint GLint bottom
int(* GetWindowBordersSize)(_THIS, SDL_Window *window, int *top, int *left, int *bottom, int *right)
Definition: SDL_sysvideo.h:218
GLdouble GLdouble GLdouble GLdouble top
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:123
#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 2278 of file SDL_video.c.

References SDL_Window::brightness, and CHECK_WINDOW_MAGIC.

2279 {
2280  CHECK_WINDOW_MAGIC(window, 1.0f);
2281 
2282  return window->brightness;
2283 }
GLfloat f
float brightness
Definition: SDL_sysvideo.h:93
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:123

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

1763 {
1765 
1766  CHECK_WINDOW_MAGIC(window, NULL);
1767 
1768  /* Input validation */
1769  if (name == NULL || name[0] == '\0') {
1770  SDL_InvalidParamError("name");
1771  return NULL;
1772  }
1773 
1774  for (data = window->data; data; data = data->next) {
1775  if (data->name && SDL_strcmp(data->name, name) == 0) {
1776  return data->data;
1777  }
1778  }
1779  return NULL;
1780 }
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:164
#define SDL_strcmp
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:123
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 1013 of file SDL_video.c.

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

Referenced by SDL_GetDisplayForWindow(), and SDL_GetWindowPosition().

1014 {
1015  int displayIndex;
1016  int i, dist;
1017  int closest = -1;
1018  int closest_dist = 0x7FFFFFFF;
1019  SDL_Point center;
1020  SDL_Point delta;
1021  SDL_Rect rect;
1022 
1023  CHECK_WINDOW_MAGIC(window, -1);
1024 
1025  if (SDL_WINDOWPOS_ISUNDEFINED(window->x) ||
1026  SDL_WINDOWPOS_ISCENTERED(window->x)) {
1027  displayIndex = (window->x & 0xFFFF);
1028  if (displayIndex >= _this->num_displays) {
1029  displayIndex = 0;
1030  }
1031  return displayIndex;
1032  }
1033  if (SDL_WINDOWPOS_ISUNDEFINED(window->y) ||
1034  SDL_WINDOWPOS_ISCENTERED(window->y)) {
1035  displayIndex = (window->y & 0xFFFF);
1036  if (displayIndex >= _this->num_displays) {
1037  displayIndex = 0;
1038  }
1039  return displayIndex;
1040  }
1041 
1042  /* Find the display containing the window */
1043  for (i = 0; i < _this->num_displays; ++i) {
1044  SDL_VideoDisplay *display = &_this->displays[i];
1045 
1046  if (display->fullscreen_window == window) {
1047  return i;
1048  }
1049  }
1050  center.x = window->x + window->w / 2;
1051  center.y = window->y + window->h / 2;
1052  for (i = 0; i < _this->num_displays; ++i) {
1053  SDL_GetDisplayBounds(i, &rect);
1054  if (SDL_EnclosePoints(&center, 1, &rect, NULL)) {
1055  return i;
1056  }
1057 
1058  delta.x = center.x - (rect.x + rect.w / 2);
1059  delta.y = center.y - (rect.y + rect.h / 2);
1060  dist = (delta.x*delta.x + delta.y*delta.y);
1061  if (dist < closest_dist) {
1062  closest = i;
1063  closest_dist = dist;
1064  }
1065  }
1066  if (closest < 0) {
1067  SDL_SetError("Couldn't find any displays");
1068  }
1069  return closest;
1070 }
#define SDL_WINDOWPOS_ISUNDEFINED(X)
Definition: SDL_video.h:131
SDL_Rect rect
Definition: testrelative.c:27
The structure that defines a point.
Definition: SDL_rect.h:48
#define SDL_WINDOWPOS_ISCENTERED(X)
Definition: SDL_video.h:140
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
int x
Definition: SDL_rect.h:50
int y
Definition: SDL_rect.h:51
SDL_VideoDisplay * displays
Definition: SDL_sysvideo.h:312
int x
Definition: SDL_rect.h:66
int SDL_GetDisplayBounds(int displayIndex, SDL_Rect *rect)
Get the desktop area represented by a display, with the primary display located at 0...
Definition: SDL_video.c:676
int w
Definition: SDL_rect.h:67
SDL_Window * fullscreen_window
Definition: SDL_sysvideo.h:134
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:164
#define SDL_SetError
int h
Definition: SDL_rect.h:67
#define SDL_EnclosePoints
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:123
int y
Definition: SDL_rect.h:66
A rectangle, with the origin at the upper left.
Definition: SDL_rect.h:64

◆ SDL_GetWindowDisplayMode()

int SDL_GetWindowDisplayMode ( SDL_Window window,
SDL_DisplayMode mode 
)

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

See also
SDL_SetWindowDisplayMode()
SDL_SetWindowFullscreen()

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

1105 {
1106  SDL_DisplayMode fullscreen_mode;
1107  SDL_VideoDisplay *display;
1108 
1109  CHECK_WINDOW_MAGIC(window, -1);
1110 
1111  if (!mode) {
1112  return SDL_InvalidParamError("mode");
1113  }
1114 
1115  fullscreen_mode = window->fullscreen_mode;
1116  if (!fullscreen_mode.w) {
1117  fullscreen_mode.w = window->windowed.w;
1118  }
1119  if (!fullscreen_mode.h) {
1120  fullscreen_mode.h = window->windowed.h;
1121  }
1122 
1123  display = SDL_GetDisplayForWindow(window);
1124 
1125  /* if in desktop size mode, just return the size of the desktop */
1127  fullscreen_mode = display->desktop_mode;
1129  &fullscreen_mode,
1130  &fullscreen_mode)) {
1131  return SDL_SetError("Couldn't find display mode match");
1132  }
1133 
1134  if (mode) {
1135  *mode = fullscreen_mode;
1136  }
1137  return 0;
1138 }
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:1073
int w
Definition: SDL_rect.h:67
SDL_DisplayMode desktop_mode
Definition: SDL_sysvideo.h:131
#define SDL_SetError
int h
Definition: SDL_rect.h:67
static SDL_DisplayMode * SDL_GetClosestDisplayModeForDisplay(SDL_VideoDisplay *display, const SDL_DisplayMode *mode, SDL_DisplayMode *closest)
Definition: SDL_video.c:844
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:123
Uint32 flags
Definition: SDL_sysvideo.h:83

◆ SDL_GetWindowFlags()

Uint32 SDL_GetWindowFlags ( SDL_Window window)

Get the window flags.

Definition at line 1660 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, and SDL_Window::flags.

Referenced by SDL_ShowMessageBox().

1661 {
1662  CHECK_WINDOW_MAGIC(window, 0);
1663 
1664  return window->flags;
1665 }
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:123
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 1644 of file SDL_video.c.

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

1645 {
1646  SDL_Window *window;
1647 
1648  if (!_this) {
1649  return NULL;
1650  }
1651  for (window = _this->windows; window; window = window->next) {
1652  if (window->id == id) {
1653  return window;
1654  }
1655  }
1656  return NULL;
1657 }
SDL_Window * next
Definition: SDL_sysvideo.h:114
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
SDL_Window * windows
Definition: SDL_sysvideo.h:313
#define NULL
Definition: begin_code.h:164
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 2382 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().

2385 {
2386  CHECK_WINDOW_MAGIC(window, -1);
2387 
2388  if (!window->gamma) {
2389  int i;
2390 
2391  window->gamma = (Uint16 *)SDL_malloc(256*6*sizeof(Uint16));
2392  if (!window->gamma) {
2393  return SDL_OutOfMemory();
2394  }
2395  window->saved_gamma = window->gamma + 3*256;
2396 
2397  if (_this->GetWindowGammaRamp) {
2398  if (_this->GetWindowGammaRamp(_this, window, window->gamma) < 0) {
2399  return -1;
2400  }
2401  } else {
2402  /* Create an identity gamma ramp */
2403  for (i = 0; i < 256; ++i) {
2404  Uint16 value = (Uint16)((i << 8) | i);
2405 
2406  window->gamma[0*256+i] = value;
2407  window->gamma[1*256+i] = value;
2408  window->gamma[2*256+i] = value;
2409  }
2410  }
2411  SDL_memcpy(window->saved_gamma, window->gamma, 3*256*sizeof(Uint16));
2412  }
2413 
2414  if (red) {
2415  SDL_memcpy(red, &window->gamma[0*256], 256*sizeof(Uint16));
2416  }
2417  if (green) {
2418  SDL_memcpy(green, &window->gamma[1*256], 256*sizeof(Uint16));
2419  }
2420  if (blue) {
2421  SDL_memcpy(blue, &window->gamma[2*256], 256*sizeof(Uint16));
2422  }
2423  return 0;
2424 }
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:121
#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:232
uint16_t Uint16
Definition: SDL_stdinc.h:169
#define SDL_malloc
Uint16 * gamma
Definition: SDL_sysvideo.h:94
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:123

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

2475 {
2476  CHECK_WINDOW_MAGIC(window, SDL_FALSE);
2478  return window == _this->grabbed_window;
2479 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
#define SDL_assert(condition)
Definition: SDL_assert.h:169
SDL_Window * grabbed_window
Definition: SDL_sysvideo.h:314
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:123
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 1636 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, and SDL_Window::id.

1637 {
1638  CHECK_WINDOW_MAGIC(window, 0);
1639 
1640  return window->id;
1641 }
Uint32 id
Definition: SDL_sysvideo.h:76
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:123

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

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

2062 {
2063  CHECK_WINDOW_MAGIC(window,);
2064  if (max_w) {
2065  *max_w = window->max_w;
2066  }
2067  if (max_h) {
2068  *max_h = window->max_h;
2069  }
2070 }
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:123

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

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

2020 {
2021  CHECK_WINDOW_MAGIC(window,);
2022  if (min_w) {
2023  *min_w = window->min_w;
2024  }
2025  if (min_h) {
2026  *min_h = window->min_h;
2027  }
2028 }
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:123

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

References CHECK_WINDOW_MAGIC, and SDL_Window::opacity.

2311 {
2312  CHECK_WINDOW_MAGIC(window, -1);
2313 
2314  if (out_opacity) {
2315  *out_opacity = window->opacity;
2316  }
2317 
2318  return 0;
2319 }
float opacity
Definition: SDL_sysvideo.h:91
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:123

◆ SDL_GetWindowPixelFormat()

Uint32 SDL_GetWindowPixelFormat ( SDL_Window window)

Get the pixel format associated with the window.

Definition at line 1141 of file SDL_video.c.

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

1142 {
1143  SDL_VideoDisplay *display;
1144 
1146 
1147  display = SDL_GetDisplayForWindow(window);
1148  return display->current_mode.format;
1149 }
SDL_VideoDisplay * SDL_GetDisplayForWindow(SDL_Window *window)
Definition: SDL_video.c:1073
SDL_DisplayMode current_mode
Definition: SDL_sysvideo.h:132
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:123
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 1828 of file SDL_video.c.

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

1829 {
1830  CHECK_WINDOW_MAGIC(window,);
1831 
1832  /* Fullscreen windows are always at their display's origin */
1833  if (window->flags & SDL_WINDOW_FULLSCREEN) {
1834  int displayIndex;
1835 
1836  if (x) {
1837  *x = 0;
1838  }
1839  if (y) {
1840  *y = 0;
1841  }
1842 
1843  /* Find the window's monitor and update to the
1844  monitor offset. */
1845  displayIndex = SDL_GetWindowDisplayIndex(window);
1846  if (displayIndex >= 0) {
1847  SDL_Rect bounds;
1848 
1849  SDL_zero(bounds);
1850 
1851  SDL_GetDisplayBounds(displayIndex, &bounds);
1852  if (x) {
1853  *x = bounds.x;
1854  }
1855  if (y) {
1856  *y = bounds.y;
1857  }
1858  }
1859  } else {
1860  if (x) {
1861  *x = window->x;
1862  }
1863  if (y) {
1864  *y = window->y;
1865  }
1866  }
1867 }
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:66
int SDL_GetDisplayBounds(int displayIndex, SDL_Rect *rect)
Get the desktop area represented by a display, with the primary display located at 0...
Definition: SDL_video.c:676
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:123
int SDL_GetWindowDisplayIndex(SDL_Window *window)
Get the display index associated with a window.
Definition: SDL_video.c:1013
Uint32 flags
Definition: SDL_sysvideo.h:83
int y
Definition: SDL_rect.h:66
A rectangle, with the origin at the upper left.
Definition: SDL_rect.h:64

◆ SDL_GetWindowSize()

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

Get the size of a window's client area.

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

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

See also
SDL_SetWindowSize()

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

1955 {
1956  CHECK_WINDOW_MAGIC(window,);
1957  if (w) {
1958  *w = window->w;
1959  }
1960  if (h) {
1961  *h = window->h;
1962  }
1963 }
GLfloat GLfloat GLfloat GLfloat h
GLubyte GLubyte GLubyte GLubyte w
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:123

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

2217 {
2218  CHECK_WINDOW_MAGIC(window, NULL);
2219 
2220  if (!window->surface_valid) {
2221  if (window->surface) {
2222  window->surface->flags &= ~SDL_DONTFREE;
2223  SDL_FreeSurface(window->surface);
2224  }
2225  window->surface = SDL_CreateWindowFramebuffer(window);
2226  if (window->surface) {
2227  window->surface_valid = SDL_TRUE;
2228  window->surface->flags |= SDL_DONTFREE;
2229  }
2230  }
2231  return window->surface;
2232 }
#define SDL_DONTFREE
Definition: SDL_surface.h:55
Uint32 flags
Definition: SDL_surface.h:71
#define SDL_FreeSurface
#define NULL
Definition: begin_code.h:164
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:123
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:2192

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

References CHECK_WINDOW_MAGIC, and SDL_Window::title.

1686 {
1687  CHECK_WINDOW_MAGIC(window, "");
1688 
1689  return window->title ? window->title : "";
1690 }
char * title
Definition: SDL_sysvideo.h:77
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:123

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

3392 {
3394  CHECK_WINDOW_MAGIC(window, NULL);
3395 
3396  if (!(window->flags & SDL_WINDOW_OPENGL)) {
3397  SDL_SetError("The specified window isn't an OpenGL window");
3398  return NULL;
3399  }
3400 
3401  ctx = _this->GL_CreateContext(_this, window);
3402 
3403  /* Creating a context is assumed to make it current in the SDL driver. */
3404  if (ctx) {
3406  _this->current_glctx = ctx;
3409  }
3410  return ctx;
3411 }
#define SDL_TLSSet
SDL_TLSID current_glwin_tls
Definition: SDL_sysvideo.h:361
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
void * SDL_GLContext
An opaque handle to an OpenGL context.
Definition: SDL_video.h:175
SDL_GLContext current_glctx
Definition: SDL_sysvideo.h:360
SDL_GLContext(* GL_CreateContext)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:257
#define NULL
Definition: begin_code.h:164
#define SDL_SetError
EGLSurface EGLNativeWindowType * window
Definition: eglext.h:1025
SDL_TLSID current_glctx_tls
Definition: SDL_sysvideo.h:362
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:123
Uint32 flags
Definition: SDL_sysvideo.h:83
SDL_Window * current_glwin
Definition: SDL_sysvideo.h:359
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 3522 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().

3523 {
3524  if (!_this || !context) {
3525  return;
3526  }
3527 
3528  if (SDL_GL_GetCurrentContext() == context) {
3530  }
3531 
3533 }
static screen_context_t context
Definition: video.c:25
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
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:3414
#define NULL
Definition: begin_code.h:164
SDL_GLContext SDL_GL_GetCurrentContext(void)
Get the currently active OpenGL context.
Definition: SDL_video.c:3455
void(* GL_DeleteContext)(_THIS, SDL_GLContext context)
Definition: SDL_sysvideo.h:263

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

2853 {
2854 #if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
2855  const GLubyte *(APIENTRY * glGetStringFunc) (GLenum);
2856  const char *extensions;
2857  const char *start;
2858  const char *where, *terminator;
2859 
2860  /* Extension names should not have spaces. */
2861  where = SDL_strchr(extension, ' ');
2862  if (where || *extension == '\0') {
2863  return SDL_FALSE;
2864  }
2865  /* See if there's an environment variable override */
2866  start = SDL_getenv(extension);
2867  if (start && *start == '0') {
2868  return SDL_FALSE;
2869  }
2870 
2871  /* Lookup the available extensions */
2872 
2873  glGetStringFunc = SDL_GL_GetProcAddress("glGetString");
2874  if (!glGetStringFunc) {
2875  return SDL_FALSE;
2876  }
2877 
2878  if (isAtLeastGL3((const char *) glGetStringFunc(GL_VERSION))) {
2879  const GLubyte *(APIENTRY * glGetStringiFunc) (GLenum, GLuint);
2880  void (APIENTRY * glGetIntegervFunc) (GLenum pname, GLint * params);
2881  GLint num_exts = 0;
2882  GLint i;
2883 
2884  glGetStringiFunc = SDL_GL_GetProcAddress("glGetStringi");
2885  glGetIntegervFunc = SDL_GL_GetProcAddress("glGetIntegerv");
2886  if ((!glGetStringiFunc) || (!glGetIntegervFunc)) {
2887  return SDL_FALSE;
2888  }
2889 
2890  #ifndef GL_NUM_EXTENSIONS
2891  #define GL_NUM_EXTENSIONS 0x821D
2892  #endif
2893  glGetIntegervFunc(GL_NUM_EXTENSIONS, &num_exts);
2894  for (i = 0; i < num_exts; i++) {
2895  const char *thisext = (const char *) glGetStringiFunc(GL_EXTENSIONS, i);
2896  if (SDL_strcmp(thisext, extension) == 0) {
2897  return SDL_TRUE;
2898  }
2899  }
2900 
2901  return SDL_FALSE;
2902  }
2903 
2904  /* Try the old way with glGetString(GL_EXTENSIONS) ... */
2905 
2906  extensions = (const char *) glGetStringFunc(GL_EXTENSIONS);
2907  if (!extensions) {
2908  return SDL_FALSE;
2909  }
2910  /*
2911  * It takes a bit of care to be fool-proof about parsing the OpenGL
2912  * extensions string. Don't be fooled by sub-strings, etc.
2913  */
2914 
2915  start = extensions;
2916 
2917  for (;;) {
2918  where = SDL_strstr(start, extension);
2919  if (!where)
2920  break;
2921 
2922  terminator = where + SDL_strlen(extension);
2923  if (where == extensions || *(where - 1) == ' ')
2924  if (*terminator == ' ' || *terminator == '\0')
2925  return SDL_TRUE;
2926 
2927  start = terminator;
2928  }
2929  return SDL_FALSE;
2930 #else
2931  return SDL_FALSE;
2932 #endif
2933 }
#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:2845
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:2805
#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 3142 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.

3143 {
3144 #if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
3145  GLenum (APIENTRY *glGetErrorFunc) (void);
3146  GLenum attrib = 0;
3147  GLenum error = 0;
3148 
3149  /*
3150  * Some queries in Core Profile desktop OpenGL 3+ contexts require
3151  * glGetFramebufferAttachmentParameteriv instead of glGetIntegerv. Note that
3152  * the enums we use for the former function don't exist in OpenGL ES 2, and
3153  * the function itself doesn't exist prior to OpenGL 3 and OpenGL ES 2.
3154  */
3155 #if SDL_VIDEO_OPENGL
3156  const GLubyte *(APIENTRY *glGetStringFunc) (GLenum name);
3157  void (APIENTRY *glGetFramebufferAttachmentParameterivFunc) (GLenum target, GLenum attachment, GLenum pname, GLint* params);
3158  GLenum attachment = GL_BACK_LEFT;
3159  GLenum attachmentattrib = 0;
3160 #endif
3161 
3162  if (!value) {
3163  return SDL_InvalidParamError("value");
3164  }
3165 
3166  /* Clear value in any case */
3167  *value = 0;
3168 
3169  if (!_this) {
3170  return SDL_UninitializedVideo();
3171  }
3172 
3173  switch (attr) {
3174  case SDL_GL_RED_SIZE:
3175 #if SDL_VIDEO_OPENGL
3176  attachmentattrib = GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE;
3177 #endif
3178  attrib = GL_RED_BITS;
3179  break;
3180  case SDL_GL_BLUE_SIZE:
3181 #if SDL_VIDEO_OPENGL
3182  attachmentattrib = GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE;
3183 #endif
3184  attrib = GL_BLUE_BITS;
3185  break;
3186  case SDL_GL_GREEN_SIZE:
3187 #if SDL_VIDEO_OPENGL
3188  attachmentattrib = GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE;
3189 #endif
3190  attrib = GL_GREEN_BITS;
3191  break;
3192  case SDL_GL_ALPHA_SIZE:
3193 #if SDL_VIDEO_OPENGL
3194  attachmentattrib = GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE;
3195 #endif
3196  attrib = GL_ALPHA_BITS;
3197  break;
3198  case SDL_GL_DOUBLEBUFFER:
3199 #if SDL_VIDEO_OPENGL
3200  attrib = GL_DOUBLEBUFFER;
3201  break;
3202 #else
3203  /* OpenGL ES 1.0 and above specifications have EGL_SINGLE_BUFFER */
3204  /* parameter which switches double buffer to single buffer. OpenGL ES */
3205  /* SDL driver must set proper value after initialization */
3207  return 0;
3208 #endif
3209  case SDL_GL_DEPTH_SIZE:
3210 #if SDL_VIDEO_OPENGL
3211  attachment = GL_DEPTH;
3212  attachmentattrib = GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE;
3213 #endif
3214  attrib = GL_DEPTH_BITS;
3215  break;
3216  case SDL_GL_STENCIL_SIZE:
3217 #if SDL_VIDEO_OPENGL
3218  attachment = GL_STENCIL;
3219  attachmentattrib = GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE;
3220 #endif
3221  attrib = GL_STENCIL_BITS;
3222  break;
3223 #if SDL_VIDEO_OPENGL
3224  case SDL_GL_ACCUM_RED_SIZE:
3225  attrib = GL_ACCUM_RED_BITS;
3226  break;
3228  attrib = GL_ACCUM_GREEN_BITS;
3229  break;
3231  attrib = GL_ACCUM_BLUE_BITS;
3232  break;
3234  attrib = GL_ACCUM_ALPHA_BITS;
3235  break;
3236  case SDL_GL_STEREO:
3237  attrib = GL_STEREO;
3238  break;
3239 #else
3240  case SDL_GL_ACCUM_RED_SIZE:
3244  case SDL_GL_STEREO:
3245  /* none of these are supported in OpenGL ES */
3246  *value = 0;
3247  return 0;
3248 #endif
3250  attrib = GL_SAMPLE_BUFFERS;
3251  break;
3253  attrib = GL_SAMPLES;
3254  break;
3256 #if SDL_VIDEO_OPENGL
3257  attrib = GL_CONTEXT_RELEASE_BEHAVIOR;
3258 #else
3260 #endif
3261  break;
3262  case SDL_GL_BUFFER_SIZE:
3263  {
3264  int rsize = 0, gsize = 0, bsize = 0, asize = 0;
3265 
3266  /* There doesn't seem to be a single flag in OpenGL for this! */
3267  if (SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &rsize) < 0) {
3268  return -1;
3269  }
3270  if (SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &gsize) < 0) {
3271  return -1;
3272  }
3273  if (SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &bsize) < 0) {
3274  return -1;
3275  }
3276  if (SDL_GL_GetAttribute(SDL_GL_ALPHA_SIZE, &asize) < 0) {
3277  return -1;
3278  }
3279 
3280  *value = rsize + gsize + bsize + asize;
3281  return 0;
3282  }
3284  {
3285  /* FIXME: How do we get this information? */
3286  *value = (_this->gl_config.accelerated != 0);
3287  return 0;
3288  }
3290  {
3292  return 0;
3293  }
3295  {
3297  return 0;
3298  }
3300  {
3302  return 0;
3303  }
3304  case SDL_GL_CONTEXT_EGL:
3305  /* FIXME: SDL_GL_CONTEXT_EGL to be deprecated in SDL 2.1 */
3306  {
3308  *value = 1;
3309  }
3310  else {
3311  *value = 0;
3312  }
3313  return 0;
3314  }
3315  case SDL_GL_CONTEXT_FLAGS:
3316  {
3317  *value = _this->gl_config.flags;
3318  return 0;
3319  }
3321  {
3323  return 0;
3324  }
3326  {
3328  return 0;
3329  }
3331  {
3333  return 0;
3334  }
3336  {
3338  return 0;
3339  }
3340  default:
3341  return SDL_SetError("Unknown OpenGL attribute");
3342  }
3343 
3344 #if SDL_VIDEO_OPENGL
3345  glGetStringFunc = SDL_GL_GetProcAddress("glGetString");
3346  if (!glGetStringFunc) {
3347  return -1;
3348  }
3349 
3350  if (attachmentattrib && isAtLeastGL3((const char *) glGetStringFunc(GL_VERSION))) {
3351  glGetFramebufferAttachmentParameterivFunc = SDL_GL_GetProcAddress("glGetFramebufferAttachmentParameteriv");
3352 
3353  if (glGetFramebufferAttachmentParameterivFunc) {
3354  glGetFramebufferAttachmentParameterivFunc(GL_FRAMEBUFFER, attachment, attachmentattrib, (GLint *) value);
3355  } else {
3356  return -1;
3357  }
3358  } else
3359 #endif
3360  {
3361  void (APIENTRY *glGetIntegervFunc) (GLenum pname, GLint * params);
3362  glGetIntegervFunc = SDL_GL_GetProcAddress("glGetIntegerv");
3363  if (glGetIntegervFunc) {
3364  glGetIntegervFunc(attrib, (GLint *) value);
3365  } else {
3366  return -1;
3367  }
3368  }
3369 
3370  glGetErrorFunc = SDL_GL_GetProcAddress("glGetError");
3371  if (!glGetErrorFunc) {
3372  return -1;
3373  }
3374 
3375  error = glGetErrorFunc();
3376  if (error != GL_NO_ERROR) {
3377  if (error == GL_INVALID_ENUM) {
3378  return SDL_SetError("OpenGL error: GL_INVALID_ENUM");
3379  } else if (error == GL_INVALID_VALUE) {
3380  return SDL_SetError("OpenGL error: GL_INVALID_VALUE");
3381  }
3382  return SDL_SetError("OpenGL error: %08X", error);
3383  }
3384  return 0;
3385 #else
3386  return SDL_Unsupported();
3387 #endif /* SDL_VIDEO_OPENGL */
3388 }
#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:121
#define GL_BLUE_BITS
Definition: SDL_opengl.h:515
static SDL_INLINE SDL_bool isAtLeastGL3(const char *verstr)
Definition: SDL_video.c:2845
#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:346
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:343
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:440
const GLfloat * params
void * SDL_GL_GetProcAddress(const char *proc)
Get the address of an OpenGL function.
Definition: SDL_video.c:2805
#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:3142
struct SDL_VideoDevice::@34 gl_config
#define GL_GREEN_BITS
Definition: SDL_opengl.h:514
GLenum pname
#define SDL_Unsupported()
Definition: SDL_error.h:53
#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE

◆ SDL_GL_GetCurrentContext()

SDL_GLContext SDL_GL_GetCurrentContext ( void  )

Get the currently active OpenGL context.

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

3456 {
3457  if (!_this) {
3459  return NULL;
3460  }
3462 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
void * SDL_GLContext
An opaque handle to an OpenGL context.
Definition: SDL_video.h:175
#define SDL_TLSGet
#define NULL
Definition: begin_code.h:164
SDL_TLSID current_glctx_tls
Definition: SDL_sysvideo.h:362
static int SDL_UninitializedVideo()
Definition: SDL_video.c:440

◆ SDL_GL_GetCurrentWindow()

SDL_Window* SDL_GL_GetCurrentWindow ( void  )

Get the currently active OpenGL window.

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

3446 {
3447  if (!_this) {
3449  return NULL;
3450  }
3452 }
SDL_TLSID current_glwin_tls
Definition: SDL_sysvideo.h:361
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
#define SDL_TLSGet
#define NULL
Definition: begin_code.h:164
The type used to identify a window.
Definition: SDL_sysvideo.h:73
static int SDL_UninitializedVideo()
Definition: SDL_video.c:440

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

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

3465 {
3466  CHECK_WINDOW_MAGIC(window,);
3467 
3468  if (_this->GL_GetDrawableSize) {
3469  _this->GL_GetDrawableSize(_this, window, w, h);
3470  } else {
3471  SDL_GetWindowSize(window, w, h);
3472  }
3473 }
GLfloat GLfloat GLfloat GLfloat h
void(* GL_GetDrawableSize)(_THIS, SDL_Window *window, int *w, int *h)
Definition: SDL_sysvideo.h:259
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
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:1954
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:123

◆ SDL_GL_GetProcAddress()

void* SDL_GL_GetProcAddress ( const char *  proc)

Get the address of an OpenGL function.

Definition at line 2805 of file SDL_video.c.

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

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

2806 {
2807  void *func;
2808 
2809  if (!_this) {
2811  return NULL;
2812  }
2813  func = NULL;
2814  if (_this->GL_GetProcAddress) {
2815  if (_this->gl_config.driver_loaded) {
2816  func = _this->GL_GetProcAddress(_this, proc);
2817  } else {
2818  SDL_SetError("No GL driver has been loaded");
2819  }
2820  } else {
2821  SDL_SetError("No dynamic GL support in video driver");
2822  }
2823  return func;
2824 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
#define NULL
Definition: begin_code.h:164
#define SDL_SetError
GLenum func
static int SDL_UninitializedVideo()
Definition: SDL_video.c:440
struct SDL_VideoDevice::@34 gl_config
void *(* GL_GetProcAddress)(_THIS, const char *proc)
Definition: SDL_sysvideo.h:255

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

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

3491 {
3492  if (!_this) {
3493  return 0;
3494  } else if (SDL_GL_GetCurrentContext() == NULL) {
3495  return 0;
3496  } else if (_this->GL_GetSwapInterval) {
3497  return _this->GL_GetSwapInterval(_this);
3498  } else {
3499  return 0;
3500  }
3501 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
#define NULL
Definition: begin_code.h:164
SDL_GLContext SDL_GL_GetCurrentContext(void)
Get the currently active OpenGL context.
Definition: SDL_video.c:3455
int(* GL_GetSwapInterval)(_THIS)
Definition: SDL_sysvideo.h:261

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

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

Referenced by SDL_CreateWindow(), and SDL_RecreateWindow().

2777 {
2778  int retval;
2779 
2780  if (!_this) {
2781  return SDL_UninitializedVideo();
2782  }
2783  if (_this->gl_config.driver_loaded) {
2784  if (path && SDL_strcmp(path, _this->gl_config.driver_path) != 0) {
2785  return SDL_SetError("OpenGL library already loaded");
2786  }
2787  retval = 0;
2788  } else {
2789  if (!_this->GL_LoadLibrary) {
2790  return SDL_SetError("No dynamic GL support in video driver");
2791  }
2792  retval = _this->GL_LoadLibrary(_this, path);
2793  }
2794  if (retval == 0) {
2796  } else {
2797  if (_this->GL_UnloadLibrary) {
2799  }
2800  }
2801  return (retval);
2802 }
int(* GL_LoadLibrary)(_THIS, const char *path)
Definition: SDL_sysvideo.h:254
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
SDL_bool retval
char driver_path[256]
Definition: SDL_sysvideo.h:350
void(* GL_UnloadLibrary)(_THIS)
Definition: SDL_sysvideo.h:256
#define SDL_SetError
static int SDL_UninitializedVideo()
Definition: SDL_video.c:440
GLsizei const GLchar *const * path
struct SDL_VideoDevice::@34 gl_config
#define SDL_strcmp

◆ SDL_GL_MakeCurrent()

int SDL_GL_MakeCurrent ( SDL_Window window,
SDL_GLContext  context 
)

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

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

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

3415 {
3416  int retval;
3417 
3418  if (window == SDL_GL_GetCurrentWindow() &&
3420  /* We're already current. */
3421  return 0;
3422  }
3423 
3424  if (!ctx) {
3425  window = NULL;
3426  } else {
3427  CHECK_WINDOW_MAGIC(window, -1);
3428 
3429  if (!(window->flags & SDL_WINDOW_OPENGL)) {
3430  return SDL_SetError("The specified window isn't an OpenGL window");
3431  }
3432  }
3433 
3434  retval = _this->GL_MakeCurrent(_this, window, ctx);
3435  if (retval == 0) {
3437  _this->current_glctx = ctx;
3440  }
3441  return retval;
3442 }
#define SDL_TLSSet
SDL_TLSID current_glwin_tls
Definition: SDL_sysvideo.h:361
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
SDL_bool retval
SDL_GLContext current_glctx
Definition: SDL_sysvideo.h:360
int(* GL_MakeCurrent)(_THIS, SDL_Window *window, SDL_GLContext context)
Definition: SDL_sysvideo.h:258
#define NULL
Definition: begin_code.h:164
#define SDL_SetError
EGLSurface EGLNativeWindowType * window
Definition: eglext.h:1025
SDL_TLSID current_glctx_tls
Definition: SDL_sysvideo.h:362
SDL_GLContext SDL_GL_GetCurrentContext(void)
Get the currently active OpenGL context.
Definition: SDL_video.c:3455
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:123
Uint32 flags
Definition: SDL_sysvideo.h:83
SDL_Window * SDL_GL_GetCurrentWindow(void)
Get the currently active OpenGL window.
Definition: SDL_video.c:3445
SDL_Window * current_glwin
Definition: SDL_sysvideo.h:359
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 2967 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().

2968 {
2969  if (!_this) {
2970  return;
2971  }
2972 
2973  _this->gl_config.red_size = 3;
2974  _this->gl_config.green_size = 3;
2975  _this->gl_config.blue_size = 2;
2976  _this->gl_config.alpha_size = 0;
2978  _this->gl_config.depth_size = 16;
2985  _this->gl_config.stereo = 0;
2989  _this->gl_config.accelerated = -1; /* accelerated or not, both are fine */
2990 
2995  } else {
2996 #if SDL_VIDEO_OPENGL
3000 #elif SDL_VIDEO_OPENGL_ES2
3004 #elif SDL_VIDEO_OPENGL_ES
3008 #endif
3009  }
3010 
3011  _this->gl_config.flags = 0;
3013  _this->gl_config.no_error = 0;
3016 
3018 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
int framebuffer_srgb_capable
Definition: SDL_sysvideo.h:346
int share_with_current_context
Definition: SDL_sysvideo.h:343
struct SDL_VideoDevice::@34 gl_config
void(* GL_DefaultProfileConfig)(_THIS, int *mask, int *major, int *minor)
Definition: SDL_sysvideo.h:264

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

3022 {
3023 #if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
3024  int retval;
3025 
3026  if (!_this) {
3027  return SDL_UninitializedVideo();
3028  }
3029  retval = 0;
3030  switch (attr) {
3031  case SDL_GL_RED_SIZE:
3033  break;
3034  case SDL_GL_GREEN_SIZE:
3036  break;
3037  case SDL_GL_BLUE_SIZE:
3039  break;
3040  case SDL_GL_ALPHA_SIZE:
3042  break;
3043  case SDL_GL_DOUBLEBUFFER:
3045  break;
3046  case SDL_GL_BUFFER_SIZE:
3048  break;
3049  case SDL_GL_DEPTH_SIZE:
3051  break;
3052  case SDL_GL_STENCIL_SIZE:
3054  break;
3055  case SDL_GL_ACCUM_RED_SIZE:
3057  break;
3060  break;
3063  break;
3066  break;
3067  case SDL_GL_STEREO:
3069  break;
3072  break;
3075  break;
3078  break;
3081  break;
3084  break;
3087  break;
3088  case SDL_GL_CONTEXT_EGL:
3089  /* FIXME: SDL_GL_CONTEXT_EGL to be deprecated in SDL 2.1 */
3090  if (value != 0) {
3092  } else {
3094  };
3095  break;
3096  case SDL_GL_CONTEXT_FLAGS:
3101  retval = SDL_SetError("Unknown OpenGL context flag %d", value);
3102  break;
3103  }
3105  break;
3107  if (value != 0 &&
3111  retval = SDL_SetError("Unknown OpenGL context profile %d", value);
3112  break;
3113  }
3115  break;
3118  break;
3121  break;
3124  break;
3127  break;
3130  break;
3131  default:
3132  retval = SDL_SetError("Unknown OpenGL attribute");
3133  break;
3134  }
3135  return retval;
3136 #else
3137  return SDL_Unsupported();
3138 #endif /* SDL_VIDEO_OPENGL */
3139 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
SDL_bool retval
GLsizei const GLfloat * value
int framebuffer_srgb_capable
Definition: SDL_sysvideo.h:346
int share_with_current_context
Definition: SDL_sysvideo.h:343
#define SDL_SetError
int SDL_GL_SetAttribute(SDL_GLattr attr, int value)
Set an OpenGL window attribute before window creation.
Definition: SDL_video.c:3021
static int SDL_UninitializedVideo()
Definition: SDL_video.c:440
struct SDL_VideoDevice::@34 gl_config
#define SDL_Unsupported()
Definition: SDL_error.h:53

◆ SDL_GL_SetSwapInterval()

int SDL_GL_SetSwapInterval ( int  interval)

Set the swap interval for the current OpenGL context.

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

Definition at line 3476 of file SDL_video.c.

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

3477 {
3478  if (!_this) {
3479  return SDL_UninitializedVideo();
3480  } else if (SDL_GL_GetCurrentContext() == NULL) {
3481  return SDL_SetError("No OpenGL context has been made current");
3482  } else if (_this->GL_SetSwapInterval) {
3483  return _this->GL_SetSwapInterval(_this, interval);
3484  } else {
3485  return SDL_SetError("Setting the swap interval is not supported");
3486  }
3487 }
int(* GL_SetSwapInterval)(_THIS, int interval)
Definition: SDL_sysvideo.h:260
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
#define NULL
Definition: begin_code.h:164
#define SDL_SetError
SDL_GLContext SDL_GL_GetCurrentContext(void)
Get the currently active OpenGL context.
Definition: SDL_video.c:3455
static int SDL_UninitializedVideo()
Definition: SDL_video.c:440

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

3505 {
3506  CHECK_WINDOW_MAGIC(window,);
3507 
3508  if (!(window->flags & SDL_WINDOW_OPENGL)) {
3509  SDL_SetError("The specified window isn't an OpenGL window");
3510  return;
3511  }
3512 
3513  if (SDL_GL_GetCurrentWindow() != window) {
3514  SDL_SetError("The specified window has not been made current");
3515  return;
3516  }
3517 
3518  _this->GL_SwapWindow(_this, window);
3519 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
#define SDL_SetError
int(* GL_SwapWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:262
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:123
Uint32 flags
Definition: SDL_sysvideo.h:83
SDL_Window * SDL_GL_GetCurrentWindow(void)
Get the currently active OpenGL window.
Definition: SDL_video.c:3445

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

2828 {
2829  if (!_this) {
2831  return;
2832  }
2833  if (_this->gl_config.driver_loaded > 0) {
2834  if (--_this->gl_config.driver_loaded > 0) {
2835  return;
2836  }
2837  if (_this->GL_UnloadLibrary) {
2839  }
2840  }
2841 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
void(* GL_UnloadLibrary)(_THIS)
Definition: SDL_sysvideo.h:256
static int SDL_UninitializedVideo()
Definition: SDL_video.c:440
struct SDL_VideoDevice::@34 gl_config

◆ SDL_HideWindow()

void SDL_HideWindow ( SDL_Window window)

Hide a window.

See also
SDL_ShowWindow()

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

2089 {
2090  CHECK_WINDOW_MAGIC(window,);
2091 
2092  if (!(window->flags & SDL_WINDOW_SHOWN)) {
2093  return;
2094  }
2095 
2096  window->is_hiding = SDL_TRUE;
2098 
2099  if (_this->HideWindow) {
2100  _this->HideWindow(_this, window);
2101  }
2102  window->is_hiding = SDL_FALSE;
2104 }
int SDL_SendWindowEvent(SDL_Window *window, Uint8 windowevent, int data1, int data2)
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
void(* HideWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:223
static int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen)
Definition: SDL_video.c:1167
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:123
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 2687 of file SDL_video.c.

References SDL_FALSE, SDL_TRUE, and SDL_VideoDevice::suspend_screensaver.

2688 {
2689  if (!_this) {
2690  return SDL_TRUE;
2691  }
2693 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
SDL_bool suspend_screensaver
Definition: SDL_sysvideo.h:310

◆ SDL_MaximizeWindow()

void SDL_MaximizeWindow ( SDL_Window window)

Make a window as large as possible.

See also
SDL_RestoreWindow()

Definition at line 2120 of file SDL_video.c.

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

Referenced by SDL_FinishWindowCreation().

2121 {
2122  CHECK_WINDOW_MAGIC(window,);
2123 
2124  if (window->flags & SDL_WINDOW_MAXIMIZED) {
2125  return;
2126  }
2127 
2128  /* !!! FIXME: should this check if the window is resizable? */
2129 
2130  if (_this->MaximizeWindow) {
2131  _this->MaximizeWindow(_this, window);
2132  }
2133 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:123
void(* MaximizeWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:225
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 2136 of file SDL_video.c.

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

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

2137 {
2138  CHECK_WINDOW_MAGIC(window,);
2139 
2140  if (window->flags & SDL_WINDOW_MINIMIZED) {
2141  return;
2142  }
2143 
2145 
2146  if (_this->MinimizeWindow) {
2147  _this->MinimizeWindow(_this, window);
2148  }
2149 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
static int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen)
Definition: SDL_video.c:1167
void(* MinimizeWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:226
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:123
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 2107 of file SDL_video.c.

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

Referenced by SDL_ShowMessageBox().

2108 {
2109  CHECK_WINDOW_MAGIC(window,);
2110 
2111  if (!(window->flags & SDL_WINDOW_SHOWN)) {
2112  return;
2113  }
2114  if (_this->RaiseWindow) {
2115  _this->RaiseWindow(_this, window);
2116  }
2117 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
void(* RaiseWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:224
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:123
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 2152 of file SDL_video.c.

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

2153 {
2154  CHECK_WINDOW_MAGIC(window,);
2155 
2156  if (!(window->flags & (SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED))) {
2157  return;
2158  }
2159 
2160  if (_this->RestoreWindow) {
2161  _this->RestoreWindow(_this, window);
2162  }
2163 }
void(* RestoreWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:227
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:123
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 1870 of file SDL_video.c.

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

1871 {
1872  CHECK_WINDOW_MAGIC(window,);
1873  if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
1874  const int want = (bordered != SDL_FALSE); /* normalize the flag. */
1875  const int have = ((window->flags & SDL_WINDOW_BORDERLESS) == 0);
1876  if ((want != have) && (_this->SetWindowBordered)) {
1877  if (want) {
1878  window->flags &= ~SDL_WINDOW_BORDERLESS;
1879  } else {
1880  window->flags |= SDL_WINDOW_BORDERLESS;
1881  }
1882  _this->SetWindowBordered(_this, window, (SDL_bool) want);
1883  }
1884  }
1885 }
void(* SetWindowBordered)(_THIS, SDL_Window *window, SDL_bool bordered)
Definition: SDL_sysvideo.h:228
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
SDL_bool
Definition: SDL_stdinc.h:139
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:123
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 2262 of file SDL_video.c.

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

2263 {
2264  Uint16 ramp[256];
2265  int status;
2266 
2267  CHECK_WINDOW_MAGIC(window, -1);
2268 
2269  SDL_CalculateGammaRamp(brightness, ramp);
2270  status = SDL_SetWindowGammaRamp(window, ramp, ramp, ramp);
2271  if (status == 0) {
2272  window->brightness = brightness;
2273  }
2274  return status;
2275 }
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:2348
float brightness
Definition: SDL_sysvideo.h:93
uint16_t Uint16
Definition: SDL_stdinc.h:169
#define SDL_CalculateGammaRamp
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:123

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

1716 {
1717  SDL_WindowUserData *prev, *data;
1718 
1719  CHECK_WINDOW_MAGIC(window, NULL);
1720 
1721  /* Input validation */
1722  if (name == NULL || name[0] == '\0') {
1723  SDL_InvalidParamError("name");
1724  return NULL;
1725  }
1726 
1727  /* See if the named data already exists */
1728  prev = NULL;
1729  for (data = window->data; data; prev = data, data = data->next) {
1730  if (data->name && SDL_strcmp(data->name, name) == 0) {
1731  void *last_value = data->data;
1732 
1733  if (userdata) {
1734  /* Set the new value */
1735  data->data = userdata;
1736  } else {
1737  /* Delete this value */
1738  if (prev) {
1739  prev->next = data->next;
1740  } else {
1741  window->data = data->next;
1742  }
1743  SDL_free(data->name);
1744  SDL_free(data);
1745  }
1746  return last_value;
1747  }
1748  }
1749 
1750  /* Add new data to the window */
1751  if (userdata) {
1752  data = (SDL_WindowUserData *)SDL_malloc(sizeof(*data));
1753  data->name = SDL_strdup(name);
1754  data->data = userdata;
1755  data->next = window->data;
1756  window->data = data;
1757  }
1758  return NULL;
1759 }
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:164
#define SDL_strdup
#define SDL_malloc
#define SDL_strcmp
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:123
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 1084 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.

1085 {
1086  CHECK_WINDOW_MAGIC(window, -1);
1087 
1088  if (mode) {
1089  window->fullscreen_mode = *mode;
1090  } else {
1091  SDL_zero(window->fullscreen_mode);
1092  }
1093 
1095  SDL_DisplayMode fullscreen_mode;
1096  if (SDL_GetWindowDisplayMode(window, &fullscreen_mode) == 0) {
1097  SDL_SetDisplayModeForDisplay(SDL_GetDisplayForWindow(window), &fullscreen_mode);
1098  }
1099  }
1100  return 0;
1101 }
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:1104
SDL_VideoDisplay * SDL_GetDisplayForWindow(SDL_Window *window)
Definition: SDL_video.c:1073
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:964
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:123
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 2166 of file SDL_video.c.

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

Referenced by SDL_FinishWindowCreation().

2167 {
2168  Uint32 oldflags;
2169  CHECK_WINDOW_MAGIC(window, -1);
2170 
2172 
2173  if (flags == (window->flags & FULLSCREEN_MASK)) {
2174  return 0;
2175  }
2176 
2177  /* clear the previous flags and OR in the new ones */
2178  oldflags = window->flags & FULLSCREEN_MASK;
2179  window->flags &= ~FULLSCREEN_MASK;
2180  window->flags |= flags;
2181 
2182  if (SDL_UpdateFullscreenMode(window, FULLSCREEN_VISIBLE(window)) == 0) {
2183  return 0;
2184  }
2185 
2186  window->flags &= ~FULLSCREEN_MASK;
2187  window->flags |= oldflags;
2188  return -1;
2189 }
#define FULLSCREEN_VISIBLE(W)
Definition: SDL_sysvideo.h:116
uint32_t Uint32
Definition: SDL_stdinc.h:181
static int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen)
Definition: SDL_video.c:1167
GLbitfield flags
#define FULLSCREEN_MASK
Definition: SDL_video.c:147
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:123
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 2348 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().

2351 {
2352  CHECK_WINDOW_MAGIC(window, -1);
2353 
2354  if (!_this->SetWindowGammaRamp) {
2355  return SDL_Unsupported();
2356  }
2357 
2358  if (!window->gamma) {
2359  if (SDL_GetWindowGammaRamp(window, NULL, NULL, NULL) < 0) {
2360  return -1;
2361  }
2362  SDL_assert(window->gamma != NULL);
2363  }
2364 
2365  if (red) {
2366  SDL_memcpy(&window->gamma[0*256], red, 256*sizeof(Uint16));
2367  }
2368  if (green) {
2369  SDL_memcpy(&window->gamma[1*256], green, 256*sizeof(Uint16));
2370  }
2371  if (blue) {
2372  SDL_memcpy(&window->gamma[2*256], blue, 256*sizeof(Uint16));
2373  }
2374  if (window->flags & SDL_WINDOW_INPUT_FOCUS) {
2375  return _this->SetWindowGammaRamp(_this, window, window->gamma);
2376  } else {
2377  return 0;
2378  }
2379 }
GLbyte green
const GLubyte GLuint red
Definition: SDL_glfuncs.h:79
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
#define SDL_memcpy
#define SDL_assert(condition)
Definition: SDL_assert.h:169
#define NULL
Definition: begin_code.h:164
GLbyte GLbyte blue
uint16_t Uint16
Definition: SDL_stdinc.h:169
int SDL_GetWindowGammaRamp(SDL_Window *window, Uint16 *red, Uint16 *green, Uint16 *blue)
Get the gamma ramp for a window.
Definition: SDL_video.c:2382
Uint16 * gamma
Definition: SDL_sysvideo.h:94
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:123
Uint32 flags
Definition: SDL_sysvideo.h:83
int(* SetWindowGammaRamp)(_THIS, SDL_Window *window, const Uint16 *ramp)
Definition: SDL_sysvideo.h:231
#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 2458 of file SDL_video.c.

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

Referenced by SDL_FinishWindowCreation().

2459 {
2460  CHECK_WINDOW_MAGIC(window,);
2461 
2462  if (!!grabbed == !!(window->flags & SDL_WINDOW_INPUT_GRABBED)) {
2463  return;
2464  }
2465  if (grabbed) {
2466  window->flags |= SDL_WINDOW_INPUT_GRABBED;
2467  } else {
2468  window->flags &= ~SDL_WINDOW_INPUT_GRABBED;
2469  }
2470  SDL_UpdateWindowGrab(window);
2471 }
void SDL_UpdateWindowGrab(SDL_Window *window)
Definition: SDL_video.c:2427
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:123
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 3894 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.

3895 {
3896  CHECK_WINDOW_MAGIC(window, -1);
3897 
3898  if (!_this->SetWindowHitTest) {
3899  return SDL_Unsupported();
3900  } else if (_this->SetWindowHitTest(window, callback != NULL) == -1) {
3901  return -1;
3902  }
3903 
3904  window->hit_test = callback;
3905  window->hit_test_data = userdata;
3906 
3907  return 0;
3908 }
int(* SetWindowHitTest)(SDL_Window *window, SDL_bool enabled)
Definition: SDL_sysvideo.h:305
void * hit_test_data
Definition: SDL_sysvideo.h:107
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
static Uint32 callback(Uint32 interval, void *param)
Definition: testtimer.c:34
#define NULL
Definition: begin_code.h:164
SDL_HitTest hit_test
Definition: SDL_sysvideo.h:106
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:123
#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 1693 of file SDL_video.c.

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

1694 {
1695  CHECK_WINDOW_MAGIC(window,);
1696 
1697  if (!icon) {
1698  return;
1699  }
1700 
1701  SDL_FreeSurface(window->icon);
1702 
1703  /* Convert the icon into ARGB8888 */
1705  if (!window->icon) {
1706  return;
1707  }
1708 
1709  if (_this->SetWindowIcon) {
1710  _this->SetWindowIcon(_this, window, window->icon);
1711  }
1712 }
#define SDL_ConvertSurfaceFormat
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
#define SDL_FreeSurface
void(* SetWindowIcon)(_THIS, SDL_Window *window, SDL_Surface *icon)
Definition: SDL_sysvideo.h:213
SDL_Surface * icon
Definition: SDL_sysvideo.h:78
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:123

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

References CHECK_WINDOW_MAGIC, SDL_Unsupported, and SDL_VideoDevice::SetWindowInputFocus.

2336 {
2337  CHECK_WINDOW_MAGIC(window, -1);
2338 
2339  if (!_this->SetWindowInputFocus) {
2340  return SDL_Unsupported();
2341  }
2342 
2343  return _this->SetWindowInputFocus(_this, window);
2344 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
int(* SetWindowInputFocus)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:221
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:123
#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 2031 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.

2032 {
2033  CHECK_WINDOW_MAGIC(window,);
2034  if (max_w <= 0) {
2035  SDL_InvalidParamError("max_w");
2036  return;
2037  }
2038  if (max_h <= 0) {
2039  SDL_InvalidParamError("max_h");
2040  return;
2041  }
2042 
2043  if (max_w <= window->min_w || max_h <= window->min_h) {
2044  SDL_SetError("SDL_SetWindowMaximumSize(): Tried to set maximum size smaller than minimum size");
2045  return;
2046  }
2047 
2048  window->max_w = max_w;
2049  window->max_h = max_h;
2050 
2051  if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
2052  if (_this->SetWindowMaximumSize) {
2053  _this->SetWindowMaximumSize(_this, window);
2054  }
2055  /* Ensure that window is not larger than maximal size */
2056  SDL_SetWindowSize(window, SDL_min(window->w, window->max_w), SDL_min(window->h, window->max_h));
2057  }
2058 }
#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:1906
#define SDL_InvalidParamError(param)
Definition: SDL_error.h:54
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
void(* SetWindowMaximumSize)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:217
#define SDL_SetError
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:123
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 1988 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.

1989 {
1990  CHECK_WINDOW_MAGIC(window,);
1991  if (min_w <= 0) {
1992  SDL_InvalidParamError("min_w");
1993  return;
1994  }
1995  if (min_h <= 0) {
1996  SDL_InvalidParamError("min_h");
1997  return;
1998  }
1999 
2000  if ((window->max_w && min_w >= window->max_w) ||
2001  (window->max_h && min_h >= window->max_h)) {
2002  SDL_SetError("SDL_SetWindowMinimumSize(): Tried to set minimum size larger than maximum size");
2003  return;
2004  }
2005 
2006  window->min_w = min_w;
2007  window->min_h = min_h;
2008 
2009  if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
2010  if (_this->SetWindowMinimumSize) {
2011  _this->SetWindowMinimumSize(_this, window);
2012  }
2013  /* Ensure that window is not smaller than minimal size */
2014  SDL_SetWindowSize(window, SDL_max(window->w, window->min_w), SDL_max(window->h, window->min_h));
2015  }
2016 }
void SDL_SetWindowSize(SDL_Window *window, int w, int h)
Set the size of a window&#39;s client area.
Definition: SDL_video.c:1906
#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:121
void(* SetWindowMinimumSize)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:216
#define SDL_SetError
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:123
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 2322 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, SDL_Unsupported, and SDL_VideoDevice::SetWindowModalFor.

2323 {
2324  CHECK_WINDOW_MAGIC(modal_window, -1);
2325  CHECK_WINDOW_MAGIC(parent_window, -1);
2326 
2327  if (!_this->SetWindowModalFor) {
2328  return SDL_Unsupported();
2329  }
2330 
2331  return _this->SetWindowModalFor(_this, modal_window, parent_window);
2332 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
int(* SetWindowModalFor)(_THIS, SDL_Window *modal_window, SDL_Window *parent_window)
Definition: SDL_sysvideo.h:220
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:123
#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 2286 of file SDL_video.c.

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

2287 {
2288  int retval;
2289  CHECK_WINDOW_MAGIC(window, -1);
2290 
2291  if (!_this->SetWindowOpacity) {
2292  return SDL_Unsupported();
2293  }
2294 
2295  if (opacity < 0.0f) {
2296  opacity = 0.0f;
2297  } else if (opacity > 1.0f) {
2298  opacity = 1.0f;
2299  }
2300 
2301  retval = _this->SetWindowOpacity(_this, window, opacity);
2302  if (retval == 0) {
2303  window->opacity = opacity;
2304  }
2305 
2306  return retval;
2307 }
GLfloat f
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
SDL_bool retval
float opacity
Definition: SDL_sysvideo.h:91
int(* SetWindowOpacity)(_THIS, SDL_Window *window, float opacity)
Definition: SDL_sysvideo.h:219
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:123
#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 1783 of file SDL_video.c.

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

1784 {
1785  CHECK_WINDOW_MAGIC(window,);
1786 
1788  int displayIndex = (x & 0xFFFF);
1789  SDL_Rect bounds;
1790  if (displayIndex >= _this->num_displays) {
1791  displayIndex = 0;
1792  }
1793 
1794  SDL_zero(bounds);
1795 
1796  SDL_GetDisplayBounds(displayIndex, &bounds);
1797  if (SDL_WINDOWPOS_ISCENTERED(x)) {
1798  x = bounds.x + (bounds.w - window->w) / 2;
1799  }
1800  if (SDL_WINDOWPOS_ISCENTERED(y)) {
1801  y = bounds.y + (bounds.h - window->h) / 2;
1802  }
1803  }
1804 
1805  if ((window->flags & SDL_WINDOW_FULLSCREEN)) {
1806  if (!SDL_WINDOWPOS_ISUNDEFINED(x)) {
1807  window->windowed.x = x;
1808  }
1809  if (!SDL_WINDOWPOS_ISUNDEFINED(y)) {
1810  window->windowed.y = y;
1811  }
1812  } else {
1813  if (!SDL_WINDOWPOS_ISUNDEFINED(x)) {
1814  window->x = x;
1815  }
1816  if (!SDL_WINDOWPOS_ISUNDEFINED(y)) {
1817  window->y = y;
1818  }
1819 
1820  if (_this->SetWindowPosition) {
1821  _this->SetWindowPosition(_this, window);
1822  }
1824  }
1825 }
#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
int SDL_SendWindowEvent(SDL_Window *window, Uint8 windowevent, int data1, int data2)
SDL_Rect windowed
Definition: SDL_sysvideo.h:87
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
#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:66
int SDL_GetDisplayBounds(int displayIndex, SDL_Rect *rect)
Get the desktop area represented by a display, with the primary display located at 0...
Definition: SDL_video.c:676
int w
Definition: SDL_rect.h:67
void(* SetWindowPosition)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:214
int h
Definition: SDL_rect.h:67
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:123
Uint32 flags
Definition: SDL_sysvideo.h:83
int y
Definition: SDL_rect.h:66
A rectangle, with the origin at the upper left.
Definition: SDL_rect.h:64

◆ SDL_SetWindowResizable()

void SDL_SetWindowResizable ( SDL_Window window,
SDL_bool  resizable 
)

Set the user-resizable state of a window.

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

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

Definition at line 1888 of file SDL_video.c.

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

1889 {
1890  CHECK_WINDOW_MAGIC(window,);
1891  if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
1892  const int want = (resizable != SDL_FALSE); /* normalize the flag. */
1893  const int have = ((window->flags & SDL_WINDOW_RESIZABLE) != 0);
1894  if ((want != have) && (_this->SetWindowResizable)) {
1895  if (want) {
1896  window->flags |= SDL_WINDOW_RESIZABLE;
1897  } else {
1898  window->flags &= ~SDL_WINDOW_RESIZABLE;
1899  }
1900  _this->SetWindowResizable(_this, window, (SDL_bool) want);
1901  }
1902  }
1903 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
SDL_bool
Definition: SDL_stdinc.h:139
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:123
void(* SetWindowResizable)(_THIS, SDL_Window *window, SDL_bool resizable)
Definition: SDL_sysvideo.h:229
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 1906 of file SDL_video.c.

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

Referenced by SDL_SetWindowMaximumSize(), and SDL_SetWindowMinimumSize().

1907 {
1908  CHECK_WINDOW_MAGIC(window,);
1909  if (w <= 0) {
1910  SDL_InvalidParamError("w");
1911  return;
1912  }
1913  if (h <= 0) {
1914  SDL_InvalidParamError("h");
1915  return;
1916  }
1917 
1918  /* Make sure we don't exceed any window size limits */
1919  if (window->min_w && w < window->min_w) {
1920  w = window->min_w;
1921  }
1922  if (window->max_w && w > window->max_w) {
1923  w = window->max_w;
1924  }
1925  if (window->min_h && h < window->min_h) {
1926  h = window->min_h;
1927  }
1928  if (window->max_h && h > window->max_h) {
1929  h = window->max_h;
1930  }
1931 
1932  window->windowed.w = w;
1933  window->windowed.h = h;
1934 
1935  if (window->flags & SDL_WINDOW_FULLSCREEN) {
1937  window->last_fullscreen_flags = 0;
1939  }
1940  } else {
1941  window->w = w;
1942  window->h = h;
1943  if (_this->SetWindowSize) {
1944  _this->SetWindowSize(_this, window);
1945  }
1946  if (window->w == w && window->h == h) {
1947  /* We didn't get a SDL_WINDOWEVENT_RESIZED event (by design) */
1948  SDL_OnWindowResized(window);
1949  }
1950  }
1951 }
#define FULLSCREEN_VISIBLE(W)
Definition: SDL_sysvideo.h:116
GLfloat GLfloat GLfloat GLfloat h
void(* SetWindowSize)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:215
#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:121
GLubyte GLubyte GLubyte GLubyte w
static int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen)
Definition: SDL_video.c:1167
int w
Definition: SDL_rect.h:67
Uint32 last_fullscreen_flags
Definition: SDL_sysvideo.h:84
int h
Definition: SDL_rect.h:67
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:123
Uint32 flags
Definition: SDL_sysvideo.h:83
void SDL_OnWindowResized(SDL_Window *window)
Definition: SDL_video.c:2501

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

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

Referenced by SDL_CreateWindow().

1669 {
1670  CHECK_WINDOW_MAGIC(window,);
1671 
1672  if (title == window->title) {
1673  return;
1674  }
1675  SDL_free(window->title);
1676 
1677  window->title = SDL_strdup(title ? title : "");
1678 
1679  if (_this->SetWindowTitle) {
1680  _this->SetWindowTitle(_this, window);
1681  }
1682 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
#define SDL_free
char * title
Definition: SDL_sysvideo.h:77
#define SDL_strdup
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:123
void(* SetWindowTitle)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:212

◆ SDL_ShowWindow()

void SDL_ShowWindow ( SDL_Window window)

Show a window.

See also
SDL_HideWindow()

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

2074 {
2075  CHECK_WINDOW_MAGIC(window,);
2076 
2077  if (window->flags & SDL_WINDOW_SHOWN) {
2078  return;
2079  }
2080 
2081  if (_this->ShowWindow) {
2082  _this->ShowWindow(_this, window);
2083  }
2085 }
void(* ShowWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:222
int SDL_SendWindowEvent(SDL_Window *window, Uint8 windowevent, int data1, int data2)
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:123
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 2235 of file SDL_video.c.

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

2236 {
2237  SDL_Rect full_rect;
2238 
2239  CHECK_WINDOW_MAGIC(window, -1);
2240 
2241  full_rect.x = 0;
2242  full_rect.y = 0;
2243  full_rect.w = window->w;
2244  full_rect.h = window->h;
2245  return SDL_UpdateWindowSurfaceRects(window, &full_rect, 1);
2246 }
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:2249
int x
Definition: SDL_rect.h:66
int w
Definition: SDL_rect.h:67
int h
Definition: SDL_rect.h:67
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:123
int y
Definition: SDL_rect.h:66
A rectangle, with the origin at the upper left.
Definition: SDL_rect.h:64

◆ SDL_UpdateWindowSurfaceRects()

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

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

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

Definition at line 2249 of file SDL_video.c.

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

Referenced by SDL_UpdateWindowSurface().

2251 {
2252  CHECK_WINDOW_MAGIC(window, -1);
2253 
2254  if (!window->surface_valid) {
2255  return SDL_SetError("Window surface is invalid, please call SDL_GetWindowSurface() to get a new surface");
2256  }
2257 
2258  return _this->UpdateWindowFramebuffer(_this, window, rects, numrects);
2259 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
#define SDL_SetError
int(* UpdateWindowFramebuffer)(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects)
Definition: SDL_sysvideo.h:236
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:123
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 464 of file SDL_video.c.

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

Referenced by SDL_CreateWindow().

465 {
466  SDL_VideoDevice *video;
467  int index;
468  int i;
469 
470  /* Check to make sure we don't overwrite '_this' */
471  if (_this != NULL) {
472  SDL_VideoQuit();
473  }
474 
475 #if !SDL_TIMERS_DISABLED
476  SDL_TicksInit();
477 #endif
478 
479  /* Start the event loop */
481  SDL_KeyboardInit() < 0 ||
482  SDL_MouseInit() < 0 ||
483  SDL_TouchInit() < 0) {
484  return -1;
485  }
486 
487  /* Select the proper video driver */
488  index = 0;
489  video = NULL;
490  if (driver_name == NULL) {
491  driver_name = SDL_getenv("SDL_VIDEODRIVER");
492  }
493  if (driver_name != NULL) {
494  for (i = 0; bootstrap[i]; ++i) {
495  if (SDL_strncasecmp(bootstrap[i]->name, driver_name, SDL_strlen(driver_name)) == 0) {
496  if (bootstrap[i]->available()) {
497  video = bootstrap[i]->create(index);
498  break;
499  }
500  }
501  }
502  } else {
503  for (i = 0; bootstrap[i]; ++i) {
504  if (bootstrap[i]->available()) {
505  video = bootstrap[i]->create(index);
506  if (video != NULL) {
507  break;
508  }
509  }
510  }
511  }
512  if (video == NULL) {
513  if (driver_name) {
514  return SDL_SetError("%s not available", driver_name);
515  }
516  return SDL_SetError("No available video device");
517  }
518  _this = video;
519  _this->name = bootstrap[i]->name;
520  _this->next_object_id = 1;
521 
522 
523  /* Set some very sane GL defaults */
527 
530 
531  /* Initialize the video subsystem */
532  if (_this->VideoInit(_this) < 0) {
533  SDL_VideoQuit();
534  return -1;
535  }
536 
537  /* Make sure some displays were added */
538  if (_this->num_displays == 0) {
539  SDL_VideoQuit();
540  return SDL_SetError("The video driver did not add any displays");
541  }
542 
543  /* Add the renderer framebuffer emulation if desired */
548  }
549 
550  /* Disable the screen saver by default. This is a change from <= 2.0.1,
551  but most things using SDL are games or media players; you wouldn't
552  want a screensaver to trigger if you're playing exclusively with a
553  joystick, or passively watching a movie. Things that use SDL but
554  function more like a normal desktop app should explicitly reenable the
555  screensaver. */
558  }
559 
560  /* If we don't use a screen keyboard, turn on text input by default,
561  otherwise programs that expect to get text events without enabling
562  UNICODE input won't get any events.
563 
564  Actually, come to think of it, you needed to call SDL_EnableUNICODE(1)
565  in SDL 1.2 before you got text input events. Hmm...
566  */
569  }
570 
571  /* We're ready to go! */
572  return 0;
573 }
void SDL_GL_ResetAttributes()
Reset all previously set OpenGL context attributes to their default values.
Definition: SDL_video.c:2967
const char * name
Definition: SDL_sysvideo.h:151
#define SDL_INIT_EVENTS
Definition: SDL.h:82
void SDL_VideoQuit(void)
Shuts down the video subsystem.
Definition: SDL_video.c:2726
SDL_TLSID current_glwin_tls
Definition: SDL_sysvideo.h:361
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:80
#define SDL_GetHintBoolean
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
static int SDL_UpdateWindowTexture(SDL_VideoDevice *unused, SDL_Window *window, const SDL_Rect *rects, int numrects)
Definition: SDL_video.c:369
#define SDL_TLSCreate
static int SDL_CreateWindowTexture(SDL_VideoDevice *unused, SDL_Window *window, Uint32 *format, void **pixels, int *pitch)
Definition: SDL_video.c:259
static void SDL_DestroyWindowTexture(SDL_VideoDevice *unused, SDL_Window *window)
Definition: SDL_video.c:399
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:3653
#define SDL_getenv
void(* DestroyWindowFramebuffer)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:237
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:164
#define SDL_SetError
static SDL_bool ShouldUseTextureFramebuffer()
Definition: SDL_video.c:169
#define SDL_strlen
SDL_TLSID current_glctx_tls
Definition: SDL_sysvideo.h:362
void SDL_TicksInit(void)
SDL_VideoDevice *(* create)(int devindex)
Definition: SDL_sysvideo.h:398
static VideoBootStrap * bootstrap[]
Definition: SDL_video.c:60
const char * name
Definition: SDL_sysvideo.h:395
int(* VideoInit)(_THIS)
Definition: SDL_sysvideo.h:160
int(* UpdateWindowFramebuffer)(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects)
Definition: SDL_sysvideo.h:236
struct SDL_VideoDevice::@34 gl_config
Uint32 next_object_id
Definition: SDL_sysvideo.h:316
SDL_bool SDL_HasScreenKeyboardSupport(void)
Returns whether the platform has some screen keyboard support.
Definition: SDL_video.c:3709
int(* CreateWindowFramebuffer)(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch)
Definition: SDL_sysvideo.h:235
int SDL_TouchInit(void)
Definition: SDL_touch.c:37
void SDL_DisableScreenSaver()
Prevent the screen from being blanked by a screensaver.
Definition: SDL_video.c:2711

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

2727 {
2728  int i, j;
2729 
2730  if (!_this) {
2731  return;
2732  }
2733 
2734  /* Halt event processing before doing anything else */
2735  SDL_TouchQuit();
2736  SDL_MouseQuit();
2737  SDL_KeyboardQuit();
2739 
2741 
2742  /* Clean up the system video */
2743  while (_this->windows) {
2745  }
2746  _this->VideoQuit(_this);
2747 
2748  for (i = 0; i < _this->num_displays; ++i) {
2749  SDL_VideoDisplay *display = &_this->displays[i];
2750  for (j = display->num_display_modes; j--;) {
2751  SDL_free(display->display_modes[j].driverdata);
2752  display->display_modes[j].driverdata = NULL;
2753  }
2754  SDL_free(display->display_modes);
2755  display->display_modes = NULL;
2756  SDL_free(display->desktop_mode.driverdata);
2757  display->desktop_mode.driverdata = NULL;
2758  SDL_free(display->driverdata);
2759  display->driverdata = NULL;
2760  }
2761  if (_this->displays) {
2762  for (i = 0; i < _this->num_displays; ++i) {
2763  SDL_free(_this->displays[i].name);
2764  }
2766  _this->displays = NULL;
2767  _this->num_displays = 0;
2768  }
2771  _this->free(_this);
2772  _this = NULL;
2773 }
#define SDL_INIT_EVENTS
Definition: SDL.h:82
void(* free)(_THIS)
Definition: SDL_sysvideo.h:390
#define SDL_QuitSubSystem
void SDL_MouseQuit(void)
Definition: SDL_mouse.c:566
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
#define SDL_free
void * driverdata
Definition: SDL_video.h:59
void SDL_DestroyWindow(SDL_Window *window)
Destroy a window.
Definition: SDL_video.c:2610
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:312
SDL_Window * windows
Definition: SDL_sysvideo.h:313
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:164
SDL_DisplayMode desktop_mode
Definition: SDL_sysvideo.h:131
void(* VideoQuit)(_THIS)
Definition: SDL_sysvideo.h:166
void SDL_EnableScreenSaver()
Allow the screen to be blanked by a screensaver.
Definition: SDL_video.c:2696
void SDL_TouchQuit(void)
Definition: SDL_touch.c:361
char * clipboard_text
Definition: SDL_sysvideo.h:317