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   0x1FFF0000
 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   0x2FFF0000
 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
}
 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
}
 Event subtype for window events. More...
 
enum  SDL_GLattr {
  SDL_GL_RED_SIZE,
  SDL_GL_GREEN_SIZE,
  SDL_GL_BLUE_SIZE,
  SDL_GL_ALPHA_SIZE,
  SDL_GL_BUFFER_SIZE,
  SDL_GL_DOUBLEBUFFER,
  SDL_GL_DEPTH_SIZE,
  SDL_GL_STENCIL_SIZE,
  SDL_GL_ACCUM_RED_SIZE,
  SDL_GL_ACCUM_GREEN_SIZE,
  SDL_GL_ACCUM_BLUE_SIZE,
  SDL_GL_ACCUM_ALPHA_SIZE,
  SDL_GL_STEREO,
  SDL_GL_MULTISAMPLEBUFFERS,
  SDL_GL_MULTISAMPLESAMPLES,
  SDL_GL_ACCELERATED_VISUAL,
  SDL_GL_RETAINED_BACKING,
  SDL_GL_CONTEXT_MAJOR_VERSION,
  SDL_GL_CONTEXT_MINOR_VERSION,
  SDL_GL_CONTEXT_EGL,
  SDL_GL_CONTEXT_FLAGS,
  SDL_GL_CONTEXT_PROFILE_MASK,
  SDL_GL_SHARE_WITH_CURRENT_CONTEXT,
  SDL_GL_FRAMEBUFFER_SRGB_CAPABLE,
  SDL_GL_CONTEXT_RELEASE_BEHAVIOR
}
 OpenGL configuration attributes. More...
 
enum  SDL_GLprofile {
  SDL_GL_CONTEXT_PROFILE_CORE = 0x0001,
  SDL_GL_CONTEXT_PROFILE_COMPATIBILITY = 0x0002,
  SDL_GL_CONTEXT_PROFILE_ES = 0x0004
}
 
enum  SDL_GLcontextFlag {
  SDL_GL_CONTEXT_DEBUG_FLAG = 0x0001,
  SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG = 0x0002,
  SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG = 0x0004,
  SDL_GL_CONTEXT_RESET_ISOLATION_FLAG = 0x0008
}
 
enum  SDL_GLcontextReleaseFlag {
  SDL_GL_CONTEXT_RELEASE_BEHAVIOR_NONE = 0x0000,
  SDL_GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH = 0x0001
}
 
enum  SDL_HitTestResult {
  SDL_HITTEST_NORMAL,
  SDL_HITTEST_DRAGGABLE,
  SDL_HITTEST_RESIZE_TOPLEFT,
  SDL_HITTEST_RESIZE_TOP,
  SDL_HITTEST_RESIZE_TOPRIGHT,
  SDL_HITTEST_RESIZE_RIGHT,
  SDL_HITTEST_RESIZE_BOTTOMRIGHT,
  SDL_HITTEST_RESIZE_BOTTOM,
  SDL_HITTEST_RESIZE_BOTTOMLEFT,
  SDL_HITTEST_RESIZE_LEFT
}
 Possible return values from the SDL_HitTest callback. More...
 

Functions

int SDL_GetNumVideoDrivers (void)
 Get the number of video drivers compiled into SDL. More...
 
const char * SDL_GetVideoDriver (int index)
 Get the name of a built in video driver. More...
 
int SDL_VideoInit (const char *driver_name)
 Initialize the video subsystem, optionally specifying a video driver. More...
 
void SDL_VideoQuit (void)
 Shuts down the video subsystem. More...
 
const char * SDL_GetCurrentVideoDriver (void)
 Returns the name of the currently initialized video driver. More...
 
int SDL_GetNumVideoDisplays (void)
 Returns the number of available video displays. More...
 
const char * SDL_GetDisplayName (int displayIndex)
 Get the name of a display in UTF-8 encoding. More...
 
int SDL_GetDisplayBounds (int displayIndex, SDL_Rect *rect)
 Get the desktop area represented by a display, with the primary display located at 0,0. More...
 
int SDL_GetDisplayDPI (int displayIndex, float *ddpi, float *hdpi, float *vdpi)
 Get the dots/pixels-per-inch for a display. More...
 
int SDL_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...
 
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_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_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 on). 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

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

Definition at line 128 of file SDL_video.h.

Referenced by SDLTest_CommonArg().

#define SDL_WINDOWPOS_CENTERED_MASK   0x2FFF0000

Used to indicate that the window position should be centered.

Definition at line 127 of file SDL_video.h.

#define SDL_WINDOWPOS_ISCENTERED (   X)    (((X)&0xFFFF0000) == SDL_WINDOWPOS_CENTERED_MASK)
#define SDL_WINDOWPOS_ISUNDEFINED (   X)    (((X)&0xFFFF0000) == SDL_WINDOWPOS_UNDEFINED_MASK)
#define SDL_WINDOWPOS_UNDEFINED   SDL_WINDOWPOS_UNDEFINED_DISPLAY(0)
#define SDL_WINDOWPOS_UNDEFINED_DISPLAY (   X)    (SDL_WINDOWPOS_UNDEFINED_MASK|(X))

Definition at line 119 of file SDL_video.h.

Referenced by SDLTest_CommonArg().

#define SDL_WINDOWPOS_UNDEFINED_MASK   0x1FFF0000

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

Definition at line 118 of file SDL_video.h.

Typedef Documentation

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

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

Enumeration Type Documentation

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

OpenGL configuration attributes.

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

Definition at line 169 of file SDL_video.h.

170 {
196 } SDL_GLattr;
SDL_GLattr
OpenGL configuration attributes.
Definition: SDL_video.h:169
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 205 of file SDL_video.h.

Enumerator
SDL_GL_CONTEXT_RELEASE_BEHAVIOR_NONE 
SDL_GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH 

Definition at line 213 of file SDL_video.h.

Enumerator
SDL_GL_CONTEXT_PROFILE_CORE 
SDL_GL_CONTEXT_PROFILE_COMPATIBILITY 
SDL_GL_CONTEXT_PROFILE_ES 

Definition at line 198 of file SDL_video.h.

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

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

Definition at line 136 of file SDL_video.h.

137 {
138  SDL_WINDOWEVENT_NONE, /**< Never used */
139  SDL_WINDOWEVENT_SHOWN, /**< Window has been shown */
140  SDL_WINDOWEVENT_HIDDEN, /**< Window has been hidden */
141  SDL_WINDOWEVENT_EXPOSED, /**< Window has been exposed and should be
142  redrawn */
143  SDL_WINDOWEVENT_MOVED, /**< Window has been moved to data1, data2
144  */
145  SDL_WINDOWEVENT_RESIZED, /**< Window has been resized to data1xdata2 */
146  SDL_WINDOWEVENT_SIZE_CHANGED, /**< The window size has changed, either as
147  a result of an API call or through the
148  system or user changing the window size. */
149  SDL_WINDOWEVENT_MINIMIZED, /**< Window has been minimized */
150  SDL_WINDOWEVENT_MAXIMIZED, /**< Window has been maximized */
151  SDL_WINDOWEVENT_RESTORED, /**< Window has been restored to normal size
152  and position */
153  SDL_WINDOWEVENT_ENTER, /**< Window has gained mouse focus */
154  SDL_WINDOWEVENT_LEAVE, /**< Window has lost mouse focus */
155  SDL_WINDOWEVENT_FOCUS_GAINED, /**< Window has gained keyboard focus */
156  SDL_WINDOWEVENT_FOCUS_LOST, /**< Window has lost keyboard focus */
157  SDL_WINDOWEVENT_CLOSE /**< The window manager requests that the
158  window be closed */
SDL_WindowEventID
Event subtype for window events.
Definition: SDL_video.h:136

The flags on a window.

See also
SDL_GetWindowFlags()
Enumerator
SDL_WINDOW_FULLSCREEN 

fullscreen window

SDL_WINDOW_OPENGL 

window usable with OpenGL context

SDL_WINDOW_SHOWN 

window is visible

SDL_WINDOW_HIDDEN 

window is not visible

SDL_WINDOW_BORDERLESS 

no window decoration

SDL_WINDOW_RESIZABLE 

window can be resized

SDL_WINDOW_MINIMIZED 

window is minimized

SDL_WINDOW_MAXIMIZED 

window is maximized

SDL_WINDOW_INPUT_GRABBED 

window has grabbed input focus

SDL_WINDOW_INPUT_FOCUS 

window has input focus

SDL_WINDOW_MOUSE_FOCUS 

window has mouse focus

SDL_WINDOW_FULLSCREEN_DESKTOP 
SDL_WINDOW_FOREIGN 

window not created by SDL

SDL_WINDOW_ALLOW_HIGHDPI 

window should be created in high-DPI mode if supported

SDL_WINDOW_MOUSE_CAPTURE 

window has mouse captured (unrelated to INPUT_GRABBED)

Definition at line 96 of file SDL_video.h.

97 {
98  SDL_WINDOW_FULLSCREEN = 0x00000001, /**< fullscreen window */
99  SDL_WINDOW_OPENGL = 0x00000002, /**< window usable with OpenGL context */
100  SDL_WINDOW_SHOWN = 0x00000004, /**< window is visible */
101  SDL_WINDOW_HIDDEN = 0x00000008, /**< window is not visible */
102  SDL_WINDOW_BORDERLESS = 0x00000010, /**< no window decoration */
103  SDL_WINDOW_RESIZABLE = 0x00000020, /**< window can be resized */
104  SDL_WINDOW_MINIMIZED = 0x00000040, /**< window is minimized */
105  SDL_WINDOW_MAXIMIZED = 0x00000080, /**< window is maximized */
106  SDL_WINDOW_INPUT_GRABBED = 0x00000100, /**< window has grabbed input focus */
107  SDL_WINDOW_INPUT_FOCUS = 0x00000200, /**< window has input focus */
108  SDL_WINDOW_MOUSE_FOCUS = 0x00000400, /**< window has mouse focus */
110  SDL_WINDOW_FOREIGN = 0x00000800, /**< window not created by SDL */
111  SDL_WINDOW_ALLOW_HIGHDPI = 0x00002000, /**< window should be created in high-DPI mode if supported */
112  SDL_WINDOW_MOUSE_CAPTURE = 0x00004000 /**< window has mouse captured (unrelated to INPUT_GRABBED) */
SDL_WindowFlags
The flags on a window.
Definition: SDL_video.h:96

Function Documentation

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

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

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

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

See also
SDL_DestroyWindow()

Definition at line 1316 of file SDL_video.c.

References SDL_Window::brightness, CREATE_FLAGS, SDL_VideoDevice::CreateWindow, SDL_Window::flags, FULLSCREEN_VISIBLE, SDL_VideoDevice::GL_CreateContext, SDL_Rect::h, SDL_Window::h, SDL_Window::id, SDL_Window::is_destroying, SDL_Window::last_fullscreen_flags, SDL_Window::magic, SDL_Window::next, SDL_VideoDevice::next_object_id, NULL, SDL_Window::prev, SDL_atoi, SDL_calloc(), SDL_DestroyWindow(), SDL_FALSE, SDL_FinishWindowCreation(), SDL_GetDisplayBounds(), SDL_GetDisplayForWindow(), SDL_GetHint, SDL_GetIndexOfDisplay(), SDL_GL_LoadLibrary(), SDL_HINT_VIDEO_HIGHDPI_DISABLED, SDL_OutOfMemory, SDL_SetError, SDL_SetWindowTitle(), SDL_UpdateFullscreenMode(), SDL_VideoInit(), SDL_WINDOW_ALLOW_HIGHDPI, SDL_WINDOW_HIDDEN, SDL_WINDOW_OPENGL, SDL_WINDOWPOS_ISCENTERED, SDL_WINDOWPOS_ISUNDEFINED, SDL_Rect::w, SDL_Window::w, window, SDL_VideoDevice::window_magic, SDL_VideoDevice::windows, SDL_Rect::x, SDL_Window::x, SDL_Rect::y, and SDL_Window::y.

Referenced by ShouldUseTextureFramebuffer().

1317 {
1318  SDL_Window *window;
1319  const char *hint;
1320 
1321  if (!_this) {
1322  /* Initialize the video system if needed */
1323  if (SDL_VideoInit(NULL) < 0) {
1324  return NULL;
1325  }
1326  }
1327 
1328  /* Some platforms can't create zero-sized windows */
1329  if (w < 1) {
1330  w = 1;
1331  }
1332  if (h < 1) {
1333  h = 1;
1334  }
1335 
1336  /* Some platforms blow up if the windows are too large. Raise it later? */
1337  if ((w > 16384) || (h > 16384)) {
1338  SDL_SetError("Window is too large.");
1339  return NULL;
1340  }
1341 
1342  /* Some platforms have OpenGL enabled by default */
1343 #if (SDL_VIDEO_OPENGL && __MACOSX__) || __IPHONEOS__ || __ANDROID__ || __NACL__
1345 #endif
1346  if (flags & SDL_WINDOW_OPENGL) {
1347  if (!_this->GL_CreateContext) {
1348  SDL_SetError("No OpenGL support in video driver");
1349  return NULL;
1350  }
1351  if (SDL_GL_LoadLibrary(NULL) < 0) {
1352  return NULL;
1353  }
1354  }
1355 
1356  /* Unless the user has specified the high-DPI disabling hint, respect the
1357  * SDL_WINDOW_ALLOW_HIGHDPI flag.
1358  */
1361  if (hint && SDL_atoi(hint) > 0) {
1362  flags &= ~SDL_WINDOW_ALLOW_HIGHDPI;
1363  }
1364  }
1365 
1366  window = (SDL_Window *)SDL_calloc(1, sizeof(*window));
1367  if (!window) {
1368  SDL_OutOfMemory();
1369  return NULL;
1370  }
1371  window->magic = &_this->window_magic;
1372  window->id = _this->next_object_id++;
1373  window->x = x;
1374  window->y = y;
1375  window->w = w;
1376  window->h = h;
1379  SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
1380  int displayIndex;
1381  SDL_Rect bounds;
1382 
1383  displayIndex = SDL_GetIndexOfDisplay(display);
1384  SDL_GetDisplayBounds(displayIndex, &bounds);
1386  window->x = bounds.x + (bounds.w - w) / 2;
1387  }
1389  window->y = bounds.y + (bounds.h - h) / 2;
1390  }
1391  }
1392  window->flags = ((flags & CREATE_FLAGS) | SDL_WINDOW_HIDDEN);
1393  window->last_fullscreen_flags = window->flags;
1394  window->brightness = 1.0f;
1395  window->next = _this->windows;
1396  window->is_destroying = SDL_FALSE;
1397 
1398  if (_this->windows) {
1399  _this->windows->prev = window;
1400  }
1401  _this->windows = window;
1402 
1403  if (_this->CreateWindow && _this->CreateWindow(_this, window) < 0) {
1404  SDL_DestroyWindow(window);
1405  return NULL;
1406  }
1407 
1408 #if __WINRT__ && (NTDDI_VERSION < NTDDI_WIN10)
1409  /* HACK: WinRT 8.x apps can't choose whether or not they are fullscreen
1410  or not. The user can choose this, via OS-provided UI, but this can't
1411  be set programmatically.
1412 
1413  Just look at what SDL's WinRT video backend code detected with regards
1414  to fullscreen (being active, or not), and figure out a return/error code
1415  from that.
1416  */
1417  flags = window->flags;
1418 #endif
1419 
1420  if (title) {
1421  SDL_SetWindowTitle(window, title);
1422  }
1424 
1425  /* If the window was created fullscreen, make sure the mode code matches */
1427 
1428  return window;
1429 }
#define SDL_WINDOWPOS_ISUNDEFINED(X)
Definition: SDL_video.h:121
SDL_Window * next
Definition: SDL_sysvideo.h:109
#define FULLSCREEN_VISIBLE(W)
Definition: SDL_sysvideo.h:111
const void * magic
Definition: SDL_sysvideo.h:73
SDL_Window * window
#define SDL_HINT_VIDEO_HIGHDPI_DISABLED
If set to 1, then do not allow high-DPI windows. ("Retina" on Mac and iOS)
Definition: SDL_hints.h:379
int SDL_GL_LoadLibrary(const char *path)
Dynamically load an OpenGL library.
Definition: SDL_video.c:2582
void SDL_SetWindowTitle(SDL_Window *window, const char *title)
Set the title of a window, in UTF-8 format.
Definition: SDL_video.c:1579
#define SDL_GetHint
#define SDL_WINDOWPOS_ISCENTERED(X)
Definition: SDL_video.h:130
SDL_bool is_destroying
Definition: SDL_sysvideo.h:97
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
#define CREATE_FLAGS
Definition: SDL_video.c:1287
void * SDL_calloc(size_t nmemb, size_t size)
SDL_VideoDisplay * SDL_GetDisplayForWindow(SDL_Window *window)
Definition: SDL_video.c:1039
SDL_GLContext(* GL_CreateContext)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:237
void SDL_DestroyWindow(SDL_Window *window)
Destroy a window.
Definition: SDL_video.c:2419
int x
Definition: SDL_rect.h:66
static int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen)
Definition: SDL_video.c:1133
SDL_Window * windows
Definition: SDL_sysvideo.h:281
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:663
int w
Definition: SDL_rect.h:67
#define SDL_atoi
float brightness
Definition: SDL_sysvideo.h:89
#define NULL
Definition: begin_code.h:143
#define SDL_OutOfMemory()
Definition: SDL_error.h:52
Uint32 last_fullscreen_flags
Definition: SDL_sysvideo.h:82
#define SDL_SetError
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1567
SDL_Window * prev
Definition: SDL_sysvideo.h:108
int SDL_VideoInit(const char *driver_name)
Initialize the video subsystem, optionally specifying a video driver.
Definition: SDL_video.c:443
int h
Definition: SDL_rect.h:67
int(* CreateWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:195
The type used to identify a window.
Definition: SDL_sysvideo.h:71
static void SDL_FinishWindowCreation(SDL_Window *window, Uint32 flags)
Definition: SDL_video.c:1291
Uint32 id
Definition: SDL_sysvideo.h:74
GLbitfield flags
GLubyte GLubyte GLubyte GLubyte w
static int SDL_GetIndexOfDisplay(SDL_VideoDisplay *display)
Definition: SDL_video.c:632
Uint32 flags
Definition: SDL_sysvideo.h:81
Uint32 next_object_id
Definition: SDL_sysvideo.h:284
int y
Definition: SDL_rect.h:66
GLfloat GLfloat GLfloat GLfloat h
A rectangle, with the origin at the upper left.
Definition: SDL_rect.h:64
SDL_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 id of the window created, or zero if window creation failed.
See also
SDL_DestroyWindow()

Definition at line 1432 of file SDL_video.c.

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

1433 {
1434  SDL_Window *window;
1435 
1436  if (!_this) {
1438  return NULL;
1439  }
1440  if (!_this->CreateWindowFrom) {
1441  SDL_Unsupported();
1442  return NULL;
1443  }
1444  window = (SDL_Window *)SDL_calloc(1, sizeof(*window));
1445  if (!window) {
1446  SDL_OutOfMemory();
1447  return NULL;
1448  }
1449  window->magic = &_this->window_magic;
1450  window->id = _this->next_object_id++;
1451  window->flags = SDL_WINDOW_FOREIGN;
1452  window->last_fullscreen_flags = window->flags;
1453  window->is_destroying = SDL_FALSE;
1454  window->brightness = 1.0f;
1455  window->next = _this->windows;
1456  if (_this->windows) {
1457  _this->windows->prev = window;
1458  }
1459  _this->windows = window;
1460 
1461  if (_this->CreateWindowFrom(_this, window, data) < 0) {
1462  SDL_DestroyWindow(window);
1463  return NULL;
1464  }
1465  return window;
1466 }
SDL_Window * next
Definition: SDL_sysvideo.h:109
const void * magic
Definition: SDL_sysvideo.h:73
int(* CreateWindowFrom)(_THIS, SDL_Window *window, const void *data)
Definition: SDL_sysvideo.h:196
SDL_Window * window
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: SDL_opengl.h:1967
SDL_bool is_destroying
Definition: SDL_sysvideo.h:97
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
void * SDL_calloc(size_t nmemb, size_t size)
void SDL_DestroyWindow(SDL_Window *window)
Destroy a window.
Definition: SDL_video.c:2419
SDL_Window * windows
Definition: SDL_sysvideo.h:281
float brightness
Definition: SDL_sysvideo.h:89
#define NULL
Definition: begin_code.h:143
#define SDL_OutOfMemory()
Definition: SDL_error.h:52
Uint32 last_fullscreen_flags
Definition: SDL_sysvideo.h:82
SDL_Window * prev
Definition: SDL_sysvideo.h:108
The type used to identify a window.
Definition: SDL_sysvideo.h:71
Uint32 id
Definition: SDL_sysvideo.h:74
static int SDL_UninitializedVideo()
Definition: SDL_video.c:419
Uint32 flags
Definition: SDL_sysvideo.h:81
Uint32 next_object_id
Definition: SDL_sysvideo.h:284
#define SDL_Unsupported()
Definition: SDL_error.h:53
void SDL_DestroyWindow ( SDL_Window window)

Destroy a window.

Definition at line 2419 of file SDL_video.c.

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

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

2420 {
2421  SDL_VideoDisplay *display;
2422 
2423  CHECK_WINDOW_MAGIC(window,);
2424 
2425  window->is_destroying = SDL_TRUE;
2426 
2427  /* Restore video mode, etc. */
2428  SDL_HideWindow(window);
2429 
2430  /* Make sure this window no longer has focus */
2431  if (SDL_GetKeyboardFocus() == window) {
2433  }
2434  if (SDL_GetMouseFocus() == window) {
2436  }
2437 
2438  /* make no context current if this is the current context window. */
2439  if (window->flags & SDL_WINDOW_OPENGL) {
2440  if (_this->current_glwin == window) {
2441  SDL_GL_MakeCurrent(window, NULL);
2442  }
2443  }
2444 
2445  if (window->surface) {
2446  window->surface->flags &= ~SDL_DONTFREE;
2447  SDL_FreeSurface(window->surface);
2448  }
2451  }
2452  if (_this->DestroyWindow) {
2453  _this->DestroyWindow(_this, window);
2454  }
2455  if (window->flags & SDL_WINDOW_OPENGL) {
2457  }
2458 
2459  display = SDL_GetDisplayForWindow(window);
2460  if (display->fullscreen_window == window) {
2461  display->fullscreen_window = NULL;
2462  }
2463 
2464  /* Now invalidate magic */
2465  window->magic = NULL;
2466 
2467  /* Free memory associated with the window */
2468  SDL_free(window->title);
2469  SDL_FreeSurface(window->icon);
2470  SDL_free(window->gamma);
2471  while (window->data) {
2472  SDL_WindowUserData *data = window->data;
2473 
2474  window->data = data->next;
2475  SDL_free(data->name);
2476  SDL_free(data);
2477  }
2478 
2479  /* Unlink the window from the list */
2480  if (window->next) {
2481  window->next->prev = window->prev;
2482  }
2483  if (window->prev) {
2484  window->prev->next = window->next;
2485  } else {
2486  _this->windows = window->next;
2487  }
2488 
2489  SDL_free(window);
2490 }
SDL_Window * next
Definition: SDL_sysvideo.h:109
void SDL_SetKeyboardFocus(SDL_Window *window)
Definition: SDL_keyboard.c:612
const void * magic
Definition: SDL_sysvideo.h:73
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: SDL_opengl.h:1967
#define SDL_DONTFREE
Definition: SDL_surface.h:55
SDL_bool is_destroying
Definition: SDL_sysvideo.h:97
void SDL_SetMouseFocus(SDL_Window *window)
Definition: SDL_mouse.c:103
void SDL_HideWindow(SDL_Window *window)
Hide a window.
Definition: SDL_video.c:1950
#define SDL_GetKeyboardFocus
Uint32 flags
Definition: SDL_surface.h:71
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
struct SDL_WindowUserData * next
Definition: SDL_sysvideo.h:67
SDL_VideoDisplay * SDL_GetDisplayForWindow(SDL_Window *window)
Definition: SDL_video.c:1039
#define SDL_FreeSurface
void SDL_free(void *mem)
int SDL_GL_MakeCurrent(SDL_Window *window, SDL_GLContext ctx)
Set up an OpenGL context for rendering into an OpenGL window.
Definition: SDL_video.c:3158
void SDL_GL_UnloadLibrary(void)
Unload the OpenGL library previously loaded by SDL_GL_LoadLibrary().
Definition: SDL_video.c:2633
void(* DestroyWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:214
char * title
Definition: SDL_sysvideo.h:75
SDL_Window * windows
Definition: SDL_sysvideo.h:281
SDL_Window * fullscreen_window
Definition: SDL_sysvideo.h:129
void(* DestroyWindowFramebuffer)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:217
#define NULL
Definition: begin_code.h:143
#define SDL_GetMouseFocus
SDL_Surface * icon
Definition: SDL_sysvideo.h:76
SDL_Window * prev
Definition: SDL_sysvideo.h:108
Uint16 * gamma
Definition: SDL_sysvideo.h:90
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:116
Uint32 flags
Definition: SDL_sysvideo.h:81
SDL_Surface * surface
Definition: SDL_sysvideo.h:93
SDL_Window * current_glwin
Definition: SDL_sysvideo.h:325
SDL_WindowUserData * data
Definition: SDL_sysvideo.h:104
void SDL_DisableScreenSaver ( void  )

Prevent the screen from being blanked by a screensaver.

See also
SDL_IsScreenSaverEnabled()
SDL_EnableScreenSaver()

Definition at line 2517 of file SDL_video.c.

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

Referenced by SDL_VideoInit().

2518 {
2519  if (!_this) {
2520  return;
2521  }
2522  if (_this->suspend_screensaver) {
2523  return;
2524  }
2526  if (_this->SuspendScreenSaver) {
2528  }
2529 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
SDL_bool suspend_screensaver
Definition: SDL_sysvideo.h:278
void(* SuspendScreenSaver)(_THIS)
Definition: SDL_sysvideo.h:252
void SDL_EnableScreenSaver ( void  )

Allow the screen to be blanked by a screensaver.

See also
SDL_IsScreenSaverEnabled()
SDL_DisableScreenSaver()

Definition at line 2502 of file SDL_video.c.

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

Referenced by SDL_VideoQuit().

2503 {
2504  if (!_this) {
2505  return;
2506  }
2507  if (!_this->suspend_screensaver) {
2508  return;
2509  }
2511  if (_this->SuspendScreenSaver) {
2513  }
2514 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
SDL_bool suspend_screensaver
Definition: SDL_sysvideo.h:278
void(* SuspendScreenSaver)(_THIS)
Definition: SDL_sysvideo.h:252
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 917 of file SDL_video.c.

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

920 {
921  SDL_VideoDisplay *display;
922 
923  CHECK_DISPLAY_INDEX(displayIndex, NULL);
924 
925  display = &_this->displays[displayIndex];
926  return SDL_GetClosestDisplayModeForDisplay(display, mode, closest);
927 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
SDL_VideoDisplay * displays
Definition: SDL_sysvideo.h:280
#define NULL
Definition: begin_code.h:143
static SDL_DisplayMode * SDL_GetClosestDisplayModeForDisplay(SDL_VideoDisplay *display, const SDL_DisplayMode *mode, SDL_DisplayMode *closest)
Definition: SDL_video.c:810
#define CHECK_DISPLAY_INDEX(displayIndex, retval)
Definition: SDL_video.c:126
int SDL_GetCurrentDisplayMode ( int  displayIndex,
SDL_DisplayMode mode 
)

Fill in information about the current display mode.

Definition at line 796 of file SDL_video.c.

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

797 {
798  SDL_VideoDisplay *display;
799 
800  CHECK_DISPLAY_INDEX(displayIndex, -1);
801 
802  display = &_this->displays[displayIndex];
803  if (mode) {
804  *mode = display->current_mode;
805  }
806  return 0;
807 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
SDL_DisplayMode current_mode
Definition: SDL_sysvideo.h:127
SDL_VideoDisplay * displays
Definition: SDL_sysvideo.h:280
#define CHECK_DISPLAY_INDEX(displayIndex, retval)
Definition: SDL_video.c:126
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 563 of file SDL_video.c.

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

564 {
565  if (!_this) {
567  return NULL;
568  }
569  return _this->name;
570 }
const char * name
Definition: SDL_sysvideo.h:146
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
#define NULL
Definition: begin_code.h:143
static int SDL_UninitializedVideo()
Definition: SDL_video.c:419
int SDL_GetDesktopDisplayMode ( int  displayIndex,
SDL_DisplayMode mode 
)

Fill in information about the desktop display mode.

Definition at line 782 of file SDL_video.c.

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

783 {
784  SDL_VideoDisplay *display;
785 
786  CHECK_DISPLAY_INDEX(displayIndex, -1);
787 
788  display = &_this->displays[displayIndex];
789  if (mode) {
790  *mode = display->desktop_mode;
791  }
792  return 0;
793 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
SDL_VideoDisplay * displays
Definition: SDL_sysvideo.h:280
SDL_DisplayMode desktop_mode
Definition: SDL_sysvideo.h:126
#define CHECK_DISPLAY_INDEX(displayIndex, retval)
Definition: SDL_video.c:126
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 663 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_GetWindowDisplayIndex(), SDL_GetWindowPosition(), and SDL_SetWindowPosition().

664 {
665  CHECK_DISPLAY_INDEX(displayIndex, -1);
666 
667  if (rect) {
668  SDL_VideoDisplay *display = &_this->displays[displayIndex];
669 
670  if (_this->GetDisplayBounds) {
671  if (_this->GetDisplayBounds(_this, display, rect) == 0) {
672  return 0;
673  }
674  }
675 
676  /* Assume that the displays are left to right */
677  if (displayIndex == 0) {
678  rect->x = 0;
679  rect->y = 0;
680  } else {
681  SDL_GetDisplayBounds(displayIndex-1, rect);
682  rect->x += rect->w;
683  }
684  rect->w = display->current_mode.w;
685  rect->h = display->current_mode.h;
686  }
687  return 0;
688 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
SDL_DisplayMode current_mode
Definition: SDL_sysvideo.h:127
SDL_VideoDisplay * displays
Definition: SDL_sysvideo.h:280
int(* GetDisplayBounds)(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect)
Definition: SDL_sysvideo.h:171
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:663
int w
Definition: SDL_rect.h:67
int h
Definition: SDL_rect.h:67
#define CHECK_DISPLAY_INDEX(displayIndex, retval)
Definition: SDL_video.c:126
int y
Definition: SDL_rect.h:66
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 691 of file SDL_video.c.

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

692 {
693  SDL_VideoDisplay *display;
694 
695  CHECK_DISPLAY_INDEX(displayIndex, -1);
696 
697  display = &_this->displays[displayIndex];
698 
699  if (_this->GetDisplayDPI) {
700  if (_this->GetDisplayDPI(_this, display, ddpi, hdpi, vdpi) == 0) {
701  return 0;
702  }
703  }
704 
705  return -1;
706 }
int(* GetDisplayDPI)(_THIS, SDL_VideoDisplay *display, float *ddpi, float *hdpi, float *vdpi)
Definition: SDL_sysvideo.h:176
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
SDL_VideoDisplay * displays
Definition: SDL_sysvideo.h:280
#define CHECK_DISPLAY_INDEX(displayIndex, retval)
Definition: SDL_video.c:126
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 764 of file SDL_video.c.

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

765 {
766  SDL_VideoDisplay *display;
767 
768  CHECK_DISPLAY_INDEX(displayIndex, -1);
769 
770  display = &_this->displays[displayIndex];
772  return SDL_SetError("index must be in the range of 0 - %d",
773  SDL_GetNumDisplayModesForDisplay(display) - 1);
774  }
775  if (mode) {
776  *mode = display->display_modes[index];
777  }
778  return 0;
779 }
static int SDL_GetNumDisplayModesForDisplay(SDL_VideoDisplay *display)
Definition: SDL_video.c:745
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
SDL_DisplayMode * display_modes
Definition: SDL_sysvideo.h:125
SDL_VideoDisplay * displays
Definition: SDL_sysvideo.h:280
GLuint index
#define SDL_SetError
#define CHECK_DISPLAY_INDEX(displayIndex, retval)
Definition: SDL_video.c:126
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 655 of file SDL_video.c.

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

656 {
657  CHECK_DISPLAY_INDEX(displayIndex, NULL);
658 
659  return _this->displays[displayIndex].name;
660 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
SDL_VideoDisplay * displays
Definition: SDL_sysvideo.h:280
#define NULL
Definition: begin_code.h:143
#define CHECK_DISPLAY_INDEX(displayIndex, retval)
Definition: SDL_video.c:126
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 2282 of file SDL_video.c.

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

2283 {
2285  return _this->grabbed_window;
2286 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
#define SDL_assert(condition)
Definition: SDL_assert.h:167
SDL_Window * grabbed_window
Definition: SDL_sysvideo.h:282
Uint32 flags
Definition: SDL_sysvideo.h:81
int SDL_GetNumDisplayModes ( int  displayIndex)

Returns the number of available display modes.

See also
SDL_GetDisplayMode()

Definition at line 756 of file SDL_video.c.

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

757 {
758  CHECK_DISPLAY_INDEX(displayIndex, -1);
759 
760  return SDL_GetNumDisplayModesForDisplay(&_this->displays[displayIndex]);
761 }
static int SDL_GetNumDisplayModesForDisplay(SDL_VideoDisplay *display)
Definition: SDL_video.c:745
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
SDL_VideoDisplay * displays
Definition: SDL_sysvideo.h:280
#define CHECK_DISPLAY_INDEX(displayIndex, retval)
Definition: SDL_video.c:126
int SDL_GetNumVideoDisplays ( void  )

Returns the number of available video displays.

See also
SDL_GetDisplayBounds()

Definition at line 622 of file SDL_video.c.

References SDL_VideoDevice::num_displays, and SDL_UninitializedVideo().

623 {
624  if (!_this) {
626  return 0;
627  }
628  return _this->num_displays;
629 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
static int SDL_UninitializedVideo()
Definition: SDL_video.c:419
int SDL_GetNumVideoDrivers ( void  )

Get the number of video drivers compiled into SDL.

See also
SDL_GetVideoDriver()

Definition at line 425 of file SDL_video.c.

References SDL_arraysize.

Referenced by SDL_GetVideoDriver().

426 {
427  return SDL_arraysize(bootstrap) - 1;
428 }
static VideoBootStrap * bootstrap[]
Definition: SDL_video.c:59
#define SDL_arraysize(array)
Definition: SDL_stdinc.h:93
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 431 of file SDL_video.c.

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

432 {
433  if (index >= 0 && index < SDL_GetNumVideoDrivers()) {
434  return bootstrap[index]->name;
435  }
436  return NULL;
437 }
int SDL_GetNumVideoDrivers(void)
Get the number of video drivers compiled into SDL.
Definition: SDL_video.c:425
GLuint index
#define NULL
Definition: begin_code.h:143
static VideoBootStrap * bootstrap[]
Definition: SDL_video.c:59
const char * name
Definition: SDL_sysvideo.h:350
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 2140 of file SDL_video.c.

References SDL_Window::brightness, and CHECK_WINDOW_MAGIC.

2141 {
2142  CHECK_WINDOW_MAGIC(window, 1.0f);
2143 
2144  return window->brightness;
2145 }
GLfloat f
float brightness
Definition: SDL_sysvideo.h:89
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:116
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 1673 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().

1674 {
1676 
1677  CHECK_WINDOW_MAGIC(window, NULL);
1678 
1679  /* Input validation */
1680  if (name == NULL || name[0] == '\0') {
1681  SDL_InvalidParamError("name");
1682  return NULL;
1683  }
1684 
1685  for (data = window->data; data; data = data->next) {
1686  if (data->name && SDL_strcmp(data->name, name) == 0) {
1687  return data->data;
1688  }
1689  }
1690  return NULL;
1691 }
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: SDL_opengl.h:1967
GLuint const GLchar * name
#define SDL_InvalidParamError(param)
Definition: SDL_error.h:54
struct SDL_WindowUserData * next
Definition: SDL_sysvideo.h:67
#define NULL
Definition: begin_code.h:143
#define SDL_strcmp
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:116
SDL_WindowUserData * data
Definition: SDL_sysvideo.h:104
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 979 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().

980 {
981  int displayIndex;
982  int i, dist;
983  int closest = -1;
984  int closest_dist = 0x7FFFFFFF;
985  SDL_Point center;
986  SDL_Point delta;
987  SDL_Rect rect;
988 
989  CHECK_WINDOW_MAGIC(window, -1);
990 
991  if (SDL_WINDOWPOS_ISUNDEFINED(window->x) ||
992  SDL_WINDOWPOS_ISCENTERED(window->x)) {
993  displayIndex = (window->x & 0xFFFF);
994  if (displayIndex >= _this->num_displays) {
995  displayIndex = 0;
996  }
997  return displayIndex;
998  }
999  if (SDL_WINDOWPOS_ISUNDEFINED(window->y) ||
1000  SDL_WINDOWPOS_ISCENTERED(window->y)) {
1001  displayIndex = (window->y & 0xFFFF);
1002  if (displayIndex >= _this->num_displays) {
1003  displayIndex = 0;
1004  }
1005  return displayIndex;
1006  }
1007 
1008  /* Find the display containing the window */
1009  for (i = 0; i < _this->num_displays; ++i) {
1010  SDL_VideoDisplay *display = &_this->displays[i];
1011 
1012  if (display->fullscreen_window == window) {
1013  return i;
1014  }
1015  }
1016  center.x = window->x + window->w / 2;
1017  center.y = window->y + window->h / 2;
1018  for (i = 0; i < _this->num_displays; ++i) {
1019  SDL_GetDisplayBounds(i, &rect);
1020  if (SDL_EnclosePoints(&center, 1, &rect, NULL)) {
1021  return i;
1022  }
1023 
1024  delta.x = center.x - (rect.x + rect.w / 2);
1025  delta.y = center.y - (rect.y + rect.h / 2);
1026  dist = (delta.x*delta.x + delta.y*delta.y);
1027  if (dist < closest_dist) {
1028  closest = i;
1029  closest_dist = dist;
1030  }
1031  }
1032  if (closest < 0) {
1033  SDL_SetError("Couldn't find any displays");
1034  }
1035  return closest;
1036 }
#define SDL_WINDOWPOS_ISUNDEFINED(X)
Definition: SDL_video.h:121
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:130
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
int x
Definition: SDL_rect.h:50
int y
Definition: SDL_rect.h:51
SDL_VideoDisplay * displays
Definition: SDL_sysvideo.h:280
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:663
int w
Definition: SDL_rect.h:67
SDL_Window * fullscreen_window
Definition: SDL_sysvideo.h:129
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:42
#define NULL
Definition: begin_code.h:143
#define SDL_SetError
int h
Definition: SDL_rect.h:67
#define SDL_EnclosePoints
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:116
int y
Definition: SDL_rect.h:66
A rectangle, with the origin at the upper left.
Definition: SDL_rect.h:64
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 1070 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().

1071 {
1072  SDL_DisplayMode fullscreen_mode;
1073  SDL_VideoDisplay *display;
1074 
1075  CHECK_WINDOW_MAGIC(window, -1);
1076 
1077  if (!mode) {
1078  return SDL_InvalidParamError("mode");
1079  }
1080 
1081  fullscreen_mode = window->fullscreen_mode;
1082  if (!fullscreen_mode.w) {
1083  fullscreen_mode.w = window->windowed.w;
1084  }
1085  if (!fullscreen_mode.h) {
1086  fullscreen_mode.h = window->windowed.h;
1087  }
1088 
1089  display = SDL_GetDisplayForWindow(window);
1090 
1091  /* if in desktop size mode, just return the size of the desktop */
1093  fullscreen_mode = display->desktop_mode;
1095  &fullscreen_mode,
1096  &fullscreen_mode)) {
1097  return SDL_SetError("Couldn't find display mode match");
1098  }
1099 
1100  if (mode) {
1101  *mode = fullscreen_mode;
1102  }
1103  return 0;
1104 }
SDL_DisplayMode fullscreen_mode
Definition: SDL_sysvideo.h:87
The structure that defines a display mode.
Definition: SDL_video.h:53
#define SDL_InvalidParamError(param)
Definition: SDL_error.h:54
SDL_Rect windowed
Definition: SDL_sysvideo.h:85
SDL_VideoDisplay * SDL_GetDisplayForWindow(SDL_Window *window)
Definition: SDL_video.c:1039
int w
Definition: SDL_rect.h:67
SDL_DisplayMode desktop_mode
Definition: SDL_sysvideo.h:126
#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:810
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:116
Uint32 flags
Definition: SDL_sysvideo.h:81
Uint32 SDL_GetWindowFlags ( SDL_Window window)

Get the window flags.

Definition at line 1571 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, and SDL_Window::flags.

Referenced by SDL_ShowMessageBox().

1572 {
1573  CHECK_WINDOW_MAGIC(window, 0);
1574 
1575  return window->flags;
1576 }
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:116
Uint32 flags
Definition: SDL_sysvideo.h:81
SDL_Window* SDL_GetWindowFromID ( Uint32  id)

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

Definition at line 1555 of file SDL_video.c.

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

1556 {
1557  SDL_Window *window;
1558 
1559  if (!_this) {
1560  return NULL;
1561  }
1562  for (window = _this->windows; window; window = window->next) {
1563  if (window->id == id) {
1564  return window;
1565  }
1566  }
1567  return NULL;
1568 }
SDL_Window * next
Definition: SDL_sysvideo.h:109
SDL_Window * window
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
SDL_Window * windows
Definition: SDL_sysvideo.h:281
#define NULL
Definition: begin_code.h:143
The type used to identify a window.
Definition: SDL_sysvideo.h:71
Uint32 id
Definition: SDL_sysvideo.h:74
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 2182 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().

2185 {
2186  CHECK_WINDOW_MAGIC(window, -1);
2187 
2188  if (!window->gamma) {
2189  int i;
2190 
2191  window->gamma = (Uint16 *)SDL_malloc(256*6*sizeof(Uint16));
2192  if (!window->gamma) {
2193  return SDL_OutOfMemory();
2194  }
2195  window->saved_gamma = window->gamma + 3*256;
2196 
2197  if (_this->GetWindowGammaRamp) {
2198  if (_this->GetWindowGammaRamp(_this, window, window->gamma) < 0) {
2199  return -1;
2200  }
2201  } else {
2202  /* Create an identity gamma ramp */
2203  for (i = 0; i < 256; ++i) {
2204  Uint16 value = (Uint16)((i << 8) | i);
2205 
2206  window->gamma[0*256+i] = value;
2207  window->gamma[1*256+i] = value;
2208  window->gamma[2*256+i] = value;
2209  }
2210  }
2211  SDL_memcpy(window->saved_gamma, window->gamma, 3*256*sizeof(Uint16));
2212  }
2213 
2214  if (red) {
2215  SDL_memcpy(red, &window->gamma[0*256], 256*sizeof(Uint16));
2216  }
2217  if (green) {
2218  SDL_memcpy(green, &window->gamma[1*256], 256*sizeof(Uint16));
2219  }
2220  if (blue) {
2221  SDL_memcpy(blue, &window->gamma[2*256], 256*sizeof(Uint16));
2222  }
2223  return 0;
2224 }
GLbyte green
Uint16 * saved_gamma
Definition: SDL_sysvideo.h:91
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
#define SDL_memcpy
GLbyte GLbyte blue
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:42
#define SDL_OutOfMemory()
Definition: SDL_error.h:52
int(* GetWindowGammaRamp)(_THIS, SDL_Window *window, Uint16 *ramp)
Definition: SDL_sysvideo.h:212
const GLubyte GLuint red
Definition: SDL_glfuncs.h:78
uint16_t Uint16
An unsigned 16-bit integer type.
Definition: SDL_stdinc.h:147
#define SDL_malloc
Uint16 * gamma
Definition: SDL_sysvideo.h:90
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:116
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 2274 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.

2275 {
2276  CHECK_WINDOW_MAGIC(window, SDL_FALSE);
2278  return window == _this->grabbed_window;
2279 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
#define SDL_assert(condition)
Definition: SDL_assert.h:167
SDL_Window * grabbed_window
Definition: SDL_sysvideo.h:282
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:116
Uint32 flags
Definition: SDL_sysvideo.h:81
Uint32 SDL_GetWindowID ( SDL_Window window)

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

Definition at line 1547 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, and SDL_Window::id.

1548 {
1549  CHECK_WINDOW_MAGIC(window, 0);
1550 
1551  return window->id;
1552 }
Uint32 id
Definition: SDL_sysvideo.h:74
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:116
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 1923 of file SDL_video.c.

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

1924 {
1925  CHECK_WINDOW_MAGIC(window,);
1926  if (max_w) {
1927  *max_w = window->max_w;
1928  }
1929  if (max_h) {
1930  *max_h = window->max_h;
1931  }
1932 }
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:116
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 1887 of file SDL_video.c.

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

1888 {
1889  CHECK_WINDOW_MAGIC(window,);
1890  if (min_w) {
1891  *min_w = window->min_w;
1892  }
1893  if (min_h) {
1894  *min_h = window->min_h;
1895  }
1896 }
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:116
Uint32 SDL_GetWindowPixelFormat ( SDL_Window window)

Get the pixel format associated with the window.

Definition at line 1107 of file SDL_video.c.

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

1108 {
1109  SDL_VideoDisplay *display;
1110 
1112 
1113  display = SDL_GetDisplayForWindow(window);
1114  return display->current_mode.format;
1115 }
SDL_VideoDisplay * SDL_GetDisplayForWindow(SDL_Window *window)
Definition: SDL_video.c:1039
SDL_DisplayMode current_mode
Definition: SDL_sysvideo.h:127
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:116
Uint32 format
Definition: SDL_video.h:55
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 1739 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.

1740 {
1741  CHECK_WINDOW_MAGIC(window,);
1742 
1743  /* Fullscreen windows are always at their display's origin */
1744  if (window->flags & SDL_WINDOW_FULLSCREEN) {
1745  int displayIndex;
1746 
1747  if (x) {
1748  *x = 0;
1749  }
1750  if (y) {
1751  *y = 0;
1752  }
1753 
1754  /* Find the window's monitor and update to the
1755  monitor offset. */
1756  displayIndex = SDL_GetWindowDisplayIndex(window);
1757  if (displayIndex >= 0) {
1758  SDL_Rect bounds;
1759 
1760  SDL_zero(bounds);
1761 
1762  SDL_GetDisplayBounds(displayIndex, &bounds);
1763  if (x) {
1764  *x = bounds.x;
1765  }
1766  if (y) {
1767  *y = bounds.y;
1768  }
1769  }
1770  } else {
1771  if (x) {
1772  *x = window->x;
1773  }
1774  if (y) {
1775  *y = window->y;
1776  }
1777  }
1778 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
#define SDL_zero(x)
Definition: SDL_stdinc.h:355
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:663
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1567
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:116
int SDL_GetWindowDisplayIndex(SDL_Window *window)
Get the display index associated with a window.
Definition: SDL_video.c:979
Uint32 flags
Definition: SDL_sysvideo.h:81
int y
Definition: SDL_rect.h:66
A rectangle, with the origin at the upper left.
Definition: SDL_rect.h:64
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 1851 of file SDL_video.c.

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

Referenced by SDL_GL_GetDrawableSize().

1852 {
1853  CHECK_WINDOW_MAGIC(window,);
1854  if (w) {
1855  *w = window->w;
1856  }
1857  if (h) {
1858  *h = window->h;
1859  }
1860 }
GLubyte GLubyte GLubyte GLubyte w
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:116
GLfloat GLfloat GLfloat GLfloat h
SDL_Surface* SDL_GetWindowSurface ( SDL_Window window)

Get the SDL surface associated with the window.

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

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

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

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

2079 {
2080  CHECK_WINDOW_MAGIC(window, NULL);
2081 
2082  if (!window->surface_valid) {
2083  if (window->surface) {
2084  window->surface->flags &= ~SDL_DONTFREE;
2085  SDL_FreeSurface(window->surface);
2086  }
2087  window->surface = SDL_CreateWindowFramebuffer(window);
2088  if (window->surface) {
2089  window->surface_valid = SDL_TRUE;
2090  window->surface->flags |= SDL_DONTFREE;
2091  }
2092  }
2093  return window->surface;
2094 }
#define SDL_DONTFREE
Definition: SDL_surface.h:55
Uint32 flags
Definition: SDL_surface.h:71
#define SDL_FreeSurface
#define NULL
Definition: begin_code.h:143
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:116
SDL_bool surface_valid
Definition: SDL_sysvideo.h:94
SDL_Surface * surface
Definition: SDL_sysvideo.h:93
static SDL_Surface * SDL_CreateWindowFramebuffer(SDL_Window *window)
Definition: SDL_video.c:2054
const char* SDL_GetWindowTitle ( SDL_Window window)

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

See also
SDL_SetWindowTitle()

Definition at line 1596 of file SDL_video.c.

References CHECK_WINDOW_MAGIC, and SDL_Window::title.

1597 {
1598  CHECK_WINDOW_MAGIC(window, "");
1599 
1600  return window->title ? window->title : "";
1601 }
char * title
Definition: SDL_sysvideo.h:75
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:116
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 3135 of file SDL_video.c.

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

Referenced by ShouldUseTextureFramebuffer().

3136 {
3137  SDL_GLContext ctx = NULL;
3138  CHECK_WINDOW_MAGIC(window, NULL);
3139 
3140  if (!(window->flags & SDL_WINDOW_OPENGL)) {
3141  SDL_SetError("The specified window isn't an OpenGL window");
3142  return NULL;
3143  }
3144 
3145  ctx = _this->GL_CreateContext(_this, window);
3146 
3147  /* Creating a context is assumed to make it current in the SDL driver. */
3148  if (ctx) {
3150  _this->current_glctx = ctx;
3153  }
3154  return ctx;
3155 }
#define SDL_TLSSet
SDL_Window * window
SDL_TLSID current_glwin_tls
Definition: SDL_sysvideo.h:327
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
void * SDL_GLContext
An opaque handle to an OpenGL context.
Definition: SDL_video.h:164
SDL_GLContext current_glctx
Definition: SDL_sysvideo.h:326
SDL_GLContext(* GL_CreateContext)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:237
#define NULL
Definition: begin_code.h:143
#define SDL_SetError
SDL_TLSID current_glctx_tls
Definition: SDL_sysvideo.h:328
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:116
Uint32 flags
Definition: SDL_sysvideo.h:81
SDL_Window * current_glwin
Definition: SDL_sysvideo.h:325
void SDL_GL_DeleteContext ( SDL_GLContext  context)

Delete an OpenGL context.

See also
SDL_GL_CreateContext()

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

3267 {
3268  if (!_this || !context) {
3269  return;
3270  }
3271 
3272  if (SDL_GL_GetCurrentContext() == context) {
3274  }
3275 
3276  _this->GL_DeleteContext(_this, context);
3277 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
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:3158
#define NULL
Definition: begin_code.h:143
SDL_GLContext SDL_GL_GetCurrentContext(void)
Get the currently active OpenGL context.
Definition: SDL_video.c:3199
void(* GL_DeleteContext)(_THIS, SDL_GLContext context)
Definition: SDL_sysvideo.h:243
SDL_bool SDL_GL_ExtensionSupported ( const char *  extension)

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

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

2657 {
2658 #if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
2659  const GLubyte *(APIENTRY * glGetStringFunc) (GLenum);
2660  const char *extensions;
2661  const char *start;
2662  const char *where, *terminator;
2663 
2664  /* Extension names should not have spaces. */
2665  where = SDL_strchr(extension, ' ');
2666  if (where || *extension == '\0') {
2667  return SDL_FALSE;
2668  }
2669  /* See if there's an environment variable override */
2670  start = SDL_getenv(extension);
2671  if (start && *start == '0') {
2672  return SDL_FALSE;
2673  }
2674 
2675  /* Lookup the available extensions */
2676 
2677  glGetStringFunc = SDL_GL_GetProcAddress("glGetString");
2678  if (!glGetStringFunc) {
2679  return SDL_FALSE;
2680  }
2681 
2682  if (isAtLeastGL3((const char *) glGetStringFunc(GL_VERSION))) {
2683  const GLubyte *(APIENTRY * glGetStringiFunc) (GLenum, GLuint);
2684  void (APIENTRY * glGetIntegervFunc) (GLenum pname, GLint * params);
2685  GLint num_exts = 0;
2686  GLint i;
2687 
2688  glGetStringiFunc = SDL_GL_GetProcAddress("glGetStringi");
2689  glGetIntegervFunc = SDL_GL_GetProcAddress("glGetIntegerv");
2690  if ((!glGetStringiFunc) || (!glGetIntegervFunc)) {
2691  return SDL_FALSE;
2692  }
2693 
2694  #ifndef GL_NUM_EXTENSIONS
2695  #define GL_NUM_EXTENSIONS 0x821D
2696  #endif
2697  glGetIntegervFunc(GL_NUM_EXTENSIONS, &num_exts);
2698  for (i = 0; i < num_exts; i++) {
2699  const char *thisext = (const char *) glGetStringiFunc(GL_EXTENSIONS, i);
2700  if (SDL_strcmp(thisext, extension) == 0) {
2701  return SDL_TRUE;
2702  }
2703  }
2704 
2705  return SDL_FALSE;
2706  }
2707 
2708  /* Try the old way with glGetString(GL_EXTENSIONS) ... */
2709 
2710  extensions = (const char *) glGetStringFunc(GL_EXTENSIONS);
2711  if (!extensions) {
2712  return SDL_FALSE;
2713  }
2714  /*
2715  * It takes a bit of care to be fool-proof about parsing the OpenGL
2716  * extensions string. Don't be fooled by sub-strings, etc.
2717  */
2718 
2719  start = extensions;
2720 
2721  for (;;) {
2722  where = SDL_strstr(start, extension);
2723  if (!where)
2724  break;
2725 
2726  terminator = where + SDL_strlen(extension);
2727  if (where == start || *(where - 1) == ' ')
2728  if (*terminator == ' ' || *terminator == '\0')
2729  return SDL_TRUE;
2730 
2731  start = terminator;
2732  }
2733  return SDL_FALSE;
2734 #else
2735  return SDL_FALSE;
2736 #endif
2737 }
#define APIENTRY
Definition: SDL_opengl.h:132
int GLint
Definition: SDL_opengl.h:175
#define GL_EXTENSIONS
Definition: SDL_opengl.h:709
GLuint start
Definition: SDL_opengl.h:1564
#define GL_VERSION
Definition: SDL_opengl.h:708
#define SDL_strchr
#define GL_NUM_EXTENSIONS
static SDL_INLINE SDL_bool isAtLeastGL3(const char *verstr)
Definition: SDL_video.c:2650
const GLfloat * params
unsigned char GLubyte
Definition: SDL_opengl.h:176
GLenum pname
#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:42
unsigned int GLenum
Definition: SDL_opengl.h:169
unsigned int GLuint
Definition: SDL_opengl.h:178
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 void
#define SDL_strlen
void * SDL_GL_GetProcAddress(const char *proc)
Get the address of an OpenGL function.
Definition: SDL_video.c:2611
#define SDL_strcmp
#define SDL_strstr
int SDL_GL_GetAttribute ( SDL_GLattr  attr,
int *  value 
)

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

Definition at line 2899 of file SDL_video.c.

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

2900 {
2901 #if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
2902  GLenum (APIENTRY *glGetErrorFunc) (void);
2903  GLenum attrib = 0;
2904  GLenum error = 0;
2905 
2906  /*
2907  * Some queries in Core Profile desktop OpenGL 3+ contexts require
2908  * glGetFramebufferAttachmentParameteriv instead of glGetIntegerv. Note that
2909  * the enums we use for the former function don't exist in OpenGL ES 2, and
2910  * the function itself doesn't exist prior to OpenGL 3 and OpenGL ES 2.
2911  */
2912 #if SDL_VIDEO_OPENGL
2913  const GLubyte *(APIENTRY *glGetStringFunc) (GLenum name);
2914  void (APIENTRY *glGetFramebufferAttachmentParameterivFunc) (GLenum target, GLenum attachment, GLenum pname, GLint* params);
2915  GLenum attachment = GL_BACK_LEFT;
2916  GLenum attachmentattrib = 0;
2917 #endif
2918 
2919  /* Clear value in any case */
2920  *value = 0;
2921 
2922  switch (attr) {
2923  case SDL_GL_RED_SIZE:
2924 #if SDL_VIDEO_OPENGL
2925  attachmentattrib = GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE;
2926 #endif
2927  attrib = GL_RED_BITS;
2928  break;
2929  case SDL_GL_BLUE_SIZE:
2930 #if SDL_VIDEO_OPENGL
2931  attachmentattrib = GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE;
2932 #endif
2933  attrib = GL_BLUE_BITS;
2934  break;
2935  case SDL_GL_GREEN_SIZE:
2936 #if SDL_VIDEO_OPENGL
2937  attachmentattrib = GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE;
2938 #endif
2939  attrib = GL_GREEN_BITS;
2940  break;
2941  case SDL_GL_ALPHA_SIZE:
2942 #if SDL_VIDEO_OPENGL
2943  attachmentattrib = GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE;
2944 #endif
2945  attrib = GL_ALPHA_BITS;
2946  break;
2947  case SDL_GL_DOUBLEBUFFER:
2948 #if SDL_VIDEO_OPENGL
2949  attrib = GL_DOUBLEBUFFER;
2950  break;
2951 #else
2952  /* OpenGL ES 1.0 and above specifications have EGL_SINGLE_BUFFER */
2953  /* parameter which switches double buffer to single buffer. OpenGL ES */
2954  /* SDL driver must set proper value after initialization */
2956  return 0;
2957 #endif
2958  case SDL_GL_DEPTH_SIZE:
2959 #if SDL_VIDEO_OPENGL
2960  attachment = GL_DEPTH;
2961  attachmentattrib = GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE;
2962 #endif
2963  attrib = GL_DEPTH_BITS;
2964  break;
2965  case SDL_GL_STENCIL_SIZE:
2966 #if SDL_VIDEO_OPENGL
2967  attachment = GL_STENCIL;
2968  attachmentattrib = GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE;
2969 #endif
2970  attrib = GL_STENCIL_BITS;
2971  break;
2972 #if SDL_VIDEO_OPENGL
2973  case SDL_GL_ACCUM_RED_SIZE:
2974  attrib = GL_ACCUM_RED_BITS;
2975  break;
2977  attrib = GL_ACCUM_GREEN_BITS;
2978  break;
2980  attrib = GL_ACCUM_BLUE_BITS;
2981  break;
2983  attrib = GL_ACCUM_ALPHA_BITS;
2984  break;
2985  case SDL_GL_STEREO:
2986  attrib = GL_STEREO;
2987  break;
2988 #else
2989  case SDL_GL_ACCUM_RED_SIZE:
2993  case SDL_GL_STEREO:
2994  /* none of these are supported in OpenGL ES */
2995  *value = 0;
2996  return 0;
2997 #endif
2999  attrib = GL_SAMPLE_BUFFERS;
3000  break;
3002  attrib = GL_SAMPLES;
3003  break;
3005 #if SDL_VIDEO_OPENGL
3006  attrib = GL_CONTEXT_RELEASE_BEHAVIOR;
3007 #else
3009 #endif
3010  break;
3011  case SDL_GL_BUFFER_SIZE:
3012  {
3013  int rsize = 0, gsize = 0, bsize = 0, asize = 0;
3014 
3015  /* There doesn't seem to be a single flag in OpenGL for this! */
3016  if (SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &rsize) < 0) {
3017  return -1;
3018  }
3019  if (SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &gsize) < 0) {
3020  return -1;
3021  }
3022  if (SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &bsize) < 0) {
3023  return -1;
3024  }
3025  if (SDL_GL_GetAttribute(SDL_GL_ALPHA_SIZE, &asize) < 0) {
3026  return -1;
3027  }
3028 
3029  *value = rsize + gsize + bsize + asize;
3030  return 0;
3031  }
3033  {
3034  /* FIXME: How do we get this information? */
3035  *value = (_this->gl_config.accelerated != 0);
3036  return 0;
3037  }
3039  {
3041  return 0;
3042  }
3044  {
3046  return 0;
3047  }
3049  {
3051  return 0;
3052  }
3053  case SDL_GL_CONTEXT_EGL:
3054  /* FIXME: SDL_GL_CONTEXT_EGL to be deprecated in SDL 2.1 */
3055  {
3057  *value = 1;
3058  }
3059  else {
3060  *value = 0;
3061  }
3062  return 0;
3063  }
3064  case SDL_GL_CONTEXT_FLAGS:
3065  {
3066  *value = _this->gl_config.flags;
3067  return 0;
3068  }
3070  {
3072  return 0;
3073  }
3075  {
3077  return 0;
3078  }
3080  {
3082  return 0;
3083  }
3084  default:
3085  return SDL_SetError("Unknown OpenGL attribute");
3086  }
3087 
3088 #if SDL_VIDEO_OPENGL
3089  glGetStringFunc = SDL_GL_GetProcAddress("glGetString");
3090  if (!glGetStringFunc) {
3091  return SDL_SetError("Failed getting OpenGL glGetString entry point");
3092  }
3093 
3094  if (attachmentattrib && isAtLeastGL3((const char *) glGetStringFunc(GL_VERSION))) {
3095  glGetFramebufferAttachmentParameterivFunc = SDL_GL_GetProcAddress("glGetFramebufferAttachmentParameteriv");
3096 
3097  if (glGetFramebufferAttachmentParameterivFunc) {
3098  glGetFramebufferAttachmentParameterivFunc(GL_FRAMEBUFFER, attachment, attachmentattrib, (GLint *) value);
3099  } else {
3100  return SDL_SetError("Failed getting OpenGL glGetFramebufferAttachmentParameteriv entry point");
3101  }
3102  } else
3103 #endif
3104  {
3105  void (APIENTRY *glGetIntegervFunc) (GLenum pname, GLint * params);
3106  glGetIntegervFunc = SDL_GL_GetProcAddress("glGetIntegerv");
3107  if (glGetIntegervFunc) {
3108  glGetIntegervFunc(attrib, (GLint *) value);
3109  } else {
3110  return SDL_SetError("Failed getting OpenGL glGetIntegerv entry point");
3111  }
3112  }
3113 
3114  glGetErrorFunc = SDL_GL_GetProcAddress("glGetError");
3115  if (!glGetErrorFunc) {
3116  return SDL_SetError("Failed getting OpenGL glGetError entry point");
3117  }
3118 
3119  error = glGetErrorFunc();
3120  if (error != GL_NO_ERROR) {
3121  if (error == GL_INVALID_ENUM) {
3122  return SDL_SetError("OpenGL error: GL_INVALID_ENUM");
3123  } else if (error == GL_INVALID_VALUE) {
3124  return SDL_SetError("OpenGL error: GL_INVALID_VALUE");
3125  }
3126  return SDL_SetError("OpenGL error: %08X", error);
3127  }
3128  return 0;
3129 #else
3130  return SDL_Unsupported();
3131 #endif /* SDL_VIDEO_OPENGL */
3132 }
#define GL_STENCIL_BITS
Definition: SDL_opengl.h:467
#define GL_INVALID_ENUM
Definition: SDL_opengl.h:713
#define GL_SAMPLE_BUFFERS
Definition: SDL_opengl.h:1832
#define GL_BACK_LEFT
Definition: SDL_opengl.h:492
#define GL_CONTEXT_RELEASE_BEHAVIOR_KHR
Definition: SDL_video.c:50
#define GL_DOUBLEBUFFER
Definition: SDL_opengl.h:514
#define APIENTRY
Definition: SDL_opengl.h:132
#define GL_RED_BITS
Definition: SDL_opengl.h:506
int GLint
Definition: SDL_opengl.h:175
#define GL_CONTEXT_RELEASE_BEHAVIOR
#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE
#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE
#define GL_SAMPLES
Definition: SDL_opengl.h:1833
#define GL_DEPTH_BITS
Definition: SDL_opengl.h:321
GLuint const GLchar * name
#define GL_VERSION
Definition: SDL_opengl.h:708
#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE
#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE
#define GL_ACCUM_ALPHA_BITS
Definition: SDL_opengl.h:376
#define GL_FRAMEBUFFER
#define GL_NO_ERROR
Definition: SDL_opengl.h:712
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
#define GL_BLUE_BITS
Definition: SDL_opengl.h:508
static SDL_INLINE SDL_bool isAtLeastGL3(const char *verstr)
Definition: SDL_video.c:2650
const GLfloat * params
#define GL_STENCIL
Definition: SDL_opengl.h:519
GLsizei const GLfloat * value
#define GL_ALPHA_BITS
Definition: SDL_opengl.h:505
#define GL_DEPTH
Definition: SDL_opengl.h:518
#define GL_ACCUM_RED_BITS
Definition: SDL_opengl.h:373
#define GL_INVALID_VALUE
Definition: SDL_opengl.h:714
int framebuffer_srgb_capable
Definition: SDL_sysvideo.h:313
unsigned char GLubyte
Definition: SDL_opengl.h:176
GLenum pname
#define GL_ACCUM_GREEN_BITS
Definition: SDL_opengl.h:374
#define GL_STEREO
Definition: SDL_opengl.h:515
struct SDL_VideoDevice::@27 gl_config
int share_with_current_context
Definition: SDL_sysvideo.h:311
unsigned int GLenum
Definition: SDL_opengl.h:169
#define SDL_SetError
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 void
#define GL_ACCUM_BLUE_BITS
Definition: SDL_opengl.h:375
GLenum attachment
void * SDL_GL_GetProcAddress(const char *proc)
Get the address of an OpenGL function.
Definition: SDL_video.c:2611
#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:2899
#define GL_GREEN_BITS
Definition: SDL_opengl.h:507
GLenum target
#define SDL_Unsupported()
Definition: SDL_error.h:53
#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE
SDL_GLContext SDL_GL_GetCurrentContext ( void  )

Get the currently active OpenGL context.

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

3200 {
3201  if (!_this) {
3203  return NULL;
3204  }
3206 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
void * SDL_GLContext
An opaque handle to an OpenGL context.
Definition: SDL_video.h:164
#define SDL_TLSGet
#define NULL
Definition: begin_code.h:143
SDL_TLSID current_glctx_tls
Definition: SDL_sysvideo.h:328
static int SDL_UninitializedVideo()
Definition: SDL_video.c:419
SDL_Window* SDL_GL_GetCurrentWindow ( void  )

Get the currently active OpenGL window.

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

3190 {
3191  if (!_this) {
3193  return NULL;
3194  }
3196 }
SDL_TLSID current_glwin_tls
Definition: SDL_sysvideo.h:327
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
#define SDL_TLSGet
#define NULL
Definition: begin_code.h:143
The type used to identify a window.
Definition: SDL_sysvideo.h:71
static int SDL_UninitializedVideo()
Definition: SDL_video.c:419
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 3208 of file SDL_video.c.

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

3209 {
3210  CHECK_WINDOW_MAGIC(window,);
3211 
3212  if (_this->GL_GetDrawableSize) {
3213  _this->GL_GetDrawableSize(_this, window, w, h);
3214  } else {
3215  SDL_GetWindowSize(window, w, h);
3216  }
3217 }
void(* GL_GetDrawableSize)(_THIS, SDL_Window *window, int *w, int *h)
Definition: SDL_sysvideo.h:239
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
void SDL_GetWindowSize(SDL_Window *window, int *w, int *h)
Get the size of a window&#39;s client area.
Definition: SDL_video.c:1851
GLubyte GLubyte GLubyte GLubyte w
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:116
GLfloat GLfloat GLfloat GLfloat h
void* SDL_GL_GetProcAddress ( const char *  proc)

Get the address of an OpenGL function.

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

2612 {
2613  void *func;
2614 
2615  if (!_this) {
2617  return NULL;
2618  }
2619  func = NULL;
2620  if (_this->GL_GetProcAddress) {
2621  if (_this->gl_config.driver_loaded) {
2622  func = _this->GL_GetProcAddress(_this, proc);
2623  } else {
2624  SDL_SetError("No GL driver has been loaded");
2625  }
2626  } else {
2627  SDL_SetError("No dynamic GL support in video driver");
2628  }
2629  return func;
2630 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
struct SDL_VideoDevice::@27 gl_config
#define NULL
Definition: begin_code.h:143
#define SDL_SetError
GLenum func
static int SDL_UninitializedVideo()
Definition: SDL_video.c:419
void *(* GL_GetProcAddress)(_THIS, const char *proc)
Definition: SDL_sysvideo.h:235
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 3234 of file SDL_video.c.

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

3235 {
3236  if (!_this) {
3237  return 0;
3238  } else if (SDL_GL_GetCurrentContext() == NULL) {
3239  return 0;
3240  } else if (_this->GL_GetSwapInterval) {
3241  return _this->GL_GetSwapInterval(_this);
3242  } else {
3243  return 0;
3244  }
3245 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
#define NULL
Definition: begin_code.h:143
SDL_GLContext SDL_GL_GetCurrentContext(void)
Get the currently active OpenGL context.
Definition: SDL_video.c:3199
int(* GL_GetSwapInterval)(_THIS)
Definition: SDL_sysvideo.h:241
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 2582 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().

2583 {
2584  int retval;
2585 
2586  if (!_this) {
2587  return SDL_UninitializedVideo();
2588  }
2589  if (_this->gl_config.driver_loaded) {
2590  if (path && SDL_strcmp(path, _this->gl_config.driver_path) != 0) {
2591  return SDL_SetError("OpenGL library already loaded");
2592  }
2593  retval = 0;
2594  } else {
2595  if (!_this->GL_LoadLibrary) {
2596  return SDL_SetError("No dynamic GL support in video driver");
2597  }
2598  retval = _this->GL_LoadLibrary(_this, path);
2599  }
2600  if (retval == 0) {
2602  } else {
2603  if (_this->GL_UnloadLibrary) {
2605  }
2606  }
2607  return (retval);
2608 }
int(* GL_LoadLibrary)(_THIS, const char *path)
Definition: SDL_sysvideo.h:234
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
SDL_bool retval
char driver_path[256]
Definition: SDL_sysvideo.h:316
void(* GL_UnloadLibrary)(_THIS)
Definition: SDL_sysvideo.h:236
struct SDL_VideoDevice::@27 gl_config
#define SDL_SetError
static int SDL_UninitializedVideo()
Definition: SDL_video.c:419
GLsizei const GLchar *const * path
#define SDL_strcmp
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 3158 of file SDL_video.c.

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

Referenced by SDL_DestroyWindow(), and SDL_GL_DeleteContext().

3159 {
3160  int retval;
3161 
3162  if (window == SDL_GL_GetCurrentWindow() &&
3163  ctx == SDL_GL_GetCurrentContext()) {
3164  /* We're already current. */
3165  return 0;
3166  }
3167 
3168  if (!ctx) {
3169  window = NULL;
3170  } else {
3171  CHECK_WINDOW_MAGIC(window, -1);
3172 
3173  if (!(window->flags & SDL_WINDOW_OPENGL)) {
3174  return SDL_SetError("The specified window isn't an OpenGL window");
3175  }
3176  }
3177 
3178  retval = _this->GL_MakeCurrent(_this, window, ctx);
3179  if (retval == 0) {
3181  _this->current_glctx = ctx;
3184  }
3185  return retval;
3186 }
#define SDL_TLSSet
SDL_Window * window
SDL_TLSID current_glwin_tls
Definition: SDL_sysvideo.h:327
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
SDL_bool retval
SDL_GLContext current_glctx
Definition: SDL_sysvideo.h:326
int(* GL_MakeCurrent)(_THIS, SDL_Window *window, SDL_GLContext context)
Definition: SDL_sysvideo.h:238
#define NULL
Definition: begin_code.h:143
#define SDL_SetError
SDL_TLSID current_glctx_tls
Definition: SDL_sysvideo.h:328
SDL_GLContext SDL_GL_GetCurrentContext(void)
Get the currently active OpenGL context.
Definition: SDL_video.c:3199
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:116
Uint32 flags
Definition: SDL_sysvideo.h:81
SDL_Window * SDL_GL_GetCurrentWindow(void)
Get the currently active OpenGL window.
Definition: SDL_video.c:3189
SDL_Window * current_glwin
Definition: SDL_sysvideo.h:325
void SDL_GL_ResetAttributes ( void  )

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

Definition at line 2740 of file SDL_video.c.

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

Referenced by SDL_VideoInit().

2741 {
2742  if (!_this) {
2743  return;
2744  }
2745 
2746  _this->gl_config.red_size = 3;
2747  _this->gl_config.green_size = 3;
2748  _this->gl_config.blue_size = 2;
2749  _this->gl_config.alpha_size = 0;
2751  _this->gl_config.depth_size = 16;
2758  _this->gl_config.stereo = 0;
2762  _this->gl_config.accelerated = -1; /* accelerated or not, both are fine */
2764 #if SDL_VIDEO_OPENGL
2767 #elif SDL_VIDEO_OPENGL_ES2
2771 #elif SDL_VIDEO_OPENGL_ES
2775 #endif
2776  _this->gl_config.flags = 0;
2779 
2781 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
int framebuffer_srgb_capable
Definition: SDL_sysvideo.h:313
struct SDL_VideoDevice::@27 gl_config
int share_with_current_context
Definition: SDL_sysvideo.h:311
int SDL_GL_SetAttribute ( SDL_GLattr  attr,
int  value 
)

Set an OpenGL window attribute before window creation.

Definition at line 2784 of file SDL_video.c.

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

2785 {
2786 #if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
2787  int retval;
2788 
2789  if (!_this) {
2790  return SDL_UninitializedVideo();
2791  }
2792  retval = 0;
2793  switch (attr) {
2794  case SDL_GL_RED_SIZE:
2796  break;
2797  case SDL_GL_GREEN_SIZE:
2799  break;
2800  case SDL_GL_BLUE_SIZE:
2802  break;
2803  case SDL_GL_ALPHA_SIZE:
2805  break;
2806  case SDL_GL_DOUBLEBUFFER:
2808  break;
2809  case SDL_GL_BUFFER_SIZE:
2811  break;
2812  case SDL_GL_DEPTH_SIZE:
2814  break;
2815  case SDL_GL_STENCIL_SIZE:
2817  break;
2818  case SDL_GL_ACCUM_RED_SIZE:
2820  break;
2823  break;
2826  break;
2829  break;
2830  case SDL_GL_STEREO:
2832  break;
2835  break;
2838  break;
2841  break;
2844  break;
2847  break;
2850  break;
2851  case SDL_GL_CONTEXT_EGL:
2852  /* FIXME: SDL_GL_CONTEXT_EGL to be deprecated in SDL 2.1 */
2853  if (value != 0) {
2855  } else {
2857  };
2858  break;
2859  case SDL_GL_CONTEXT_FLAGS:
2864  retval = SDL_SetError("Unknown OpenGL context flag %d", value);
2865  break;
2866  }
2868  break;
2870  if (value != 0 &&
2874  retval = SDL_SetError("Unknown OpenGL context profile %d", value);
2875  break;
2876  }
2878  break;
2881  break;
2884  break;
2887  break;
2888  default:
2889  retval = SDL_SetError("Unknown OpenGL attribute");
2890  break;
2891  }
2892  return retval;
2893 #else
2894  return SDL_Unsupported();
2895 #endif /* SDL_VIDEO_OPENGL */
2896 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
SDL_bool retval
GLsizei const GLfloat * value
int framebuffer_srgb_capable
Definition: SDL_sysvideo.h:313
struct SDL_VideoDevice::@27 gl_config
int share_with_current_context
Definition: SDL_sysvideo.h:311
#define SDL_SetError
int SDL_GL_SetAttribute(SDL_GLattr attr, int value)
Set an OpenGL window attribute before window creation.
Definition: SDL_video.c:2784
static int SDL_UninitializedVideo()
Definition: SDL_video.c:419
#define SDL_Unsupported()
Definition: SDL_error.h:53
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 3220 of file SDL_video.c.

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

3221 {
3222  if (!_this) {
3223  return SDL_UninitializedVideo();
3224  } else if (SDL_GL_GetCurrentContext() == NULL) {
3225  return SDL_SetError("No OpenGL context has been made current");
3226  } else if (_this->GL_SetSwapInterval) {
3227  return _this->GL_SetSwapInterval(_this, interval);
3228  } else {
3229  return SDL_SetError("Setting the swap interval is not supported");
3230  }
3231 }
int(* GL_SetSwapInterval)(_THIS, int interval)
Definition: SDL_sysvideo.h:240
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
#define NULL
Definition: begin_code.h:143
#define SDL_SetError
SDL_GLContext SDL_GL_GetCurrentContext(void)
Get the currently active OpenGL context.
Definition: SDL_video.c:3199
static int SDL_UninitializedVideo()
Definition: SDL_video.c:419
void SDL_GL_SwapWindow ( SDL_Window window)

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

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

3249 {
3250  CHECK_WINDOW_MAGIC(window,);
3251 
3252  if (!(window->flags & SDL_WINDOW_OPENGL)) {
3253  SDL_SetError("The specified window isn't an OpenGL window");
3254  return;
3255  }
3256 
3257  if (SDL_GL_GetCurrentWindow() != window) {
3258  SDL_SetError("The specified window has not been made current");
3259  return;
3260  }
3261 
3262  _this->GL_SwapWindow(_this, window);
3263 }
void(* GL_SwapWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:242
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
#define SDL_SetError
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:116
Uint32 flags
Definition: SDL_sysvideo.h:81
SDL_Window * SDL_GL_GetCurrentWindow(void)
Get the currently active OpenGL window.
Definition: SDL_video.c:3189
void SDL_GL_UnloadLibrary ( void  )

Unload the OpenGL library previously loaded by SDL_GL_LoadLibrary().

See also
SDL_GL_LoadLibrary()

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

2634 {
2635  if (!_this) {
2637  return;
2638  }
2639  if (_this->gl_config.driver_loaded > 0) {
2640  if (--_this->gl_config.driver_loaded > 0) {
2641  return;
2642  }
2643  if (_this->GL_UnloadLibrary) {
2645  }
2646  }
2647 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
void(* GL_UnloadLibrary)(_THIS)
Definition: SDL_sysvideo.h:236
struct SDL_VideoDevice::@27 gl_config
static int SDL_UninitializedVideo()
Definition: SDL_video.c:419
void SDL_HideWindow ( SDL_Window window)

Hide a window.

See also
SDL_ShowWindow()

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

1951 {
1952  CHECK_WINDOW_MAGIC(window,);
1953 
1954  if (!(window->flags & SDL_WINDOW_SHOWN)) {
1955  return;
1956  }
1957 
1958  window->is_hiding = SDL_TRUE;
1960 
1961  if (_this->HideWindow) {
1962  _this->HideWindow(_this, window);
1963  }
1964  window->is_hiding = SDL_FALSE;
1966 }
int SDL_SendWindowEvent(SDL_Window *window, Uint8 windowevent, int data1, int data2)
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
void(* HideWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:204
static int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen)
Definition: SDL_video.c:1133
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:116
Uint32 flags
Definition: SDL_sysvideo.h:81
SDL_bool is_hiding
Definition: SDL_sysvideo.h:96
SDL_bool SDL_IsScreenSaverEnabled ( void  )

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

See also
SDL_EnableScreenSaver()
SDL_DisableScreenSaver()

Definition at line 2493 of file SDL_video.c.

References SDL_FALSE, SDL_TRUE, and SDL_VideoDevice::suspend_screensaver.

2494 {
2495  if (!_this) {
2496  return SDL_TRUE;
2497  }
2499 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
SDL_bool suspend_screensaver
Definition: SDL_sysvideo.h:278
void SDL_MaximizeWindow ( SDL_Window window)

Make a window as large as possible.

See also
SDL_RestoreWindow()

Definition at line 1982 of file SDL_video.c.

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

Referenced by SDL_FinishWindowCreation().

1983 {
1984  CHECK_WINDOW_MAGIC(window,);
1985 
1986  if (window->flags & SDL_WINDOW_MAXIMIZED) {
1987  return;
1988  }
1989 
1990  /* !!! FIXME: should this check if the window is resizable? */
1991 
1992  if (_this->MaximizeWindow) {
1993  _this->MaximizeWindow(_this, window);
1994  }
1995 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:116
void(* MaximizeWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:206
Uint32 flags
Definition: SDL_sysvideo.h:81
void SDL_MinimizeWindow ( SDL_Window window)

Minimize a window to an iconic representation.

See also
SDL_RestoreWindow()

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

1999 {
2000  CHECK_WINDOW_MAGIC(window,);
2001 
2002  if (window->flags & SDL_WINDOW_MINIMIZED) {
2003  return;
2004  }
2005 
2007 
2008  if (_this->MinimizeWindow) {
2009  _this->MinimizeWindow(_this, window);
2010  }
2011 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
static int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen)
Definition: SDL_video.c:1133
void(* MinimizeWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:207
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:116
Uint32 flags
Definition: SDL_sysvideo.h:81
void SDL_RaiseWindow ( SDL_Window window)

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

Definition at line 1969 of file SDL_video.c.

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

Referenced by SDL_ShowMessageBox().

1970 {
1971  CHECK_WINDOW_MAGIC(window,);
1972 
1973  if (!(window->flags & SDL_WINDOW_SHOWN)) {
1974  return;
1975  }
1976  if (_this->RaiseWindow) {
1977  _this->RaiseWindow(_this, window);
1978  }
1979 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
void(* RaiseWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:205
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:116
Uint32 flags
Definition: SDL_sysvideo.h:81
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 2014 of file SDL_video.c.

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

2015 {
2016  CHECK_WINDOW_MAGIC(window,);
2017 
2018  if (!(window->flags & (SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED))) {
2019  return;
2020  }
2021 
2022  if (_this->RestoreWindow) {
2023  _this->RestoreWindow(_this, window);
2024  }
2025 }
void(* RestoreWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:208
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:116
Uint32 flags
Definition: SDL_sysvideo.h:81
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 1781 of file SDL_video.c.

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

1782 {
1783  CHECK_WINDOW_MAGIC(window,);
1784  if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
1785  const int want = (bordered != SDL_FALSE); /* normalize the flag. */
1786  const int have = ((window->flags & SDL_WINDOW_BORDERLESS) == 0);
1787  if ((want != have) && (_this->SetWindowBordered)) {
1788  if (want) {
1789  window->flags &= ~SDL_WINDOW_BORDERLESS;
1790  } else {
1791  window->flags |= SDL_WINDOW_BORDERLESS;
1792  }
1793  _this->SetWindowBordered(_this, window, (SDL_bool) want);
1794  }
1795  }
1796 }
void(* SetWindowBordered)(_THIS, SDL_Window *window, SDL_bool bordered)
Definition: SDL_sysvideo.h:209
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
SDL_bool
Definition: SDL_stdinc.h:126
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:116
Uint32 flags
Definition: SDL_sysvideo.h:81
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 2124 of file SDL_video.c.

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

2125 {
2126  Uint16 ramp[256];
2127  int status;
2128 
2129  CHECK_WINDOW_MAGIC(window, -1);
2130 
2131  SDL_CalculateGammaRamp(brightness, ramp);
2132  status = SDL_SetWindowGammaRamp(window, ramp, ramp, ramp);
2133  if (status == 0) {
2134  window->brightness = brightness;
2135  }
2136  return status;
2137 }
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:2148
float brightness
Definition: SDL_sysvideo.h:89
uint16_t Uint16
An unsigned 16-bit integer type.
Definition: SDL_stdinc.h:147
#define SDL_CalculateGammaRamp
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:116
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 1626 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().

1627 {
1628  SDL_WindowUserData *prev, *data;
1629 
1630  CHECK_WINDOW_MAGIC(window, NULL);
1631 
1632  /* Input validation */
1633  if (name == NULL || name[0] == '\0') {
1634  SDL_InvalidParamError("name");
1635  return NULL;
1636  }
1637 
1638  /* See if the named data already exists */
1639  prev = NULL;
1640  for (data = window->data; data; prev = data, data = data->next) {
1641  if (data->name && SDL_strcmp(data->name, name) == 0) {
1642  void *last_value = data->data;
1643 
1644  if (userdata) {
1645  /* Set the new value */
1646  data->data = userdata;
1647  } else {
1648  /* Delete this value */
1649  if (prev) {
1650  prev->next = data->next;
1651  } else {
1652  window->data = data->next;
1653  }
1654  SDL_free(data->name);
1655  SDL_free(data);
1656  }
1657  return last_value;
1658  }
1659  }
1660 
1661  /* Add new data to the window */
1662  if (userdata) {
1663  data = (SDL_WindowUserData *)SDL_malloc(sizeof(*data));
1664  data->name = SDL_strdup(name);
1665  data->data = userdata;
1666  data->next = window->data;
1667  window->data = data;
1668  }
1669  return NULL;
1670 }
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: SDL_opengl.h:1967
GLuint const GLchar * name
#define SDL_InvalidParamError(param)
Definition: SDL_error.h:54
struct SDL_WindowUserData * next
Definition: SDL_sysvideo.h:67
void SDL_free(void *mem)
#define NULL
Definition: begin_code.h:143
#define SDL_strdup
#define SDL_malloc
#define SDL_strcmp
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:116
SDL_WindowUserData * data
Definition: SDL_sysvideo.h:104
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 1050 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.

1051 {
1052  CHECK_WINDOW_MAGIC(window, -1);
1053 
1054  if (mode) {
1055  window->fullscreen_mode = *mode;
1056  } else {
1057  SDL_zero(window->fullscreen_mode);
1058  }
1059 
1061  SDL_DisplayMode fullscreen_mode;
1062  if (SDL_GetWindowDisplayMode(window, &fullscreen_mode) == 0) {
1063  SDL_SetDisplayModeForDisplay(SDL_GetDisplayForWindow(window), &fullscreen_mode);
1064  }
1065  }
1066  return 0;
1067 }
SDL_DisplayMode fullscreen_mode
Definition: SDL_sysvideo.h:87
#define FULLSCREEN_VISIBLE(W)
Definition: SDL_sysvideo.h:111
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:1070
SDL_VideoDisplay * SDL_GetDisplayForWindow(SDL_Window *window)
Definition: SDL_video.c:1039
GLenum mode
#define SDL_zero(x)
Definition: SDL_stdinc.h:355
static int SDL_SetDisplayModeForDisplay(SDL_VideoDisplay *display, const SDL_DisplayMode *mode)
Definition: SDL_video.c:930
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:116
Uint32 flags
Definition: SDL_sysvideo.h:81
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 2028 of file SDL_video.c.

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

Referenced by SDL_FinishWindowCreation().

2029 {
2030  Uint32 oldflags;
2031  CHECK_WINDOW_MAGIC(window, -1);
2032 
2034 
2035  if (flags == (window->flags & FULLSCREEN_MASK)) {
2036  return 0;
2037  }
2038 
2039  /* clear the previous flags and OR in the new ones */
2040  oldflags = window->flags & FULLSCREEN_MASK;
2041  window->flags &= ~FULLSCREEN_MASK;
2042  window->flags |= flags;
2043 
2044  if (SDL_UpdateFullscreenMode(window, FULLSCREEN_VISIBLE(window)) == 0) {
2045  return 0;
2046  }
2047 
2048  window->flags &= ~FULLSCREEN_MASK;
2049  window->flags |= oldflags;
2050  return -1;
2051 }
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:155
#define FULLSCREEN_VISIBLE(W)
Definition: SDL_sysvideo.h:111
static int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen)
Definition: SDL_video.c:1133
GLbitfield flags
#define FULLSCREEN_MASK
Definition: SDL_video.c:138
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:116
Uint32 flags
Definition: SDL_sysvideo.h:81
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 2148 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().

2151 {
2152  CHECK_WINDOW_MAGIC(window, -1);
2153 
2154  if (!_this->SetWindowGammaRamp) {
2155  return SDL_Unsupported();
2156  }
2157 
2158  if (!window->gamma) {
2159  if (SDL_GetWindowGammaRamp(window, NULL, NULL, NULL) < 0) {
2160  return -1;
2161  }
2162  SDL_assert(window->gamma != NULL);
2163  }
2164 
2165  if (red) {
2166  SDL_memcpy(&window->gamma[0*256], red, 256*sizeof(Uint16));
2167  }
2168  if (green) {
2169  SDL_memcpy(&window->gamma[1*256], green, 256*sizeof(Uint16));
2170  }
2171  if (blue) {
2172  SDL_memcpy(&window->gamma[2*256], blue, 256*sizeof(Uint16));
2173  }
2174  if (window->flags & SDL_WINDOW_INPUT_FOCUS) {
2175  return _this->SetWindowGammaRamp(_this, window, window->gamma);
2176  } else {
2177  return 0;
2178  }
2179 }
GLbyte green
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
#define SDL_memcpy
GLbyte GLbyte blue
#define SDL_assert(condition)
Definition: SDL_assert.h:167
#define NULL
Definition: begin_code.h:143
const GLubyte GLuint red
Definition: SDL_glfuncs.h:78
uint16_t Uint16
An unsigned 16-bit integer type.
Definition: SDL_stdinc.h:147
int SDL_GetWindowGammaRamp(SDL_Window *window, Uint16 *red, Uint16 *green, Uint16 *blue)
Get the gamma ramp for a window.
Definition: SDL_video.c:2182
Uint16 * gamma
Definition: SDL_sysvideo.h:90
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:116
Uint32 flags
Definition: SDL_sysvideo.h:81
int(* SetWindowGammaRamp)(_THIS, SDL_Window *window, const Uint16 *ramp)
Definition: SDL_sysvideo.h:211
#define SDL_Unsupported()
Definition: SDL_error.h:53
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 2258 of file SDL_video.c.

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

Referenced by SDL_FinishWindowCreation().

2259 {
2260  CHECK_WINDOW_MAGIC(window,);
2261 
2262  if (!!grabbed == !!(window->flags & SDL_WINDOW_INPUT_GRABBED)) {
2263  return;
2264  }
2265  if (grabbed) {
2266  window->flags |= SDL_WINDOW_INPUT_GRABBED;
2267  } else {
2268  window->flags &= ~SDL_WINDOW_INPUT_GRABBED;
2269  }
2270  SDL_UpdateWindowGrab(window);
2271 }
void SDL_UpdateWindowGrab(SDL_Window *window)
Definition: SDL_video.c:2227
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:116
Uint32 flags
Definition: SDL_sysvideo.h:81
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 3633 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.

3634 {
3635  CHECK_WINDOW_MAGIC(window, -1);
3636 
3637  if (!_this->SetWindowHitTest) {
3638  return SDL_Unsupported();
3639  } else if (_this->SetWindowHitTest(window, callback != NULL) == -1) {
3640  return -1;
3641  }
3642 
3643  window->hit_test = callback;
3644  window->hit_test_data = userdata;
3645 
3646  return 0;
3647 }
int(* SetWindowHitTest)(SDL_Window *window, SDL_bool enabled)
Definition: SDL_sysvideo.h:274
void * hit_test_data
Definition: SDL_sysvideo.h:102
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
static Uint32 callback(Uint32 interval, void *param)
Definition: testtimer.c:34
#define NULL
Definition: begin_code.h:143
SDL_HitTest hit_test
Definition: SDL_sysvideo.h:101
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:116
#define SDL_Unsupported()
Definition: SDL_error.h:53
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 1604 of file SDL_video.c.

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

1605 {
1606  CHECK_WINDOW_MAGIC(window,);
1607 
1608  if (!icon) {
1609  return;
1610  }
1611 
1612  SDL_FreeSurface(window->icon);
1613 
1614  /* Convert the icon into ARGB8888 */
1616  if (!window->icon) {
1617  return;
1618  }
1619 
1620  if (_this->SetWindowIcon) {
1621  _this->SetWindowIcon(_this, window, window->icon);
1622  }
1623 }
#define SDL_ConvertSurfaceFormat
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
#define SDL_FreeSurface
void(* SetWindowIcon)(_THIS, SDL_Window *window, SDL_Surface *icon)
Definition: SDL_sysvideo.h:198
SDL_Surface * icon
Definition: SDL_sysvideo.h:76
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:116
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 1899 of file SDL_video.c.

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

1900 {
1901  CHECK_WINDOW_MAGIC(window,);
1902  if (max_w <= 0) {
1903  SDL_InvalidParamError("max_w");
1904  return;
1905  }
1906  if (max_h <= 0) {
1907  SDL_InvalidParamError("max_h");
1908  return;
1909  }
1910 
1911  if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
1912  window->max_w = max_w;
1913  window->max_h = max_h;
1914  if (_this->SetWindowMaximumSize) {
1915  _this->SetWindowMaximumSize(_this, window);
1916  }
1917  /* Ensure that window is not larger than maximal size */
1918  SDL_SetWindowSize(window, SDL_min(window->w, window->max_w), SDL_min(window->h, window->max_h));
1919  }
1920 }
#define SDL_min(x, y)
Definition: SDL_stdinc.h:345
void SDL_SetWindowSize(SDL_Window *window, int w, int h)
Set the size of a window&#39;s client area.
Definition: SDL_video.c:1799
#define SDL_InvalidParamError(param)
Definition: SDL_error.h:54
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
void(* SetWindowMaximumSize)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:202
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:116
Uint32 flags
Definition: SDL_sysvideo.h:81
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 1863 of file SDL_video.c.

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

1864 {
1865  CHECK_WINDOW_MAGIC(window,);
1866  if (min_w <= 0) {
1867  SDL_InvalidParamError("min_w");
1868  return;
1869  }
1870  if (min_h <= 0) {
1871  SDL_InvalidParamError("min_h");
1872  return;
1873  }
1874 
1875  if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
1876  window->min_w = min_w;
1877  window->min_h = min_h;
1878  if (_this->SetWindowMinimumSize) {
1879  _this->SetWindowMinimumSize(_this, window);
1880  }
1881  /* Ensure that window is not smaller than minimal size */
1882  SDL_SetWindowSize(window, SDL_max(window->w, window->min_w), SDL_max(window->h, window->min_h));
1883  }
1884 }
void SDL_SetWindowSize(SDL_Window *window, int w, int h)
Set the size of a window&#39;s client area.
Definition: SDL_video.c:1799
#define SDL_InvalidParamError(param)
Definition: SDL_error.h:54
#define SDL_max(x, y)
Definition: SDL_stdinc.h:346
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
void(* SetWindowMinimumSize)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:201
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:116
Uint32 flags
Definition: SDL_sysvideo.h:81
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 1694 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.

1695 {
1696  CHECK_WINDOW_MAGIC(window,);
1697 
1699  int displayIndex = (x & 0xFFFF);
1700  SDL_Rect bounds;
1701  if (displayIndex > _this->num_displays) {
1702  displayIndex = 0;
1703  }
1704 
1705  SDL_zero(bounds);
1706 
1707  SDL_GetDisplayBounds(displayIndex, &bounds);
1708  if (SDL_WINDOWPOS_ISCENTERED(x)) {
1709  x = bounds.x + (bounds.w - window->w) / 2;
1710  }
1711  if (SDL_WINDOWPOS_ISCENTERED(y)) {
1712  y = bounds.y + (bounds.h - window->h) / 2;
1713  }
1714  }
1715 
1716  if ((window->flags & SDL_WINDOW_FULLSCREEN)) {
1717  if (!SDL_WINDOWPOS_ISUNDEFINED(x)) {
1718  window->windowed.x = x;
1719  }
1720  if (!SDL_WINDOWPOS_ISUNDEFINED(y)) {
1721  window->windowed.y = y;
1722  }
1723  } else {
1724  if (!SDL_WINDOWPOS_ISUNDEFINED(x)) {
1725  window->x = x;
1726  }
1727  if (!SDL_WINDOWPOS_ISUNDEFINED(y)) {
1728  window->y = y;
1729  }
1730 
1731  if (_this->SetWindowPosition) {
1732  _this->SetWindowPosition(_this, window);
1733  }
1735  }
1736 }
#define SDL_WINDOWPOS_ISUNDEFINED(X)
Definition: SDL_video.h:121
#define SDL_WINDOWPOS_ISCENTERED(X)
Definition: SDL_video.h:130
int SDL_SendWindowEvent(SDL_Window *window, Uint8 windowevent, int data1, int data2)
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
SDL_Rect windowed
Definition: SDL_sysvideo.h:85
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
#define SDL_zero(x)
Definition: SDL_stdinc.h:355
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:663
int w
Definition: SDL_rect.h:67
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1567
void(* SetWindowPosition)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:199
int h
Definition: SDL_rect.h:67
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:116
Uint32 flags
Definition: SDL_sysvideo.h:81
int y
Definition: SDL_rect.h:66
A rectangle, with the origin at the upper left.
Definition: SDL_rect.h:64
void SDL_SetWindowSize ( SDL_Window window,
int  w,
int  h 
)

Set the size of a window's client area.

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

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

See also
SDL_GetWindowSize()

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

1800 {
1801  CHECK_WINDOW_MAGIC(window,);
1802  if (w <= 0) {
1803  SDL_InvalidParamError("w");
1804  return;
1805  }
1806  if (h <= 0) {
1807  SDL_InvalidParamError("h");
1808  return;
1809  }
1810 
1811  /* Make sure we don't exceed any window size limits */
1812  if (window->min_w && w < window->min_w)
1813  {
1814  w = window->min_w;
1815  }
1816  if (window->max_w && w > window->max_w)
1817  {
1818  w = window->max_w;
1819  }
1820  if (window->min_h && h < window->min_h)
1821  {
1822  h = window->min_h;
1823  }
1824  if (window->max_h && h > window->max_h)
1825  {
1826  h = window->max_h;
1827  }
1828 
1829  window->windowed.w = w;
1830  window->windowed.h = h;
1831 
1832  if (window->flags & SDL_WINDOW_FULLSCREEN) {
1834  window->last_fullscreen_flags = 0;
1836  }
1837  } else {
1838  window->w = w;
1839  window->h = h;
1840  if (_this->SetWindowSize) {
1841  _this->SetWindowSize(_this, window);
1842  }
1843  if (window->w == w && window->h == h) {
1844  /* We didn't get a SDL_WINDOWEVENT_RESIZED event (by design) */
1845  SDL_OnWindowResized(window);
1846  }
1847  }
1848 }
#define FULLSCREEN_VISIBLE(W)
Definition: SDL_sysvideo.h:111
void(* SetWindowSize)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:200
#define SDL_InvalidParamError(param)
Definition: SDL_error.h:54
SDL_Rect windowed
Definition: SDL_sysvideo.h:85
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
static int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen)
Definition: SDL_video.c:1133
int w
Definition: SDL_rect.h:67
Uint32 last_fullscreen_flags
Definition: SDL_sysvideo.h:82
int h
Definition: SDL_rect.h:67
GLubyte GLubyte GLubyte GLubyte w
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:116
Uint32 flags
Definition: SDL_sysvideo.h:81
GLfloat GLfloat GLfloat GLfloat h
void SDL_OnWindowResized(SDL_Window *window)
Definition: SDL_video.c:2301
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 1579 of file SDL_video.c.

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

Referenced by SDL_CreateWindow().

1580 {
1581  CHECK_WINDOW_MAGIC(window,);
1582 
1583  if (title == window->title) {
1584  return;
1585  }
1586  SDL_free(window->title);
1587 
1588  window->title = SDL_strdup(title ? title : "");
1589 
1590  if (_this->SetWindowTitle) {
1591  _this->SetWindowTitle(_this, window);
1592  }
1593 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
void SDL_free(void *mem)
char * title
Definition: SDL_sysvideo.h:75
#define SDL_strdup
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:116
void(* SetWindowTitle)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:197
void SDL_ShowWindow ( SDL_Window window)

Show a window.

See also
SDL_HideWindow()

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

1936 {
1937  CHECK_WINDOW_MAGIC(window,);
1938 
1939  if (window->flags & SDL_WINDOW_SHOWN) {
1940  return;
1941  }
1942 
1943  if (_this->ShowWindow) {
1944  _this->ShowWindow(_this, window);
1945  }
1947 }
void(* ShowWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:203
int SDL_SendWindowEvent(SDL_Window *window, Uint8 windowevent, int data1, int data2)
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:116
Uint32 flags
Definition: SDL_sysvideo.h:81
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 2097 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.

2098 {
2099  SDL_Rect full_rect;
2100 
2101  CHECK_WINDOW_MAGIC(window, -1);
2102 
2103  full_rect.x = 0;
2104  full_rect.y = 0;
2105  full_rect.w = window->w;
2106  full_rect.h = window->h;
2107  return SDL_UpdateWindowSurfaceRects(window, &full_rect, 1);
2108 }
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:2111
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:116
int y
Definition: SDL_rect.h:66
A rectangle, with the origin at the upper left.
Definition: SDL_rect.h:64
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_UpdateWindowSurfaceRect()

Definition at line 2111 of file SDL_video.c.

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

Referenced by SDL_UpdateWindowSurface().

2113 {
2114  CHECK_WINDOW_MAGIC(window, -1);
2115 
2116  if (!window->surface_valid) {
2117  return SDL_SetError("Window surface is invalid, please call SDL_GetWindowSurface() to get a new surface");
2118  }
2119 
2120  return _this->UpdateWindowFramebuffer(_this, window, rects, numrects);
2121 }
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
#define SDL_SetError
int(* UpdateWindowFramebuffer)(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects)
Definition: SDL_sysvideo.h:216
#define CHECK_WINDOW_MAGIC(window, retval)
Definition: SDL_video.c:116
SDL_bool surface_valid
Definition: SDL_sysvideo.h:94
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 443 of file SDL_video.c.

References VideoBootStrap::create, SDL_VideoDevice::CreateWindowFramebuffer, SDL_VideoDevice::current_glctx_tls, SDL_VideoDevice::current_glwin_tls, SDL_VideoDevice::DestroyWindowFramebuffer, SDL_VideoDevice::dll_handle, SDL_VideoDevice::driver_loaded, SDL_VideoDevice::gl_config, i, SDL_VideoDevice::name, VideoBootStrap::name, SDL_VideoDevice::next_object_id, NULL, SDL_VideoDevice::num_displays, SDL_atoi, SDL_CreateWindowTexture(), SDL_DestroyWindowTexture(), SDL_DisableScreenSaver(), SDL_FALSE, SDL_getenv, SDL_GetHint, 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_TRUE, SDL_UpdateWindowTexture(), SDL_VideoQuit(), ShouldUseTextureFramebuffer(), SDL_VideoDevice::UpdateWindowFramebuffer, and SDL_VideoDevice::VideoInit.

Referenced by SDL_CreateWindow().

444 {
445  SDL_VideoDevice *video;
446  const char *hint;
447  int index;
448  int i;
449  SDL_bool allow_screensaver;
450 
451  /* Check to make sure we don't overwrite '_this' */
452  if (_this != NULL) {
453  SDL_VideoQuit();
454  }
455 
456 #if !SDL_TIMERS_DISABLED
457  SDL_TicksInit();
458 #endif
459 
460  /* Start the event loop */
462  SDL_KeyboardInit() < 0 ||
463  SDL_MouseInit() < 0 ||
464  SDL_TouchInit() < 0) {
465  return -1;
466  }
467 
468  /* Select the proper video driver */
469  index = 0;
470  video = NULL;
471  if (driver_name == NULL) {
472  driver_name = SDL_getenv("SDL_VIDEODRIVER");
473  }
474  if (driver_name != NULL) {
475  for (i = 0; bootstrap[i]; ++i) {
476  if (SDL_strncasecmp(bootstrap[i]->name, driver_name, SDL_strlen(driver_name)) == 0) {
477  if (bootstrap[i]->available()) {
478  video = bootstrap[i]->create(index);
479  break;
480  }
481  }
482  }
483  } else {
484  for (i = 0; bootstrap[i]; ++i) {
485  if (bootstrap[i]->available()) {
486  video = bootstrap[i]->create(index);
487  if (video != NULL) {
488  break;
489  }
490  }
491  }
492  }
493  if (video == NULL) {
494  if (driver_name) {
495  return SDL_SetError("%s not available", driver_name);
496  }
497  return SDL_SetError("No available video device");
498  }
499  _this = video;
500  _this->name = bootstrap[i]->name;
501  _this->next_object_id = 1;
502 
503 
504  /* Set some very sane GL defaults */
508 
511 
512  /* Initialize the video subsystem */
513  if (_this->VideoInit(_this) < 0) {
514  SDL_VideoQuit();
515  return -1;
516  }
517 
518  /* Make sure some displays were added */
519  if (_this->num_displays == 0) {
520  SDL_VideoQuit();
521  return SDL_SetError("The video driver did not add any displays");
522  }
523 
524  /* Add the renderer framebuffer emulation if desired */
529  }
530 
531  /* Disable the screen saver by default. This is a change from <= 2.0.1,
532  but most things using SDL are games or media players; you wouldn't
533  want a screensaver to trigger if you're playing exclusively with a
534  joystick, or passively watching a movie. Things that use SDL but
535  function more like a normal desktop app should explicitly reenable the
536  screensaver. */
538  if (hint) {
539  allow_screensaver = SDL_atoi(hint) ? SDL_TRUE : SDL_FALSE;
540  } else {
541  allow_screensaver = SDL_FALSE;
542  }
543  if (!allow_screensaver) {
545  }
546 
547  /* If we don't use a screen keyboard, turn on text input by default,
548  otherwise programs that expect to get text events without enabling
549  UNICODE input won't get any events.
550 
551  Actually, come to think of it, you needed to call SDL_EnableUNICODE(1)
552  in SDL 1.2 before you got text input events. Hmm...
553  */
556  }
557 
558  /* We're ready to go! */
559  return 0;
560 }
void SDL_GL_ResetAttributes()
Reset all previously set OpenGL context attributes to their default values.
Definition: SDL_video.c:2740
const char * name
Definition: SDL_sysvideo.h:146
#define SDL_INIT_EVENTS
Definition: SDL.h:81
void SDL_VideoQuit(void)
Shuts down the video subsystem.
Definition: SDL_video.c:2532
SDL_TLSID current_glwin_tls
Definition: SDL_sysvideo.h:327
#define SDL_HINT_VIDEO_ALLOW_SCREENSAVER
A variable controlling whether the screensaver is enabled.
Definition: SDL_hints.h:153
#define SDL_GetHint
#define SDL_InitSubSystem
GLuint const GLchar * name
int SDL_KeyboardInit(void)
Definition: SDL_keyboard.c:554
#define SDL_strncasecmp
int SDL_MouseInit(void)
Definition: SDL_mouse.c:45
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
SDL_bool
Definition: SDL_stdinc.h:126
static int SDL_UpdateWindowTexture(SDL_VideoDevice *unused, SDL_Window *window, const SDL_Rect *rects, int numrects)
Definition: SDL_video.c:348
#define SDL_TLSCreate
static int SDL_CreateWindowTexture(SDL_VideoDevice *unused, SDL_Window *window, Uint32 *format, void **pixels, int *pitch)
Definition: SDL_video.c:245
static void SDL_DestroyWindowTexture(SDL_VideoDevice *unused, SDL_Window *window)
Definition: SDL_video.c:378
#define SDL_atoi
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:3397
#define SDL_getenv
void(* DestroyWindowFramebuffer)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:217
struct SDL_VideoDevice::@27 gl_config
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:42
#define NULL
Definition: begin_code.h:143
#define SDL_SetError
static SDL_bool ShouldUseTextureFramebuffer()
Definition: SDL_video.c:160
#define SDL_strlen
SDL_TLSID current_glctx_tls
Definition: SDL_sysvideo.h:328
SDL_VideoDevice *(* create)(int devindex)
Definition: SDL_sysvideo.h:353
static VideoBootStrap * bootstrap[]
Definition: SDL_video.c:59
const char * name
Definition: SDL_sysvideo.h:350
void SDL_TicksInit(void)
int(* VideoInit)(_THIS)
Definition: SDL_sysvideo.h:155
int(* UpdateWindowFramebuffer)(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects)
Definition: SDL_sysvideo.h:216
Uint32 next_object_id
Definition: SDL_sysvideo.h:284
SDL_bool SDL_HasScreenKeyboardSupport(void)
Returns whether the platform has some screen keyboard support.
Definition: SDL_video.c:3453
int(* CreateWindowFramebuffer)(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch)
Definition: SDL_sysvideo.h:215
int SDL_TouchInit(void)
Definition: SDL_touch.c:36
void SDL_DisableScreenSaver()
Prevent the screen from being blanked by a screensaver.
Definition: SDL_video.c:2517
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 2532 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().

2533 {
2534  int i, j;
2535 
2536  if (!_this) {
2537  return;
2538  }
2539 
2540  /* Halt event processing before doing anything else */
2541  SDL_TouchQuit();
2542  SDL_MouseQuit();
2543  SDL_KeyboardQuit();
2545 
2547 
2548  /* Clean up the system video */
2549  while (_this->windows) {
2551  }
2552  _this->VideoQuit(_this);
2553 
2554  for (i = 0; i < _this->num_displays; ++i) {
2555  SDL_VideoDisplay *display = &_this->displays[i];
2556  for (j = display->num_display_modes; j--;) {
2557  SDL_free(display->display_modes[j].driverdata);
2558  display->display_modes[j].driverdata = NULL;
2559  }
2560  SDL_free(display->display_modes);
2561  display->display_modes = NULL;
2562  SDL_free(display->desktop_mode.driverdata);
2563  display->desktop_mode.driverdata = NULL;
2564  SDL_free(display->driverdata);
2565  display->driverdata = NULL;
2566  }
2567  if (_this->displays) {
2568  for (i = 0; i < _this->num_displays; ++i) {
2569  SDL_free(_this->displays[i].name);
2570  }
2572  _this->displays = NULL;
2573  _this->num_displays = 0;
2574  }
2577  _this->free(_this);
2578  _this = NULL;
2579 }
#define SDL_INIT_EVENTS
Definition: SDL.h:81
void(* free)(_THIS)
Definition: SDL_sysvideo.h:345
#define SDL_QuitSubSystem
void SDL_MouseQuit(void)
Definition: SDL_mouse.c:435
static SDL_VideoDevice * _this
Definition: SDL_video.c:114
void SDL_free(void *mem)
void * driverdata
Definition: SDL_video.h:59
void SDL_DestroyWindow(SDL_Window *window)
Destroy a window.
Definition: SDL_video.c:2419
SDL_DisplayMode * display_modes
Definition: SDL_sysvideo.h:125
SDL_VideoDisplay * displays
Definition: SDL_sysvideo.h:280
SDL_Window * windows
Definition: SDL_sysvideo.h:281
void SDL_KeyboardQuit(void)
Definition: SDL_keyboard.c:817
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:42
#define NULL
Definition: begin_code.h:143
SDL_DisplayMode desktop_mode
Definition: SDL_sysvideo.h:126
void(* VideoQuit)(_THIS)
Definition: SDL_sysvideo.h:161
void SDL_EnableScreenSaver()
Allow the screen to be blanked by a screensaver.
Definition: SDL_video.c:2502
void SDL_TouchQuit(void)
Definition: SDL_touch.c:352
char * clipboard_text
Definition: SDL_sysvideo.h:285
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:42