SDL3pp
A slim C++ wrapper for SDL3
|
SDL's video subsystem is largely interested in abstracting window management from the underlying operating system. More...
Classes | |
struct | SDL::WindowParam |
Safely wrap Window for non owning parameters. More... | |
struct | SDL::GLContextParam |
Safely wrap GLContext for non owning parameters. More... | |
class | SDL::Display |
This is a unique ID for a display for the time it is connected to the system, and is never reused for the lifetime of the application. More... | |
class | SDL::Window |
The struct used as an opaque handle to a window. More... | |
struct | SDL::WindowRef |
Semi-safe reference for Window. More... | |
class | SDL::GLContext |
An opaque handle to an OpenGL context. More... | |
struct | SDL::GLContextScoped |
RAII owning version GLContext. More... | |
Macros | |
#define | SDL_WINDOWPOS_UNDEFINED_MASK 0x1FFF0000u |
A magic value used with SDL_WINDOWPOS_UNDEFINED. More... | |
#define | SDL_WINDOWPOS_UNDEFINED_DISPLAY(X) (SDL_WINDOWPOS_UNDEFINED_MASK | (X)) |
Used to indicate that you don't care what the window position is. More... | |
#define | SDL_WINDOWPOS_UNDEFINED SDL_WINDOWPOS_UNDEFINED_DISPLAY(0) |
Used to indicate that you don't care what the window position/display is. More... | |
#define | SDL_WINDOWPOS_ISUNDEFINED(X) (((X) & 0xFFFF0000) == SDL_WINDOWPOS_UNDEFINED_MASK) |
A macro to test if the window position is marked as "undefined.". More... | |
#define | SDL_WINDOWPOS_CENTERED_MASK 0x2FFF0000u |
A magic value used with SDL_WINDOWPOS_CENTERED. More... | |
#define | SDL_WINDOWPOS_CENTERED_DISPLAY(X) (SDL_WINDOWPOS_CENTERED_MASK | (X)) |
Used to indicate that the window position should be centered. More... | |
#define | SDL_WINDOWPOS_CENTERED SDL_WINDOWPOS_CENTERED_DISPLAY(0) |
Used to indicate that the window position should be centered. More... | |
#define | SDL_WINDOWPOS_ISCENTERED(X) (((X) & 0xFFFF0000) == SDL_WINDOWPOS_CENTERED_MASK) |
A macro to test if the window position is marked as "centered.". More... | |
Typedefs | |
using | SDL::DisplayID = SDL_DisplayID |
Alias to raw representation for Display. | |
using | SDL::WindowRaw = SDL_Window * |
Alias to raw representation for Window. | |
using | SDL::GLContextRaw = SDL_GLContext |
Alias to raw representation for GLContext. | |
using | SDL::DisplayOrientation = SDL_DisplayOrientation |
Display orientation values; the way a display is rotated. More... | |
using | SDL::DisplayMode = SDL_DisplayMode |
The structure that defines a display mode. More... | |
using | SDL::WindowID = SDL_WindowID |
This is a unique ID for a window. More... | |
using | SDL::SystemTheme = SDL_SystemTheme |
System theme. More... | |
using | SDL::DisplayModeData = SDL_DisplayModeData |
Internal display mode data. More... | |
using | SDL::WindowFlags = Uint64 |
The flags on a window. More... | |
using | SDL::FlashOperation = SDL_FlashOperation |
Window flash operation. More... | |
using | SDL::HitTestResult = SDL_HitTestResult |
Possible return values from the HitTest callback. More... | |
using | SDL::HitTest = SDL_HitTest |
Callback used for hit-testing. More... | |
using | SDL::HitTestCB = std::function< HitTestResult(WindowRaw window, const Point &area)> |
Callback used for hit-testing. More... | |
using | SDL::EGLDisplay = SDL_EGLDisplay |
Opaque type for an EGL display. More... | |
using | SDL::EGLConfig = SDL_EGLConfig |
Opaque type for an EGL config. More... | |
using | SDL::EGLSurface = SDL_EGLSurface |
Opaque type for an EGL surface. More... | |
using | SDL::EGLAttrib = SDL_EGLAttrib |
An EGL attribute, used when creating an EGL context. More... | |
using | SDL::EGLint = SDL_EGLint |
An EGL integer attribute, used when creating an EGL surface. More... | |
using | SDL::EGLAttribArrayCallback = SDL_EGLAttribArrayCallback |
EGL platform attribute initialization callback. More... | |
using | SDL::EGLAttribArrayCB = std::function< SDL_EGLAttrib *()> |
EGL platform attribute initialization callback. More... | |
using | SDL::EGLIntArrayCallback = SDL_EGLIntArrayCallback |
EGL surface/context attribute initialization callback types. More... | |
using | SDL::EGLIntArrayCB = std::function< SDL_EGLint *(SDL_EGLDisplay, SDL_EGLConfig)> |
EGL surface/context attribute initialization callback types. More... | |
using | SDL::GLAttr = SDL_GLAttr |
An enumeration of OpenGL configuration attributes. More... | |
using | SDL::GLProfile = Uint32 |
Possible values to be set for the GL_CONTEXT_PROFILE_MASK attribute. More... | |
using | SDL::GLContextFlag = Uint32 |
Possible flags to be set for the GL_CONTEXT_FLAGS attribute. More... | |
using | SDL::GLContextReleaseFlag = Uint32 |
Possible values to be set for the GL_CONTEXT_RELEASE_BEHAVIOR attribute. More... | |
using | SDL::GLContextResetNotification = Uint32 |
Possible values to be set GL_CONTEXT_RESET_NOTIFICATION attribute. More... | |
Functions | |
int | SDL::GetNumVideoDrivers () |
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... | |
const char * | SDL::GetCurrentVideoDriver () |
Get the name of the currently initialized video driver. More... | |
SystemTheme | SDL::GetSystemTheme () |
Get the current system theme. More... | |
OwnArray< DisplayID > | SDL::GetDisplays () |
Get a list of currently connected displays. More... | |
Display | SDL::GetPrimaryDisplay () |
Return the primary display. More... | |
PropertiesRef | SDL::GetDisplayProperties (DisplayID displayID) |
Get the properties associated with a display. More... | |
const char * | SDL::GetDisplayName (DisplayID displayID) |
Get the name of a display in UTF-8 encoding. More... | |
Rect | SDL::GetDisplayBounds (DisplayID displayID) |
Get the desktop area represented by a display. More... | |
Rect | SDL::GetDisplayUsableBounds (DisplayID displayID) |
Get the usable desktop area represented by a display, in screen coordinates. More... | |
DisplayOrientation | SDL::GetNaturalDisplayOrientation (DisplayID displayID) |
Get the orientation of a display when it is unrotated. More... | |
DisplayOrientation | SDL::GetCurrentDisplayOrientation (DisplayID displayID) |
Get the orientation of a display. More... | |
float | SDL::GetDisplayContentScale (DisplayID displayID) |
Get the content scale of a display. More... | |
OwnArray< DisplayMode * > | SDL::GetFullscreenDisplayModes (DisplayID displayID) |
Get a list of fullscreen display modes available on a display. More... | |
DisplayMode | SDL::GetClosestFullscreenDisplayMode (DisplayID displayID, const PointRaw &size, float refresh_rate, bool include_high_density_modes) |
Get the closest match to the requested display mode. More... | |
const DisplayMode & | SDL::GetDesktopDisplayMode (DisplayID displayID) |
Get information about the desktop's display mode. More... | |
const DisplayMode & | SDL::GetCurrentDisplayMode (DisplayID displayID) |
Get information about the current display mode. More... | |
Display | SDL::GetDisplayForPoint (const PointRaw &point) |
Get the display containing a point. More... | |
Display | SDL::GetDisplayForRect (const RectRaw &rect) |
Get the display primarily containing a rect. More... | |
Display | SDL::GetDisplayForWindow (WindowParam window) |
Get the display associated with a window. More... | |
float | SDL::GetWindowPixelDensity (WindowParam window) |
Get the pixel density of a window. More... | |
float | SDL::GetWindowDisplayScale (WindowParam window) |
Get the content display scale relative to a window's pixel size. More... | |
void | SDL::SetWindowFullscreenMode (WindowParam window, OptionalRef< const DisplayMode > mode) |
Set the display mode to use when a window is visible and fullscreen. More... | |
const DisplayMode & | SDL::GetWindowFullscreenMode (WindowParam window) |
Query the display mode to use when a window is visible at fullscreen. More... | |
OwnPtr< void > | SDL::GetWindowICCProfile (WindowParam window) |
Get the raw ICC profile data for the screen the window is currently on. More... | |
PixelFormat | SDL::GetWindowPixelFormat (WindowParam window) |
Get the pixel format associated with the window. More... | |
OwnArray< WindowRef > | SDL::GetWindows () |
Get a list of valid windows. More... | |
Window | SDL::CreateWindow (StringParam title, const PointRaw &size, WindowFlags flags) |
Create a window with the specified dimensions and flags. More... | |
Window | SDL::CreatePopupWindow (WindowParam parent, const PointRaw &offset, const PointRaw &size, WindowFlags flags) |
Create a child popup window of the specified parent window. More... | |
Window | SDL::CreateWindowWithProperties (PropertiesParam props) |
Create a window with the specified properties. More... | |
WindowID | SDL::GetWindowID (WindowParam window) |
Get the numeric ID of a window. More... | |
WindowRef | SDL::GetWindowFromID (WindowID id) |
Get a window from a stored ID. More... | |
WindowRef | SDL::GetWindowParent (WindowParam window) |
Get parent of a window. More... | |
PropertiesRef | SDL::GetWindowProperties (WindowParam window) |
Get the properties associated with a window. More... | |
WindowFlags | SDL::GetWindowFlags (WindowParam window) |
Get the window flags. More... | |
void | SDL::SetWindowTitle (WindowParam window, StringParam title) |
Set the title of a window. More... | |
const char * | SDL::GetWindowTitle (WindowParam window) |
Get the title of a window. More... | |
void | SDL::SetWindowIcon (WindowParam window, SurfaceParam icon) |
Set the icon for a window. More... | |
void | SDL::SetWindowPosition (WindowParam window, const PointRaw &p) |
Request that the window's position be set. More... | |
void | SDL::GetWindowPosition (WindowParam window, int *x, int *y) |
Get the position of a window. More... | |
void | SDL::SetWindowSize (WindowParam window, const PointRaw &p) |
Request that the size of a window's client area be set. More... | |
void | SDL::GetWindowSize (WindowParam window, int *w, int *h) |
Get the size of a window's client area. More... | |
Rect | SDL::GetWindowSafeArea (WindowParam window) |
Get the safe area for this window. More... | |
void | SDL::SetWindowAspectRatio (WindowParam window, float min_aspect, float max_aspect) |
Request that the aspect ratio of a window's client area be set. More... | |
void | SDL::GetWindowAspectRatio (WindowParam window, float *min_aspect, float *max_aspect) |
Get the size of a window's client area. More... | |
void | SDL::GetWindowBordersSize (WindowParam window, int *top, int *left, int *bottom, int *right) |
Get the size of a window's borders (decorations) around the client area. More... | |
void | SDL::GetWindowSizeInPixels (WindowParam window, int *w, int *h) |
Get the size of a window's client area, in pixels. More... | |
void | SDL::SetWindowMinimumSize (WindowParam window, const PointRaw &p) |
Set the minimum size of a window's client area. More... | |
void | SDL::GetWindowMinimumSize (WindowParam window, int *w, int *h) |
Get the minimum size of a window's client area. More... | |
void | SDL::SetWindowMaximumSize (WindowParam window, const PointRaw &p) |
Set the maximum size of a window's client area. More... | |
void | SDL::GetWindowMaximumSize (WindowParam window, int *w, int *h) |
Get the maximum size of a window's client area. More... | |
void | SDL::SetWindowBordered (WindowParam window, bool bordered) |
Set the border state of a window. More... | |
void | SDL::SetWindowResizable (WindowParam window, bool resizable) |
Set the user-resizable state of a window. More... | |
void | SDL::SetWindowAlwaysOnTop (WindowParam window, bool on_top) |
Set the window to always be above the others. More... | |
void | SDL::ShowWindow (WindowParam window) |
Show a window. More... | |
void | SDL::HideWindow (WindowParam window) |
Hide a window. More... | |
void | SDL::RaiseWindow (WindowParam window) |
Request that a window be raised above other windows and gain the input focus. More... | |
void | SDL::MaximizeWindow (WindowParam window) |
Request that the window be made as large as possible. More... | |
void | SDL::MinimizeWindow (WindowParam window) |
Request that the window be minimized to an iconic representation. More... | |
void | SDL::RestoreWindow (WindowParam window) |
Request that the size and position of a minimized or maximized window be restored. More... | |
void | SDL::SetWindowFullscreen (WindowParam window, bool fullscreen) |
Request that the window's fullscreen state be changed. More... | |
void | SDL::SyncWindow (WindowParam window) |
Block until any pending window state is finalized. More... | |
bool | SDL::WindowHasSurface (WindowParam window) |
Return whether the window has a surface associated with it. More... | |
Surface | SDL::GetWindowSurface (WindowParam window) |
Get the SDL surface associated with the window. More... | |
void | SDL::SetWindowSurfaceVSync (WindowParam window, int vsync) |
Toggle VSync for the window surface. More... | |
int | SDL::GetWindowSurfaceVSync (WindowParam window) |
Get VSync for the window surface. More... | |
void | SDL::UpdateWindowSurface (WindowParam window) |
Copy the window surface to the screen. More... | |
void | SDL::UpdateWindowSurfaceRects (WindowParam window, SpanRef< const RectRaw > rects) |
Copy areas of the window surface to the screen. More... | |
void | SDL::DestroyWindowSurface (WindowParam window) |
Destroy the surface associated with the window. More... | |
void | SDL::SetWindowKeyboardGrab (WindowParam window, bool grabbed) |
Set a window's keyboard grab mode. More... | |
void | SDL::SetWindowMouseGrab (WindowParam window, bool grabbed) |
Set a window's mouse grab mode. More... | |
bool | SDL::GetWindowKeyboardGrab (WindowParam window) |
Get a window's keyboard grab mode. More... | |
bool | SDL::GetWindowMouseGrab (WindowParam window) |
Get a window's mouse grab mode. More... | |
WindowRef | SDL::GetGrabbedWindow () |
Get the window that currently has an input grab enabled. More... | |
void | SDL::SetWindowMouseRect (WindowParam window, const RectRaw &rect) |
Confines the cursor to the specified area of a window. More... | |
const RectRaw * | SDL::GetWindowMouseRect (WindowParam window) |
Get the mouse confinement rectangle of a window. More... | |
void | SDL::SetWindowOpacity (WindowParam window, float opacity) |
Set the opacity for a window. More... | |
float | SDL::GetWindowOpacity (WindowParam window) |
Get the opacity of a window. More... | |
void | SDL::SetWindowParent (WindowParam window, WindowParam parent) |
Set the window as a child of a parent window. More... | |
void | SDL::SetWindowModal (WindowParam window, bool modal) |
Toggle the state of the window as modal. More... | |
void | SDL::SetWindowFocusable (WindowParam window, bool focusable) |
Set whether the window may have input focus. More... | |
void | SDL::ShowWindowSystemMenu (WindowParam window, const PointRaw &p) |
Display the system-level window menu. More... | |
void | SDL::SetWindowHitTest (WindowParam window, HitTest callback, void *callback_data) |
Provide a callback that decides if a window region has special properties. More... | |
void | SDL::SetWindowHitTest (WindowParam window, HitTestCB callback) |
Provide a callback that decides if a window region has special properties. More... | |
void | SDL::SetWindowShape (WindowParam window, SurfaceParam shape) |
Set the shape of a transparent window. More... | |
void | SDL::FlashWindow (WindowParam window, FlashOperation operation) |
Request a window to demand attention from the user. More... | |
void | SDL::DestroyWindow (WindowRaw window) |
Destroy a window. More... | |
bool | SDL::ScreenSaverEnabled () |
Check whether the screensaver is currently enabled. More... | |
void | SDL::EnableScreenSaver () |
Allow the screen to be blanked by a screen saver. More... | |
void | SDL::DisableScreenSaver () |
Prevent the screen from being blanked by a screen saver. More... | |
void | SDL::GL_LoadLibrary (StringParam path) |
Dynamically load an OpenGL library. More... | |
FunctionPointer | SDL::GL_GetProcAddress (StringParam proc) |
Get an OpenGL function by name. More... | |
FunctionPointer | SDL::EGL_GetProcAddress (StringParam proc) |
Get an EGL library function by name. More... | |
void | SDL::GL_UnloadLibrary () |
Unload the OpenGL library previously loaded by GL_LoadLibrary(). More... | |
bool | SDL::GL_ExtensionSupported (StringParam extension) |
Check if an OpenGL extension is supported for the current context. More... | |
void | SDL::GL_ResetAttributes () |
Reset all previously set OpenGL context attributes to their default values. More... | |
void | SDL::GL_SetAttribute (GLAttr attr, int value) |
Set an OpenGL window attribute before window creation. More... | |
void | SDL::GL_GetAttribute (GLAttr attr, int *value) |
Get the actual value for an attribute from the current context. More... | |
GLContext | SDL::GL_CreateContext (WindowParam window) |
Create an OpenGL context for an OpenGL window, and make it current. More... | |
void | SDL::GL_MakeCurrent (WindowParam window, GLContext context) |
Set up an OpenGL context for rendering into an OpenGL window. More... | |
WindowRef | SDL::GL_GetCurrentWindow () |
Get the currently active OpenGL window. More... | |
GLContext | SDL::GL_GetCurrentContext () |
Get the currently active OpenGL context. More... | |
EGLDisplay | SDL::EGL_GetCurrentDisplay () |
Get the currently active EGL display. More... | |
EGLConfig | SDL::EGL_GetCurrentConfig () |
Get the currently active EGL config. More... | |
EGLSurface | SDL::EGL_GetWindowSurface (WindowParam window) |
Get the EGL surface associated with the window. More... | |
void | SDL::EGL_SetAttributeCallbacks (EGLAttribArrayCallback platformAttribCallback, EGLIntArrayCallback surfaceAttribCallback, EGLIntArrayCallback contextAttribCallback, void *userdata) |
Sets the callbacks for defining custom EGLAttrib arrays for EGL initialization. More... | |
void | SDL::GL_SetSwapInterval (int interval) |
Set the swap interval for the current OpenGL context. More... | |
void | SDL::GL_GetSwapInterval (int *interval) |
Get the swap interval for the current OpenGL context. More... | |
void | SDL::GL_SwapWindow (WindowParam window) |
Update a window with OpenGL rendering. More... | |
void | SDL::GL_DestroyContext (GLContextRaw context) |
Delete an OpenGL context. More... | |
static OwnArray< DisplayID > | SDL::Display::GetAll () |
Get a list of currently connected displays. More... | |
static Display | SDL::Display::GetPrimary () |
Return the primary display. More... | |
PropertiesRef | SDL::Display::GetProperties () const |
Get the properties associated with a display. More... | |
const char * | SDL::Display::GetName () const |
Get the name of a display in UTF-8 encoding. More... | |
Rect | SDL::Display::GetBounds () const |
Get the desktop area represented by a display. More... | |
Rect | SDL::Display::GetUsableBounds () const |
Get the usable desktop area represented by a display, in screen coordinates. More... | |
DisplayOrientation | SDL::Display::GetNaturalOrientation () const |
Get the orientation of a display when it is unrotated. More... | |
DisplayOrientation | SDL::Display::GetCurrentOrientation () const |
Get the orientation of a display. More... | |
float | SDL::Display::GetContentScale () const |
Get the content scale of a display. More... | |
OwnArray< DisplayMode * > | SDL::Display::GetFullscreenModes () const |
Get a list of fullscreen display modes available on a display. More... | |
DisplayMode | SDL::Display::GetClosestFullscreenMode (const PointRaw &size, float refresh_rate, bool include_high_density_modes) const |
Get the closest match to the requested display mode. More... | |
const DisplayMode & | SDL::Display::GetDesktopMode () const |
Get information about the desktop's display mode. More... | |
const DisplayMode & | SDL::Display::GetCurrentMode () const |
Get information about the current display mode. More... | |
static Display | SDL::Display::GetForPoint (const PointRaw &point) |
Get the display containing a point. More... | |
static Display | SDL::Display::GetForRect (const RectRaw &rect) |
Get the display primarily containing a rect. More... | |
Display | SDL::Window::GetDisplay () const |
Get the display associated with a window. More... | |
float | SDL::Window::GetPixelDensity () const |
Get the pixel density of a window. More... | |
float | SDL::Window::GetDisplayScale () const |
Get the content display scale relative to a window's pixel size. More... | |
void | SDL::Window::SetFullscreenMode (OptionalRef< const DisplayMode > mode) |
Set the display mode to use when a window is visible and fullscreen. More... | |
const DisplayMode & | SDL::Window::GetFullscreenMode () const |
Query the display mode to use when a window is visible at fullscreen. More... | |
OwnPtr< void > | SDL::Window::GetICCProfile () const |
Get the raw ICC profile data for the screen the window is currently on. More... | |
PixelFormat | SDL::Window::GetPixelFormat () const |
Get the pixel format associated with the window. More... | |
WindowID | SDL::Window::GetID () const |
Get the numeric ID of a window. More... | |
static WindowRef | SDL::Window::FromID (WindowID id) |
Get a window from a stored ID. More... | |
WindowRef | SDL::Window::GetParent () const |
Get parent of a window. More... | |
PropertiesRef | SDL::Window::GetProperties () const |
Get the properties associated with a window. More... | |
WindowFlags | SDL::Window::GetFlags () const |
Get the window flags. More... | |
void | SDL::Window::SetTitle (StringParam title) |
Set the title of a window. More... | |
const char * | SDL::Window::GetTitle () const |
Get the title of a window. More... | |
void | SDL::Window::SetIcon (SurfaceParam icon) |
Set the icon for a window. More... | |
void | SDL::Window::SetPosition (const PointRaw &p) |
Request that the window's position be set. More... | |
void | SDL::Window::GetPosition (int *x, int *y) const |
Get the position of a window. More... | |
void | SDL::Window::SetSize (const PointRaw &p) |
Request that the size of a window's client area be set. More... | |
void | SDL::Window::GetSize (int *w, int *h) const |
Get the size of a window's client area. More... | |
Rect | SDL::Window::GetSafeArea () const |
Get the safe area for this window. More... | |
void | SDL::Window::SetAspectRatio (float min_aspect, float max_aspect) |
Request that the aspect ratio of a window's client area be set. More... | |
void | SDL::Window::GetAspectRatio (float *min_aspect, float *max_aspect) const |
Get the size of a window's client area. More... | |
void | SDL::Window::GetBordersSize (int *top, int *left, int *bottom, int *right) const |
Get the size of a window's borders (decorations) around the client area. More... | |
void | SDL::Window::GetSizeInPixels (int *w, int *h) const |
Get the size of a window's client area, in pixels. More... | |
void | SDL::Window::SetMinimumSize (const PointRaw &p) |
Set the minimum size of a window's client area. More... | |
void | SDL::Window::GetMinimumSize (int *w, int *h) const |
Get the minimum size of a window's client area. More... | |
void | SDL::Window::SetMaximumSize (const PointRaw &p) |
Set the maximum size of a window's client area. More... | |
void | SDL::Window::GetMaximumSize (int *w, int *h) const |
Get the maximum size of a window's client area. More... | |
void | SDL::Window::SetBordered (bool bordered) |
Set the border state of a window. More... | |
void | SDL::Window::SetResizable (bool resizable) |
Set the user-resizable state of a window. More... | |
void | SDL::Window::SetAlwaysOnTop (bool on_top) |
Set the window to always be above the others. More... | |
void | SDL::Window::Show () |
Show a window. More... | |
void | SDL::Window::Hide () |
Hide a window. More... | |
void | SDL::Window::Raise () |
Request that a window be raised above other windows and gain the input focus. More... | |
void | SDL::Window::Maximize () |
Request that the window be made as large as possible. More... | |
void | SDL::Window::Minimize () |
Request that the window be minimized to an iconic representation. More... | |
void | SDL::Window::Restore () |
Request that the size and position of a minimized or maximized window be restored. More... | |
void | SDL::Window::SetFullscreen (bool fullscreen) |
Request that the window's fullscreen state be changed. More... | |
void | SDL::Window::Sync () |
Block until any pending window state is finalized. More... | |
bool | SDL::Window::HasSurface () const |
Return whether the window has a surface associated with it. More... | |
Surface | SDL::Window::GetSurface () |
Get the SDL surface associated with the window. More... | |
void | SDL::Window::SetSurfaceVSync (int vsync) |
Toggle VSync for the window surface. More... | |
int | SDL::Window::GetSurfaceVSync () const |
Get VSync for the window surface. More... | |
void | SDL::Window::UpdateSurface () |
Copy the window surface to the screen. More... | |
void | SDL::Window::UpdateSurfaceRects (SpanRef< const RectRaw > rects) |
Copy areas of the window surface to the screen. More... | |
void | SDL::Window::DestroySurface () |
Destroy the surface associated with the window. More... | |
void | SDL::Window::SetKeyboardGrab (bool grabbed) |
Set a window's keyboard grab mode. More... | |
void | SDL::Window::SetMouseGrab (bool grabbed) |
Set a window's mouse grab mode. More... | |
bool | SDL::Window::GetKeyboardGrab () const |
Get a window's keyboard grab mode. More... | |
bool | SDL::Window::GetMouseGrab () const |
Get a window's mouse grab mode. More... | |
static WindowRef | SDL::Window::GetGrabbed () |
Get the window that currently has an input grab enabled. More... | |
void | SDL::Window::SetMouseRect (const RectRaw &rect) |
Confines the cursor to the specified area of a window. More... | |
const RectRaw * | SDL::Window::GetMouseRect () const |
Get the mouse confinement rectangle of a window. More... | |
void | SDL::Window::SetOpacity (float opacity) |
Set the opacity for a window. More... | |
float | SDL::Window::GetOpacity () const |
Get the opacity of a window. More... | |
void | SDL::Window::SetParent (WindowParam parent) |
Set the window as a child of a parent window. More... | |
void | SDL::Window::SetModal (bool modal) |
Toggle the state of the window as modal. More... | |
void | SDL::Window::SetFocusable (bool focusable) |
Set whether the window may have input focus. More... | |
void | SDL::Window::ShowSystemMenu (const PointRaw &p) |
Display the system-level window menu. More... | |
void | SDL::Window::SetShape (SurfaceParam shape) |
Set the shape of a transparent window. More... | |
void | SDL::Window::Flash (FlashOperation operation) |
Request a window to demand attention from the user. More... | |
void | SDL::Window::Destroy () |
Destroy a window. More... | |
void | SDL::GLContext::MakeCurrent (WindowParam window) |
Set up an OpenGL context for rendering into an OpenGL window. More... | |
void | SDL::GLContext::Destroy () |
Delete an OpenGL context. More... | |
Variables | |
constexpr DisplayOrientation | SDL::ORIENTATION_UNKNOWN |
The display orientation can't be determined. More... | |
constexpr DisplayOrientation | SDL::ORIENTATION_LANDSCAPE = SDL_ORIENTATION_LANDSCAPE |
The display is in landscape mode, with the right side up, relative to portrait mode. | |
constexpr DisplayOrientation | SDL::ORIENTATION_LANDSCAPE_FLIPPED |
The display is in landscape mode, with the left side up, relative to portrait mode. More... | |
constexpr DisplayOrientation | SDL::ORIENTATION_PORTRAIT |
The display is in portrait mode. More... | |
constexpr DisplayOrientation | SDL::ORIENTATION_PORTRAIT_FLIPPED |
The display is in portrait mode, upside down. More... | |
constexpr SystemTheme | SDL::SYSTEM_THEME_UNKNOWN |
Unknown system theme. More... | |
constexpr SystemTheme | SDL::SYSTEM_THEME_LIGHT |
Light colored system theme. More... | |
constexpr SystemTheme | SDL::SYSTEM_THEME_DARK |
Dark colored system theme. More... | |
constexpr WindowFlags | SDL::WINDOW_FULLSCREEN |
window is in fullscreen mode More... | |
constexpr WindowFlags | SDL::WINDOW_OPENGL |
window usable with OpenGL context More... | |
constexpr WindowFlags | SDL::WINDOW_OCCLUDED |
window is occluded More... | |
constexpr WindowFlags | SDL::WINDOW_HIDDEN = SDL_WINDOW_HIDDEN |
window is neither mapped onto the desktop nor shown in the taskbar/dock/window list; Window.Show() is required for it to become visible | |
constexpr WindowFlags | SDL::WINDOW_BORDERLESS |
no window decoration More... | |
constexpr WindowFlags | SDL::WINDOW_RESIZABLE |
window can be resized More... | |
constexpr WindowFlags | SDL::WINDOW_MINIMIZED |
window is minimized More... | |
constexpr WindowFlags | SDL::WINDOW_MAXIMIZED |
window is maximized More... | |
constexpr WindowFlags | SDL::WINDOW_MOUSE_GRABBED |
window has grabbed mouse input More... | |
constexpr WindowFlags | SDL::WINDOW_INPUT_FOCUS |
window has input focus More... | |
constexpr WindowFlags | SDL::WINDOW_MOUSE_FOCUS |
window has mouse focus More... | |
constexpr WindowFlags | SDL::WINDOW_EXTERNAL |
window not created by SDL More... | |
constexpr WindowFlags | SDL::WINDOW_MODAL = SDL_WINDOW_MODAL |
window is modal | |
constexpr WindowFlags | SDL::WINDOW_HIGH_PIXEL_DENSITY = SDL_WINDOW_HIGH_PIXEL_DENSITY |
window uses high pixel density back buffer if possible | |
constexpr WindowFlags | SDL::WINDOW_MOUSE_CAPTURE = SDL_WINDOW_MOUSE_CAPTURE |
window has mouse captured (unrelated to MOUSE_GRABBED) | |
constexpr WindowFlags | SDL::WINDOW_MOUSE_RELATIVE_MODE |
window has relative mode enabled More... | |
constexpr WindowFlags | SDL::WINDOW_ALWAYS_ON_TOP |
window should always be above others More... | |
constexpr WindowFlags | SDL::WINDOW_UTILITY = SDL_WINDOW_UTILITY |
window should be treated as a utility window, not showing in the task bar and window list | |
constexpr WindowFlags | SDL::WINDOW_TOOLTIP = SDL_WINDOW_TOOLTIP |
window should be treated as a tooltip and does not get mouse or keyboard focus, requires a parent window | |
constexpr WindowFlags | SDL::WINDOW_POPUP_MENU = SDL_WINDOW_POPUP_MENU |
window should be treated as a popup menu, requires a parent window | |
constexpr WindowFlags | SDL::WINDOW_KEYBOARD_GRABBED |
window has grabbed keyboard input More... | |
constexpr WindowFlags | SDL::WINDOW_VULKAN |
window usable for Vulkan surface More... | |
constexpr WindowFlags | SDL::WINDOW_METAL |
window usable for Metal view More... | |
constexpr WindowFlags | SDL::WINDOW_TRANSPARENT |
window with transparent buffer More... | |
constexpr WindowFlags | SDL::WINDOW_NOT_FOCUSABLE |
window should not be focusable More... | |
constexpr FlashOperation | SDL::FLASH_CANCEL |
Cancel any window flash state. More... | |
constexpr FlashOperation | SDL::FLASH_BRIEFLY |
Flash the window briefly to get attention. More... | |
constexpr FlashOperation | SDL::FLASH_UNTIL_FOCUSED |
Flash the window until it gets focus. More... | |
constexpr HitTestResult | SDL::HITTEST_NORMAL |
Region is normal. No special properties. More... | |
constexpr HitTestResult | SDL::HITTEST_DRAGGABLE |
Region can drag entire window. More... | |
constexpr HitTestResult | SDL::HITTEST_RESIZE_TOPLEFT |
Region is the resizable top-left corner border. More... | |
constexpr HitTestResult | SDL::HITTEST_RESIZE_TOP |
Region is the resizable top border. More... | |
constexpr HitTestResult | SDL::HITTEST_RESIZE_TOPRIGHT |
Region is the resizable top-right corner border. More... | |
constexpr HitTestResult | SDL::HITTEST_RESIZE_RIGHT |
Region is the resizable right border. More... | |
constexpr HitTestResult | SDL::HITTEST_RESIZE_BOTTOMRIGHT |
Region is the resizable bottom-right corner border. More... | |
constexpr HitTestResult | SDL::HITTEST_RESIZE_BOTTOM |
Region is the resizable bottom border. More... | |
constexpr HitTestResult | SDL::HITTEST_RESIZE_BOTTOMLEFT |
Region is the resizable bottom-left corner border. More... | |
constexpr HitTestResult | SDL::HITTEST_RESIZE_LEFT |
Region is the resizable left border. More... | |
constexpr GLAttr | SDL::GL_RED_SIZE = SDL_GL_RED_SIZE |
the minimum number of bits for the red channel of the color buffer; defaults to 8. | |
constexpr GLAttr | SDL::GL_GREEN_SIZE = SDL_GL_GREEN_SIZE |
the minimum number of bits for the green channel of the color buffer; defaults to 8. | |
constexpr GLAttr | SDL::GL_BLUE_SIZE = SDL_GL_BLUE_SIZE |
the minimum number of bits for the blue channel of the color buffer; defaults to 8. | |
constexpr GLAttr | SDL::GL_ALPHA_SIZE = SDL_GL_ALPHA_SIZE |
the minimum number of bits for the alpha channel of the color buffer; defaults to 8. | |
constexpr GLAttr | SDL::GL_BUFFER_SIZE = SDL_GL_BUFFER_SIZE |
the minimum number of bits for frame buffer size; defaults to 0. | |
constexpr GLAttr | SDL::GL_DOUBLEBUFFER = SDL_GL_DOUBLEBUFFER |
whether the output is single or double buffered; defaults to double buffering on. | |
constexpr GLAttr | SDL::GL_DEPTH_SIZE = SDL_GL_DEPTH_SIZE |
the minimum number of bits in the depth buffer; defaults to 16. | |
constexpr GLAttr | SDL::GL_STENCIL_SIZE = SDL_GL_STENCIL_SIZE |
the minimum number of bits in the stencil buffer; defaults to 0. | |
constexpr GLAttr | SDL::GL_ACCUM_RED_SIZE = SDL_GL_ACCUM_RED_SIZE |
the minimum number of bits for the red channel of the accumulation buffer; defaults to 0. | |
constexpr GLAttr | SDL::GL_ACCUM_GREEN_SIZE = SDL_GL_ACCUM_GREEN_SIZE |
the minimum number of bits for the green channel of the accumulation buffer; defaults to 0. | |
constexpr GLAttr | SDL::GL_ACCUM_BLUE_SIZE = SDL_GL_ACCUM_BLUE_SIZE |
the minimum number of bits for the blue channel of the accumulation buffer; defaults to 0. | |
constexpr GLAttr | SDL::GL_ACCUM_ALPHA_SIZE = SDL_GL_ACCUM_ALPHA_SIZE |
the minimum number of bits for the alpha channel of the accumulation buffer; defaults to 0. | |
constexpr GLAttr | SDL::GL_STEREO |
whether the output is stereo 3D; defaults to off. More... | |
constexpr GLAttr | SDL::GL_MULTISAMPLEBUFFERS = SDL_GL_MULTISAMPLEBUFFERS |
the number of buffers used for multisample anti-aliasing; defaults to 0. | |
constexpr GLAttr | SDL::GL_MULTISAMPLESAMPLES = SDL_GL_MULTISAMPLESAMPLES |
the number of samples used around the current pixel used for multisample anti-aliasing. | |
constexpr GLAttr | SDL::GL_ACCELERATED_VISUAL = SDL_GL_ACCELERATED_VISUAL |
set to 1 to require hardware acceleration, set to 0 to force software rendering; defaults to allow either. | |
constexpr GLAttr | SDL::GL_RETAINED_BACKING |
not used (deprecated). More... | |
constexpr GLAttr | SDL::GL_CONTEXT_MAJOR_VERSION |
OpenGL context major version. More... | |
constexpr GLAttr | SDL::GL_CONTEXT_MINOR_VERSION |
OpenGL context minor version. More... | |
constexpr GLAttr | SDL::GL_CONTEXT_FLAGS = SDL_GL_CONTEXT_FLAGS |
some combination of 0 or more of elements of the GLContextFlag enumeration; defaults to 0. | |
constexpr GLAttr | SDL::GL_CONTEXT_PROFILE_MASK = SDL_GL_CONTEXT_PROFILE_MASK |
type of GL context (Core, Compatibility, ES). More... | |
constexpr GLAttr | SDL::GL_SHARE_WITH_CURRENT_CONTEXT |
OpenGL context sharing; defaults to 0. More... | |
constexpr GLAttr | SDL::GL_FRAMEBUFFER_SRGB_CAPABLE |
requests sRGB capable visual; defaults to 0. More... | |
constexpr GLAttr | SDL::GL_CONTEXT_RELEASE_BEHAVIOR = SDL_GL_CONTEXT_RELEASE_BEHAVIOR |
sets context the release behavior. More... | |
constexpr GLAttr | SDL::GL_CONTEXT_RESET_NOTIFICATION |
set context reset notification. More... | |
constexpr GLAttr | SDL::GL_CONTEXT_NO_ERROR |
GL_CONTEXT_NO_ERROR. More... | |
constexpr GLAttr | SDL::GL_FLOATBUFFERS = SDL_GL_FLOATBUFFERS |
GL_FLOATBUFFERS. | |
constexpr GLAttr | SDL::GL_EGL_PLATFORM = SDL_GL_EGL_PLATFORM |
GL_EGL_PLATFORM. | |
constexpr GLProfile | SDL::GL_CONTEXT_PROFILE_CORE |
OpenGL Core Profile context. More... | |
constexpr GLProfile | SDL::GL_CONTEXT_PROFILE_COMPATIBILITY |
OpenGL Compatibility Profile context. More... | |
constexpr GLProfile | SDL::GL_CONTEXT_PROFILE_ES |
GLX_CONTEXT_ES2_PROFILE_BIT_EXT. More... | |
constexpr GLContextFlag | SDL::GL_CONTEXT_DEBUG_FLAG |
DEBUG_FLAG. More... | |
constexpr GLContextFlag | SDL::GL_CONTEXT_FORWARD_COMPATIBLE_FLAG |
FORWARD_COMPATIBLE_FLAG. More... | |
constexpr GLContextFlag | SDL::GL_CONTEXT_ROBUST_ACCESS_FLAG |
ROBUST_ACCESS_FLAG. More... | |
constexpr GLContextFlag | SDL::GL_CONTEXT_RESET_ISOLATION_FLAG |
RESET_ISOLATION_FLAG. More... | |
constexpr GLContextReleaseFlag | SDL::GL_CONTEXT_RELEASE_BEHAVIOR_NONE |
BEHAVIOR_NONE. More... | |
constexpr GLContextReleaseFlag | SDL::GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH |
BEHAVIOR_FLUSH. More... | |
constexpr GLContextResetNotification | SDL::GL_CONTEXT_RESET_NO_NOTIFICATION |
NO_NOTIFICATION. More... | |
constexpr GLContextResetNotification | SDL::GL_CONTEXT_RESET_LOSE_CONTEXT |
LOSE_CONTEXT. More... | |
constexpr int | SDL::WINDOW_SURFACE_VSYNC_DISABLED = SDL_WINDOW_SURFACE_VSYNC_DISABLED |
Constant to disable vsync. | |
constexpr int | SDL::WINDOW_SURFACE_VSYNC_ADAPTIVE = SDL_WINDOW_SURFACE_VSYNC_ADAPTIVE |
Constant to enable adaptive vsync. | |
You can create windows, manage them in various ways, set them fullscreen, and get events when interesting things happen with them, such as the mouse or keyboard interacting with a window.
The video subsystem is also interested in abstracting away some platform-specific differences in OpenGL: context creation, swapping buffers, etc. This may be crucial to your app, but also you are not required to use OpenGL at all. In fact, SDL can provide rendering to those windows as well, either with an easy-to-use 2D API or with a more-powerful GPU API . Of course, it can simply get out of your way and give you the window handles you need to use Vulkan, Direct3D, Metal, or whatever else you like directly, too.
The video subsystem covers a lot of functionality, out of necessity, so it is worth perusing the list of functions just to see what's available, but most apps can get by with simply creating a window and listening for events, so start with Window.Window() and PollEvent().
#define SDL_WINDOWPOS_CENTERED SDL_WINDOWPOS_CENTERED_DISPLAY(0) |
This always uses the primary display.
#define SDL_WINDOWPOS_CENTERED_DISPLAY | ( | X | ) | (SDL_WINDOWPOS_CENTERED_MASK | (X)) |
SDL_WINDOWPOS_CENTERED is the same, but always uses the primary display instead of specifying one.
X | the Display of the display to use. |
#define SDL_WINDOWPOS_CENTERED_MASK 0x2FFF0000u |
Generally this macro isn't used directly, but rather through SDL_WINDOWPOS_CENTERED or SDL_WINDOWPOS_CENTERED_DISPLAY.
#define SDL_WINDOWPOS_ISCENTERED | ( | X | ) | (((X) & 0xFFFF0000) == SDL_WINDOWPOS_CENTERED_MASK) |
X | the window position value. |
#define SDL_WINDOWPOS_ISUNDEFINED | ( | X | ) | (((X) & 0xFFFF0000) == SDL_WINDOWPOS_UNDEFINED_MASK) |
X | the window position value. |
#define SDL_WINDOWPOS_UNDEFINED SDL_WINDOWPOS_UNDEFINED_DISPLAY(0) |
This always uses the primary display.
#define SDL_WINDOWPOS_UNDEFINED_DISPLAY | ( | X | ) | (SDL_WINDOWPOS_UNDEFINED_MASK | (X)) |
If you really don't care, SDL_WINDOWPOS_UNDEFINED is the same, but always uses the primary display instead of specifying one.
X | the Display of the display to use. |
#define SDL_WINDOWPOS_UNDEFINED_MASK 0x1FFF0000u |
Generally this macro isn't used directly, but rather through SDL_WINDOWPOS_UNDEFINED or SDL_WINDOWPOS_UNDEFINED_DISPLAY.
using SDL::DisplayMode = typedef SDL_DisplayMode |
using SDL::DisplayModeData = typedef SDL_DisplayModeData |
This lives as a field in DisplayMode, as opaque data.
using SDL::DisplayOrientation = typedef SDL_DisplayOrientation |
using SDL::EGLAttrib = typedef SDL_EGLAttrib |
using SDL::EGLAttribArrayCallback = typedef SDL_EGLAttribArrayCallback |
This is called when SDL is attempting to create an EGL context, to let the app add extra attributes to its eglGetPlatformDisplay() call.
The callback should return a pointer to an EGL attribute array terminated with EGL_NONE
. If this function returns nullptr, the Window.Window process will fail gracefully.
The returned pointer should be allocated with malloc() and will be passed to free().
The arrays returned by each callback will be appended to the existing attribute arrays defined by SDL.
userdata | an app-controlled pointer that is passed to the callback. |
EGL_NONE
.using SDL::EGLAttribArrayCB = typedef std::function<SDL_EGLAttrib*()> |
This is called when SDL is attempting to create an EGL context, to let the app add extra attributes to its eglGetPlatformDisplay() call.
The callback should return a pointer to an EGL attribute array terminated with EGL_NONE
. If this function returns nullptr, the Window.Window process will fail gracefully.
The returned pointer should be allocated with malloc() and will be passed to free().
The arrays returned by each callback will be appended to the existing attribute arrays defined by SDL.
userdata | an app-controlled pointer that is passed to the callback. |
EGL_NONE
.using SDL::EGLConfig = typedef SDL_EGLConfig |
using SDL::EGLDisplay = typedef SDL_EGLDisplay |
using SDL::EGLint = typedef SDL_EGLint |
using SDL::EGLIntArrayCallback = typedef SDL_EGLIntArrayCallback |
This is called when SDL is attempting to create an EGL surface, to let the app add extra attributes to its eglCreateWindowSurface() or eglCreateContext calls.
For convenience, the EGLDisplay and EGLConfig to use are provided to the callback.
The callback should return a pointer to an EGL attribute array terminated with EGL_NONE
. If this function returns nullptr, the Window.Window process will fail gracefully.
The returned pointer should be allocated with malloc() and will be passed to free().
The arrays returned by each callback will be appended to the existing attribute arrays defined by SDL.
userdata | an app-controlled pointer that is passed to the callback. |
display | the EGL display to be used. |
config | the EGL config to be used. |
EGL_NONE
.using SDL::EGLIntArrayCB = typedef std::function<SDL_EGLint*(SDL_EGLDisplay, SDL_EGLConfig)> |
This is called when SDL is attempting to create an EGL surface, to let the app add extra attributes to its eglCreateWindowSurface() or eglCreateContext calls.
For convenience, the EGLDisplay and EGLConfig to use are provided to the callback.
The callback should return a pointer to an EGL attribute array terminated with EGL_NONE
. If this function returns nullptr, the Window.Window process will fail gracefully.
The returned pointer should be allocated with malloc() and will be passed to free().
The arrays returned by each callback will be appended to the existing attribute arrays defined by SDL.
userdata | an app-controlled pointer that is passed to the callback. |
display | the EGL display to be used. |
config | the EGL config to be used. |
EGL_NONE
.using SDL::EGLSurface = typedef SDL_EGLSurface |
using SDL::FlashOperation = typedef SDL_FlashOperation |
using SDL::GLAttr = typedef SDL_GLAttr |
While you can set most OpenGL attributes normally, the attributes listed above must be known before SDL creates the window that will be used with the OpenGL context. These attributes are set and read with GL_SetAttribute() and GL_GetAttribute().
In some cases, these attributes are minimum requests; the GL does not promise to give you exactly what you asked for. It's possible to ask for a 16-bit depth buffer and get a 24-bit one instead, for example, or to ask for no stencil buffer and still have one available. Context creation should fail if the GL can't provide your requested attributes at a minimum, but you should check to see exactly what you got.
using SDL::GLContextFlag = typedef Uint32 |
using SDL::GLContextReleaseFlag = typedef Uint32 |
using SDL::GLContextResetNotification = typedef Uint32 |
using SDL::GLProfile = typedef Uint32 |
using SDL::HitTest = typedef SDL_HitTest |
win | the Window where hit-testing was set on. |
area | an Point which should be hit-tested. |
data | what was passed as callback_data to Window.SetHitTest(). |
using SDL::HitTestCB = typedef std::function<HitTestResult(WindowRaw window, const Point& area)> |
win | the WindowRef where hit-testing was set on. |
area | a Point const reference which should be hit-tested. |
using SDL::HitTestResult = typedef SDL_HitTestResult |
using SDL::SystemTheme = typedef SDL_SystemTheme |
using SDL::WindowFlags = typedef Uint64 |
These cover a lot of true/false, or on/off, window state. Some of it is immutable after being set through Window.Window(), some of it can be changed on existing windows by the app, and some of it might be altered by the user or system outside of the app's control.
using SDL::WindowID = typedef SDL_WindowID |
The value 0 is an invalid ID.
|
inline |
The window size is a request and may be different than expected based on the desktop layout and window manager policies. Your application should be prepared to handle a window of any size.
The flags parameter must contain at least one of the following:
WINDOW_TOOLTIP
: The popup window is a tooltip and will not pass any input events.WINDOW_POPUP_MENU
: The popup window is a popup menu. The topmost popup menu will implicitly gain the keyboard focus.The following flags are not relevant to popup window creation and will be ignored:
WINDOW_MINIMIZED
WINDOW_MAXIMIZED
WINDOW_FULLSCREEN
WINDOW_BORDERLESS
The following flags are incompatible with popup window creation and will cause it to fail:
WINDOW_UTILITY
WINDOW_MODAL
The parent parameter must be non-null and a valid window. The parent of a popup window can be either a regular, toplevel window, or another popup window.
Popup windows cannot be minimized, maximized, made fullscreen, raised, flash, be made a modal window, be the parent of a toplevel window, or grab the mouse and/or keyboard. Attempts to do so will fail.
Popup windows implicitly do not have a border/decorations and do not appear on the taskbar/dock or in lists of windows such as alt-tab menus.
By default, popup window positions will automatically be constrained to keep the entire window within display bounds. This can be overridden with the prop::Window.CREATE_CONSTRAIN_POPUP_BOOLEAN
property.
By default, popup menus will automatically grab keyboard focus from the parent when shown. This behavior can be overridden by setting the WINDOW_NOT_FOCUSABLE
flag, setting the prop::Window.CREATE_FOCUSABLE_BOOLEAN
property to false, or toggling it after creation via the Window.SetFocusable()
function.
If a parent window is hidden or destroyed, any child popup windows will be recursively hidden or destroyed as well. Child popup windows not explicitly hidden will be restored when the parent is shown.
parent | the parent of the window, must not be nullptr. |
offset | the x, y position of the popup window relative to the origin of the parent. |
size | the width and height of the window. |
flags | WINDOW_TOOLTIP or WINDOW_POPUP_MENU, and zero or more additional WindowFlags OR'd together. |
|
inline |
The window size is a request and may be different than expected based on the desktop layout and window manager policies. Your application should be prepared to handle a window of any size.
flags
may be any of the following OR'd together:
WINDOW_FULLSCREEN
: fullscreen window at desktop resolutionWINDOW_OPENGL
: window usable with an OpenGL contextWINDOW_OCCLUDED
: window partially or completely obscured by another windowWINDOW_HIDDEN
: window is not visibleWINDOW_BORDERLESS
: no window decorationWINDOW_RESIZABLE
: window can be resizedWINDOW_MINIMIZED
: window is minimizedWINDOW_MAXIMIZED
: window is maximizedWINDOW_MOUSE_GRABBED
: window has grabbed mouse focusWINDOW_INPUT_FOCUS
: window has input focusWINDOW_MOUSE_FOCUS
: window has mouse focusWINDOW_EXTERNAL
: window not created by SDLWINDOW_MODAL
: window is modalWINDOW_HIGH_PIXEL_DENSITY
: window uses high pixel density back buffer if possibleWINDOW_MOUSE_CAPTURE
: window has mouse captured (unrelated to MOUSE_GRABBED)WINDOW_ALWAYS_ON_TOP
: window should always be above othersWINDOW_UTILITY
: window should be treated as a utility window, not showing in the task bar and window listWINDOW_TOOLTIP
: window should be treated as a tooltip and does not get mouse or keyboard focus, requires a parent windowWINDOW_POPUP_MENU
: window should be treated as a popup menu, requires a parent windowWINDOW_KEYBOARD_GRABBED
: window has grabbed keyboard inputWINDOW_VULKAN
: window usable with a Vulkan instanceWINDOW_METAL
: window usable with a Metal instanceWINDOW_TRANSPARENT
: window with transparent bufferWINDOW_NOT_FOCUSABLE
: window should not be focusableThe Window is implicitly shown if WINDOW_HIDDEN is not set.
On Apple's macOS, you must set the NSHighResolutionCapable Info.plist property to YES, otherwise you will not receive a High-DPI OpenGL canvas.
The window pixel size may differ from its window coordinate size if the window is on a high pixel density display. Use Window.GetSize() to query the client area's size in window coordinates, and Window.GetSizeInPixels() or Renderer.GetOutputSize() to query the drawable size in pixels. Note that the drawable size can vary after the window is created and should be queried again if you get an EVENT_WINDOW_PIXEL_SIZE_CHANGED event.
If the window is created with any of the WINDOW_OPENGL or WINDOW_VULKAN flags, then the corresponding LoadLibrary function (GL_LoadLibrary or Vulkan_LoadLibrary) is called and the corresponding UnloadLibrary function is called by Window.Destroy().
If WINDOW_VULKAN is specified and there isn't a working Vulkan driver, Window.Window() will fail, because Vulkan_LoadLibrary() will fail.
If WINDOW_METAL is specified on an OS that does not support Metal, Window.Window() will fail.
If you intend to use this window with an Renderer, you should use CreateWindowAndRenderer() instead of this function, to avoid window flicker.
On non-Apple devices, SDL requires you to either not link to the Vulkan loader or link to a dynamic library version. This limitation may be removed in a future version of SDL.
title | the title of the window, in UTF-8 encoding. |
size | the width and height of the window. |
flags | 0, or one or more WindowFlags OR'd together. |
|
inline |
The window size is a request and may be different than expected based on the desktop layout and window manager policies. Your application should be prepared to handle a window of any size.
These are the supported properties:
prop::Window.CREATE_ALWAYS_ON_TOP_BOOLEAN
: true if the window should be always on topprop::Window.CREATE_BORDERLESS_BOOLEAN
: true if the window has no window decorationprop::Window.CREATE_CONSTRAIN_POPUP_BOOLEAN
: true if the "tooltip" and "menu" window types should be automatically constrained to be entirely within display bounds (default), false if no constraints on the position are desired.prop::Window.CREATE_EXTERNAL_GRAPHICS_CONTEXT_BOOLEAN
: true if the window will be used with an externally managed graphics context.prop::Window.CREATE_FOCUSABLE_BOOLEAN
: true if the window should accept keyboard input (defaults true)prop::Window.CREATE_FULLSCREEN_BOOLEAN
: true if the window should start in fullscreen mode at desktop resolutionprop::Window.CREATE_HEIGHT_NUMBER
: the height of the windowprop::Window.CREATE_HIDDEN_BOOLEAN
: true if the window should start hiddenprop::Window.CREATE_HIGH_PIXEL_DENSITY_BOOLEAN
: true if the window uses a high pixel density buffer if possibleprop::Window.CREATE_MAXIMIZED_BOOLEAN
: true if the window should start maximizedprop::Window.CREATE_MENU_BOOLEAN
: true if the window is a popup menuprop::Window.CREATE_METAL_BOOLEAN
: true if the window will be used with Metal renderingprop::Window.CREATE_MINIMIZED_BOOLEAN
: true if the window should start minimizedprop::Window.CREATE_MODAL_BOOLEAN
: true if the window is modal to its parentprop::Window.CREATE_MOUSE_GRABBED_BOOLEAN
: true if the window starts with grabbed mouse focusprop::Window.CREATE_OPENGL_BOOLEAN
: true if the window will be used with OpenGL renderingprop::Window.CREATE_PARENT_POINTER
: an Window that will be the parent of this window, required for windows with the "tooltip", "menu", and "modal" propertiesprop::Window.CREATE_RESIZABLE_BOOLEAN
: true if the window should be resizableprop::Window.CREATE_TITLE_STRING
: the title of the window, in UTF-8 encodingprop::Window.CREATE_TRANSPARENT_BOOLEAN
: true if the window show transparent in the areas with alpha of 0prop::Window.CREATE_TOOLTIP_BOOLEAN
: true if the window is a tooltipprop::Window.CREATE_UTILITY_BOOLEAN
: true if the window is a utility window, not showing in the task bar and window listprop::Window.CREATE_VULKAN_BOOLEAN
: true if the window will be used with Vulkan renderingprop::Window.CREATE_WIDTH_NUMBER
: the width of the windowprop::Window.CREATE_X_NUMBER
: the x position of the window, or SDL_WINDOWPOS_CENTERED
, defaults to SDL_WINDOWPOS_UNDEFINED
. This is relative to the parent for windows with the "tooltip" or "menu" property set.prop::Window.CREATE_Y_NUMBER
: the y position of the window, or SDL_WINDOWPOS_CENTERED
, defaults to SDL_WINDOWPOS_UNDEFINED
. This is relative to the parent for windows with the "tooltip" or "menu" property set.These are additional supported properties on macOS:
prop::Window.CREATE_COCOA_WINDOW_POINTER
: the (__unsafe_unretained)
NSWindow associated with the window, if you want to wrap an existing window.prop::Window.CREATE_COCOA_VIEW_POINTER
: the (__unsafe_unretained)
NSView associated with the window, defaults to [window contentView]
These are additional supported properties on Wayland:
prop::Window.CREATE_WAYLAND_SURFACE_ROLE_CUSTOM_BOOLEAN
- true if the application wants to use the Wayland surface for a custom role and does not want it attached to an XDG toplevel window. See README/wayland for more information on using custom surfaces.prop::Window.CREATE_WAYLAND_CREATE_EGL_WINDOW_BOOLEAN
- true if the application wants an associated wl_egl_window
object to be created and attached to the window, even if the window does not have the OpenGL property or WINDOW_OPENGL
flag set.prop::Window.CREATE_WAYLAND_WL_SURFACE_POINTER
- the wl_surface associated with the window, if you want to wrap an existing window. See README/wayland for more information.These are additional supported properties on Windows:
prop::Window.CREATE_WIN32_HWND_POINTER
: the HWND associated with the window, if you want to wrap an existing window.prop::Window.CREATE_WIN32_PIXEL_FORMAT_HWND_POINTER
: optional, another window to share pixel format with, useful for OpenGL windowsThese are additional supported properties with X11:
prop::Window.CREATE_X11_WINDOW_NUMBER
: the X11 Window associated with the window, if you want to wrap an existing window.The window is implicitly shown if the "hidden" property is not set.
Windows with the "tooltip" and "menu" properties are popup windows and have the behaviors and guidelines outlined in Window.Window().
If this window is being created to be used with an Renderer, you should not add a graphics API specific property (prop::Window.CREATE_OPENGL_BOOLEAN
, etc), as SDL will handle that internally when it chooses a renderer. However, SDL might need to recreate your window at that point, which may cause the window to appear briefly, and then flicker as it is recreated. The correct approach to this is to create the window with the prop::Window.CREATE_HIDDEN_BOOLEAN
property set to true, then create the renderer, then show the window with Window.Show().
props | the properties to use. |
|
inline |
Any child windows owned by the window will be recursively destroyed as well.
Note that on some platforms, the visible window may not actually be removed from the screen until the SDL event loop is pumped again, even though the Window is no longer valid after this call.
|
inline |
|
inline |
Error | on failure. |
|
inline |
Any child windows owned by the window will be recursively destroyed as well.
Note that on some platforms, the visible window may not actually be removed from the screen until the SDL event loop is pumped again, even though the Window is no longer valid after this call.
window | the window to destroy. |
|
inline |
window | the window to update. |
Error | on failure. |
|
inline |
If you disable the screensaver, it is automatically re-enabled when SDL quits.
The screensaver is disabled by default, but this may by changed by SDL_HINT_VIDEO_ALLOW_SCREENSAVER.
Error | on failure. |
|
inline |
|
inline |
|
inline |
If an EGL library is loaded, this function allows applications to get entry points for EGL functions. This is useful to provide to an EGL API and extension loader.
proc | the name of an EGL function. |
|
inline |
window | the window to query. |
|
inline |
Callbacks that aren't needed can be set to nullptr.
NOTE: These callback pointers will be reset after GL_ResetAttributes.
platformAttribCallback | callback for attributes to pass to eglGetPlatformDisplay. May be nullptr. |
surfaceAttribCallback | callback for attributes to pass to eglCreateSurface. May be nullptr. |
contextAttribCallback | callback for attributes to pass to eglCreateContext. May be nullptr. |
userdata | a pointer that is passed to the callbacks. |
|
inline |
Error | on failure. |
|
inline |
|
inline |
The numeric ID is what WindowEvent references, and is necessary to map these events to specific Window objects.
id | the ID of the window. |
id
or nullptr if it doesn't exist; call GetError() for more information.
|
inline |
min_aspect | a pointer filled in with the minimum aspect ratio of the window, may be nullptr. |
max_aspect | a pointer filled in with the maximum aspect ratio of the window, may be nullptr. |
Error | on failure. |
|
inline |
Note: If this function fails (returns false), the size values will be initialized to 0, 0, 0, 0 (if a non-nullptr pointer is provided), as if the window in question was borderless.
Note: This function may fail on systems where the window has not yet been decorated by the display server (for example, immediately after calling Window.Window). It is recommended that you wait at least until the window has been presented and composited, so that the window system has a chance to decorate the window and provide the border dimensions to SDL.
This function also returns false if getting the information is not supported.
(decorations) from.
top | pointer to variable for storing the size of the top border; nullptr is permitted. |
left | pointer to variable for storing the size of the left border; nullptr is permitted. |
bottom | pointer to variable for storing the size of the bottom border; nullptr is permitted. |
right | pointer to variable for storing the size of the right border; nullptr is permitted. |
Error | on failure. |
|
inline |
The primary display is often located at (0,0), but may be placed at a different location depending on monitor layout.
Error | on failure. |
|
inline |
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 set to 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 false is returned.
displayID | the instance ID of the display to query. |
size | the width and height in pixels of the desired display mode. |
refresh_rate | the refresh rate of the desired display mode, or 0.0f for the desktop refresh rate. |
include_high_density_modes | boolean to include high density modes in the search. |
Error | on failure. |
|
inline |
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 set to 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 false is returned.
size | the width and height in pixels of the desired display mode. |
refresh_rate | the refresh rate of the desired display mode, or 0.0f for the desktop refresh rate. |
include_high_density_modes | boolean to include high density modes in the search. |
Error | on failure. |
|
inline |
The content scale is the expected scale for content based on the DPI settings of the display. For example, a 4K display might have a 2.0 (200%) display scale, which means that the user expects UI elements to be twice as big on this display, to aid in readability.
After window creation, Window.GetDisplayScale() should be used to query the content scale factor for individual windows instead of querying the display for a window and calling this function, as the per-window content scale factor may differ from the base value of the display it is on, particularly on high-DPI and/or multi-monitor desktop configurations.
|
inline |
There's a difference between this function and Display.GetDesktopMode() when SDL runs fullscreen and has changed the resolution. In that case this function will return the current display mode, and not the previous native display mode.
displayID | the instance ID of the display to query. |
|
inline |
displayID | the instance ID of the display to query. |
ORIENTATION_UNKNOWN
if it isn't available.
|
inline |
There's a difference between this function and Display.GetDesktopMode() when SDL runs fullscreen and has changed the resolution. In that case this function will return the current display mode, and not the previous native display mode.
|
inline |
ORIENTATION_UNKNOWN
if it isn't available.
|
inline |
The names of drivers are all simple, low-ASCII identifiers, like "cocoa", "x11" or "windows". These never have Unicode characters, and are not meant to be proper names.
|
inline |
There's a difference between this function and Display.GetCurrentMode() when SDL runs fullscreen and has changed the resolution. In that case this function will return the previous native display mode, and not the current display mode.
displayID | the instance ID of the display to query. |
|
inline |
There's a difference between this function and Display.GetCurrentMode() when SDL runs fullscreen and has changed the resolution. In that case this function will return the previous native display mode, and not the current display mode.
|
inline |
The primary display is often located at (0,0), but may be placed at a different location depending on monitor layout.
displayID | the instance ID of the display to query. |
Error | on failure. |
|
inline |
The content scale is the expected scale for content based on the DPI settings of the display. For example, a 4K display might have a 2.0 (200%) display scale, which means that the user expects UI elements to be twice as big on this display, to aid in readability.
After window creation, Window.GetDisplayScale() should be used to query the content scale factor for individual windows instead of querying the display for a window and calling this function, as the per-window content scale factor may differ from the base value of the display it is on, particularly on high-DPI and/or multi-monitor desktop configurations.
displayID | the instance ID of the display to query. |
point | the point to query. |
rect | the rect to query. |
|
inline |
window | the window to query. |
|
inline |
displayID | the instance ID of the display to query. |
|
inline |
The following read-only properties are provided by SDL:
prop::Display.HDR_ENABLED_BOOLEAN
: true if the display has HDR headroom above the SDR white point. This is for informational and diagnostic purposes only, as not all platforms provide this information at the display level.On KMS/DRM:
prop::Display.KMSDRM_PANEL_ORIENTATION_NUMBER
: the "panel
orientation" property for the display in degrees of clockwise rotation. Note that this is provided only as a hint, and the application is responsible for any coordinate transformations needed to conform to the requested display orientation.displayID | the instance ID of the display to query. |
Error | on failure. |
|
inline |
This is a combination of the window pixel density and the display content scale, and is the expected scale for displaying content in this window. For example, if a 3840x2160 window had a display scale of 2.0, the user expects the content to take twice as many pixels and be the same physical size as if it were being displayed in a 1920x1080 window with a display scale of 1.0.
Conceptually this value corresponds to the scale display setting, and is updated when that setting is changed, or the window moves to a display with a different scale setting.
This is the same area as Display.GetBounds() reports, but with portions reserved by the system removed. For example, on Apple's macOS, this subtracts the area occupied by the menu bar and dock.
Setting a window to be fullscreen generally bypasses these unusable areas, so these are good guidelines for the maximum space available to a non-fullscreen window.
displayID | the instance ID of the display to query. |
Error | on failure. |
|
inline |
window
.point | the point to query. |
rect | the rect to query. |
|
inline |
The display modes are sorted in this priority:
displayID | the instance ID of the display to query. |
|
inline |
|
inline |
The display modes are sorted in this priority:
|
inlinestatic |
|
inline |
|
inline |
|
inline |
The numeric ID is what WindowEvent references, and is necessary to map these events to specific Window objects.
Error | on failure. |
|
inline |
|
inline |
w | a pointer filled in with the maximum width of the window, may be nullptr. |
h | a pointer filled in with the maximum height of the window, may be nullptr. |
Error | on failure. |
|
inline |
w | a pointer filled in with the minimum width of the window, may be nullptr. |
h | a pointer filled in with the minimum height of the window, may be nullptr. |
Error | on failure. |
|
inline |
|
inline |
|
inline |
|
inline |
displayID | the instance ID of the display to query. |
ORIENTATION_UNKNOWN
if it isn't available.
|
inline |
ORIENTATION_UNKNOWN
if it isn't available.
|
inline |
|
inline |
If transparency isn't supported on this platform, opacity will be returned as 1.0f without error.
|
inline |
Error | on failure. |
|
inline |
This is a ratio of pixel size to window size. For example, if the window is 1920x1080 and it has a high density back buffer of 3840x2160 pixels, it would have a pixel density of 2.0.
|
inline |
|
inline |
This is the current position of the window as last reported by the windowing system.
If you do not need the value for one of the positions a nullptr may be passed in the x
or y
parameter.
x | a pointer filled in with the x position of the window, may be nullptr. |
y | a pointer filled in with the y position of the window, may be nullptr. |
Error | on failure. |
|
inlinestatic |
Error | on failure. |
|
inline |
Error | on failure. |
|
inline |
The following read-only properties are provided by SDL:
prop::Display.HDR_ENABLED_BOOLEAN
: true if the display has HDR headroom above the SDR white point. This is for informational and diagnostic purposes only, as not all platforms provide this information at the display level.On KMS/DRM:
prop::Display.KMSDRM_PANEL_ORIENTATION_NUMBER
: the "panel
orientation" property for the display in degrees of clockwise rotation. Note that this is provided only as a hint, and the application is responsible for any coordinate transformations needed to conform to the requested display orientation.Error | on failure. |
|
inline |
The following read-only properties are provided by SDL:
prop::Window.SHAPE_POINTER
: the surface associated with a shaped windowprop::Window.HDR_ENABLED_BOOLEAN
: true if the window has HDR headroom above the SDR white point. This property can change dynamically when EVENT_WINDOW_HDR_STATE_CHANGED is sent.prop::Window.SDR_WHITE_LEVEL_FLOAT
: the value of SDR white in the COLORSPACE_SRGB_LINEAR colorspace. On Windows this corresponds to the SDR white level in scRGB colorspace, and on Apple platforms this is always 1.0 for EDR content. This property can change dynamically when EVENT_WINDOW_HDR_STATE_CHANGED is sent.prop::Window.HDR_HEADROOM_FLOAT
: the additional high dynamic range that can be displayed, in terms of the SDR white point. When HDR is not enabled, this will be 1.0. This property can change dynamically when EVENT_WINDOW_HDR_STATE_CHANGED is sent.On Android:
prop::Window.ANDROID_WINDOW_POINTER
: the ANativeWindow associated with the windowprop::Window.ANDROID_SURFACE_POINTER
: the EGLSurface associated with the windowOn iOS:
prop::Window.UIKIT_WINDOW_POINTER
: the (__unsafe_unretained)
UIWindow associated with the windowprop::Window.UIKIT_METAL_VIEW_TAG_NUMBER
: the NSInteger tag associated with metal views on the windowprop::Window.UIKIT_OPENGL_FRAMEBUFFER_NUMBER
: the OpenGL view's framebuffer object. It must be bound when rendering to the screen using OpenGL.prop::Window.UIKIT_OPENGL_RENDERBUFFER_NUMBER
: the OpenGL view's renderbuffer object. It must be bound when GL_SwapWindow is called.prop::Window.UIKIT_OPENGL_RESOLVE_FRAMEBUFFER_NUMBER
: the OpenGL view's resolve framebuffer, when MSAA is used.On KMS/DRM:
prop::Window.KMSDRM_DEVICE_INDEX_NUMBER
: the device index associated with the window (e.g. the X in /dev/dri/cardX)prop::Window.KMSDRM_DRM_FD_NUMBER
: the DRM FD associated with the windowprop::Window.KMSDRM_GBM_DEVICE_POINTER
: the GBM device associated with the windowOn macOS:
prop::Window.COCOA_WINDOW_POINTER
: the (__unsafe_unretained)
NSWindow associated with the windowprop::Window.COCOA_METAL_VIEW_TAG_NUMBER
: the NSInteger tag associated with metal views on the windowOn OpenVR:
prop::Window.OPENVR_OVERLAY_ID
: the OpenVR Overlay Handle ID for the associated overlay window.On Vivante:
prop::Window.VIVANTE_DISPLAY_POINTER
: the EGLNativeDisplayType associated with the windowprop::Window.VIVANTE_WINDOW_POINTER
: the EGLNativeWindowType associated with the windowprop::Window.VIVANTE_SURFACE_POINTER
: the EGLSurface associated with the windowOn Windows:
prop::Window.WIN32_HWND_POINTER
: the HWND associated with the windowprop::Window.WIN32_HDC_POINTER
: the HDC associated with the windowprop::Window.WIN32_INSTANCE_POINTER
: the HINSTANCE associated with the windowOn Wayland:
Note: The xdg_*
window objects do not internally persist across window show/hide calls. They will be null if the window is hidden and must be queried each time it is shown.
prop::Window.WAYLAND_DISPLAY_POINTER
: the wl_display associated with the windowprop::Window.WAYLAND_SURFACE_POINTER
: the wl_surface associated with the windowprop::Window.WAYLAND_VIEWPORT_POINTER
: the wp_viewport associated with the windowprop::Window.WAYLAND_EGL_WINDOW_POINTER
: the wl_egl_window associated with the windowprop::Window.WAYLAND_XDG_SURFACE_POINTER
: the xdg_surface associated with the windowprop::Window.WAYLAND_XDG_TOPLEVEL_POINTER
: the xdg_toplevel role associated with the windowprop::Window.WAYLAND_XDG_POPUP_POINTER
: the xdg_popup role associated with the windowprop::Window.WAYLAND_XDG_POSITIONER_POINTER
: the xdg_positioner associated with the window, in popup modeOn X11:
prop::Window.X11_DISPLAY_POINTER
: the X11 Display associated with the windowprop::Window.X11_SCREEN_NUMBER
: the screen number associated with the windowprop::Window.X11_WINDOW_NUMBER
: the X11 Window associated with the windowError | on failure. |
|
inline |
Some devices have portions of the screen which are partially obscured or not interactive, possibly due to on-screen controls, curved edges, camera notches, TV overscan, etc. This function provides the area of the window which is safe to have interactable content. You should continue rendering into the rest of the window, but it should not contain visually important or interactible content.
Error | on failure. |
|
inline |
The window pixel size may differ from its window coordinate size if the window is on a high pixel density display. Use Window.GetSizeInPixels() or Renderer.GetOutputSize() to get the real client area size in pixels.
w | a pointer filled in with the width of the window, may be nullptr. |
h | a pointer filled in with the height of the window, may be nullptr. |
Error | on failure. |
|
inline |
w | a pointer to variable for storing the width in pixels, may be nullptr. |
h | a pointer to variable for storing the height in pixels, may be nullptr. |
Error | on failure. |
|
inline |
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. Do not free this surface.
This surface will be invalidated if the window is resized. After resizing a window this function must be called again to return a valid surface.
You may not combine this with 3D or the rendering API on this window.
This function is affected by SDL_HINT_FRAMEBUFFER_ACCELERATION
.
|
inline |
Error | on failure. |
|
inline |
|
inline |
|
inline |
This is the same area as Display.GetBounds() reports, but with portions reserved by the system removed. For example, on Apple's macOS, this subtracts the area occupied by the menu bar and dock.
Setting a window to be fullscreen generally bypasses these unusable areas, so these are good guidelines for the maximum space available to a non-fullscreen window.
Error | on failure. |
|
inline |
The video drivers are presented in the order in which they are normally checked during initialization.
The names of drivers are all simple, low-ASCII identifiers, like "cocoa", "x11" or "windows". These never have Unicode characters, and are not meant to be proper names.
index | the index of a video driver. |
|
inline |
window | the window to query the width and height from. |
min_aspect | a pointer filled in with the minimum aspect ratio of the window, may be nullptr. |
max_aspect | a pointer filled in with the maximum aspect ratio of the window, may be nullptr. |
Error | on failure. |
|
inline |
Note: If this function fails (returns false), the size values will be initialized to 0, 0, 0, 0 (if a non-nullptr pointer is provided), as if the window in question was borderless.
Note: This function may fail on systems where the window has not yet been decorated by the display server (for example, immediately after calling Window.Window). It is recommended that you wait at least until the window has been presented and composited, so that the window system has a chance to decorate the window and provide the border dimensions to SDL.
This function also returns false if getting the information is not supported.
window | the window to query the size values of the border (decorations) from. |
top | pointer to variable for storing the size of the top border; nullptr is permitted. |
left | pointer to variable for storing the size of the left border; nullptr is permitted. |
bottom | pointer to variable for storing the size of the bottom border; nullptr is permitted. |
right | pointer to variable for storing the size of the right border; nullptr is permitted. |
Error | on failure. |
|
inline |
This is a combination of the window pixel density and the display content scale, and is the expected scale for displaying content in this window. For example, if a 3840x2160 window had a display scale of 2.0, the user expects the content to take twice as many pixels and be the same physical size as if it were being displayed in a 1920x1080 window with a display scale of 1.0.
Conceptually this value corresponds to the scale display setting, and is updated when that setting is changed, or the window moves to a display with a different scale setting.
window | the window to query. |
|
inline |
window | the window to query. |
window
.The numeric ID is what WindowEvent references, and is necessary to map these events to specific Window objects.
id | the ID of the window. |
id
or nullptr if it doesn't exist; call GetError() for more information.
|
inline |
window | the window to query. |
|
inline |
|
inline |
The numeric ID is what WindowEvent references, and is necessary to map these events to specific Window objects.
window | the window to query. |
Error | on failure. |
|
inline |
window | the window to query. |
|
inline |
window | the window to query. |
w | a pointer filled in with the maximum width of the window, may be nullptr. |
h | a pointer filled in with the maximum height of the window, may be nullptr. |
Error | on failure. |
|
inline |
window | the window to query. |
w | a pointer filled in with the minimum width of the window, may be nullptr. |
h | a pointer filled in with the minimum height of the window, may be nullptr. |
Error | on failure. |
|
inline |
window | the window to query. |
|
inline |
window | the window to query. |
|
inline |
If transparency isn't supported on this platform, opacity will be returned as 1.0f without error.
window | the window to get the current opacity value from. |
|
inline |
window | the window to query. |
Error | on failure. |
|
inline |
This is a ratio of pixel size to window size. For example, if the window is 1920x1080 and it has a high density back buffer of 3840x2160 pixels, it would have a pixel density of 2.0.
window | the window to query. |
|
inline |
|
inline |
This is the current position of the window as last reported by the windowing system.
If you do not need the value for one of the positions a nullptr may be passed in the x
or y
parameter.
window | the window to query. |
x | a pointer filled in with the x position of the window, may be nullptr. |
y | a pointer filled in with the y position of the window, may be nullptr. |
Error | on failure. |
|
inline |
The following read-only properties are provided by SDL:
prop::Window.SHAPE_POINTER
: the surface associated with a shaped windowprop::Window.HDR_ENABLED_BOOLEAN
: true if the window has HDR headroom above the SDR white point. This property can change dynamically when EVENT_WINDOW_HDR_STATE_CHANGED is sent.prop::Window.SDR_WHITE_LEVEL_FLOAT
: the value of SDR white in the COLORSPACE_SRGB_LINEAR colorspace. On Windows this corresponds to the SDR white level in scRGB colorspace, and on Apple platforms this is always 1.0 for EDR content. This property can change dynamically when EVENT_WINDOW_HDR_STATE_CHANGED is sent.prop::Window.HDR_HEADROOM_FLOAT
: the additional high dynamic range that can be displayed, in terms of the SDR white point. When HDR is not enabled, this will be 1.0. This property can change dynamically when EVENT_WINDOW_HDR_STATE_CHANGED is sent.On Android:
prop::Window.ANDROID_WINDOW_POINTER
: the ANativeWindow associated with the windowprop::Window.ANDROID_SURFACE_POINTER
: the EGLSurface associated with the windowOn iOS:
prop::Window.UIKIT_WINDOW_POINTER
: the (__unsafe_unretained)
UIWindow associated with the windowprop::Window.UIKIT_METAL_VIEW_TAG_NUMBER
: the NSInteger tag associated with metal views on the windowprop::Window.UIKIT_OPENGL_FRAMEBUFFER_NUMBER
: the OpenGL view's framebuffer object. It must be bound when rendering to the screen using OpenGL.prop::Window.UIKIT_OPENGL_RENDERBUFFER_NUMBER
: the OpenGL view's renderbuffer object. It must be bound when GL_SwapWindow is called.prop::Window.UIKIT_OPENGL_RESOLVE_FRAMEBUFFER_NUMBER
: the OpenGL view's resolve framebuffer, when MSAA is used.On KMS/DRM:
prop::Window.KMSDRM_DEVICE_INDEX_NUMBER
: the device index associated with the window (e.g. the X in /dev/dri/cardX)prop::Window.KMSDRM_DRM_FD_NUMBER
: the DRM FD associated with the windowprop::Window.KMSDRM_GBM_DEVICE_POINTER
: the GBM device associated with the windowOn macOS:
prop::Window.COCOA_WINDOW_POINTER
: the (__unsafe_unretained)
NSWindow associated with the windowprop::Window.COCOA_METAL_VIEW_TAG_NUMBER
: the NSInteger tag associated with metal views on the windowOn OpenVR:
prop::Window.OPENVR_OVERLAY_ID
: the OpenVR Overlay Handle ID for the associated overlay window.On Vivante:
prop::Window.VIVANTE_DISPLAY_POINTER
: the EGLNativeDisplayType associated with the windowprop::Window.VIVANTE_WINDOW_POINTER
: the EGLNativeWindowType associated with the windowprop::Window.VIVANTE_SURFACE_POINTER
: the EGLSurface associated with the windowOn Windows:
prop::Window.WIN32_HWND_POINTER
: the HWND associated with the windowprop::Window.WIN32_HDC_POINTER
: the HDC associated with the windowprop::Window.WIN32_INSTANCE_POINTER
: the HINSTANCE associated with the windowOn Wayland:
Note: The xdg_*
window objects do not internally persist across window show/hide calls. They will be null if the window is hidden and must be queried each time it is shown.
prop::Window.WAYLAND_DISPLAY_POINTER
: the wl_display associated with the windowprop::Window.WAYLAND_SURFACE_POINTER
: the wl_surface associated with the windowprop::Window.WAYLAND_VIEWPORT_POINTER
: the wp_viewport associated with the windowprop::Window.WAYLAND_EGL_WINDOW_POINTER
: the wl_egl_window associated with the windowprop::Window.WAYLAND_XDG_SURFACE_POINTER
: the xdg_surface associated with the windowprop::Window.WAYLAND_XDG_TOPLEVEL_POINTER
: the xdg_toplevel role associated with the windowprop::Window.WAYLAND_XDG_POPUP_POINTER
: the xdg_popup role associated with the windowprop::Window.WAYLAND_XDG_POSITIONER_POINTER
: the xdg_positioner associated with the window, in popup modeOn X11:
prop::Window.X11_DISPLAY_POINTER
: the X11 Display associated with the windowprop::Window.X11_SCREEN_NUMBER
: the screen number associated with the windowprop::Window.X11_WINDOW_NUMBER
: the X11 Window associated with the windowwindow | the window to query. |
Error | on failure. |
|
inline |
Some devices have portions of the screen which are partially obscured or not interactive, possibly due to on-screen controls, curved edges, camera notches, TV overscan, etc. This function provides the area of the window which is safe to have interactable content. You should continue rendering into the rest of the window, but it should not contain visually important or interactible content.
window | the window to query. |
Error | on failure. |
|
inline |
The window pixel size may differ from its window coordinate size if the window is on a high pixel density display. Use Window.GetSizeInPixels() or Renderer.GetOutputSize() to get the real client area size in pixels.
window | the window to query the width and height from. |
w | a pointer filled in with the width of the window, may be nullptr. |
h | a pointer filled in with the height of the window, may be nullptr. |
Error | on failure. |
|
inline |
window | the window from which the drawable size should be queried. |
w | a pointer to variable for storing the width in pixels, may be nullptr. |
h | a pointer to variable for storing the height in pixels, may be nullptr. |
Error | on failure. |
|
inline |
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. Do not free this surface.
This surface will be invalidated if the window is resized. After resizing a window this function must be called again to return a valid surface.
You may not combine this with 3D or the rendering API on this window.
This function is affected by SDL_HINT_FRAMEBUFFER_ACCELERATION
.
window | the window to query. |
|
inline |
window | the window to query. |
Error | on failure. |
|
inline |
window | the window to query. |
|
inline |
Windows users new to OpenGL should note that, for historical reasons, GL functions added after OpenGL version 1.1 are not available by default. Those functions must be loaded at run-time, either with an OpenGL extension-handling library or with GL_GetProcAddress() and its related functions.
GLContext is opaque to the application.
window | the window to associate with the context. |
window
or nullptr on failure; call GetError() for more information.
|
inline |
context | the OpenGL context to be deleted. |
Error | on failure. |
|
inline |
This function operates on the current GL context; you must have created a context and it must be current before calling this function. Do not assume that all contexts you create will have the same set of extensions available, or that recreating an existing context will offer the same extensions again.
While it's probably not a massive overhead, this function is not an O(1) operation. Check the extensions you care about after creating the GL context and save that information somewhere instead of calling the function every time you need to know.
extension | the name of the extension to check. |
|
inline |
attr | an GLAttr enum value specifying the OpenGL attribute to get. |
value | a pointer filled in with the current value of attr . |
Error | on failure. |
|
inline |
|
inline |
|
inline |
If the GL library is loaded at runtime with GL_LoadLibrary(), then all GL functions must be retrieved this way. Usually this is used to retrieve function pointers to OpenGL extensions.
There are some quirks to looking up OpenGL functions that require some extra care from the application. If you code carefully, you can handle these quirks without any platform-specific code, though:
APIENTRY
as in the example code. This will ensure the proper calling convention is followed on platforms where this matters (Win32) thereby avoiding stack corruption.proc | the name of an OpenGL function. |
|
inline |
If the system can't determine the swap interval, or there isn't a valid current context, this function will set *interval to 0 as a safe default.
interval | output interval value. 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. |
Error | on failure. |
|
inline |
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.
If you do this, you need to retrieve all of the GL functions used in your program from the dynamic library using GL_GetProcAddress().
path | the platform dependent OpenGL library name, or nullptr to open the default OpenGL library. |
Error | on failure. |
|
inline |
The context must have been created with a compatible window.
window | the window to associate with the context. |
context | the OpenGL context to associate with the window. |
Error | on failure. |
|
inline |
|
inline |
This function sets the OpenGL attribute attr
to value
. The requested attributes should be set before creating an OpenGL window. You should use GL_GetAttribute() to check the values after creating the OpenGL context, since the values obtained can differ from the requested ones.
attr | an GLAttr enum value specifying the OpenGL attribute to set. |
value | the desired value for the attribute. |
Error | on failure. |
|
inline |
Some systems allow specifying -1 for the interval, to enable adaptive vsync. Adaptive vsync works the same as vsync, but if you've already missed the vertical retrace for a given frame, it swaps buffers immediately, which might be less jarring for the user during occasional framerate drops. If an application requests adaptive vsync and the system does not support it, this function will fail and return false. In such a case, you should probably retry the call with 1 for the interval.
Adaptive vsync is implemented for some glX drivers with GLX_EXT_swap_control_tear, and for some Windows drivers with WGL_EXT_swap_control_tear.
Read more on the Khronos wiki: https://www.khronos.org/opengl/wiki/Swap_Interval#Adaptive_Vsync
interval | 0 for immediate updates, 1 for updates synchronized with the vertical retrace, -1 for adaptive vsync. |
Error | on failure. |
|
inline |
This is used with double-buffered OpenGL contexts, which are the default.
On macOS, make sure you bind 0 to the draw framebuffer before swapping the window, otherwise nothing will happen. If you aren't using glBindFramebuffer(), this is the default and you won't have to do anything extra.
window | the window to change. |
Error | on failure. |
|
inline |
|
inline |
|
inline |
Error | on failure. |
|
inline |
window | the window to hide. |
Error | on failure. |
|
inline |
The context must have been created with a compatible window.
window | the window to associate with the context. |
Error | on failure. |
|
inline |
Non-resizable windows can't be maximized. The window must have the WINDOW_RESIZABLE flag set, or this will have no effect.
On some windowing systems this request is asynchronous and the new window state may not have have been applied immediately upon the return of this function. If an immediate change is required, call Window.Sync() to block until the changes have taken effect.
When the window state changes, an EVENT_WINDOW_MAXIMIZED event will be emitted. Note that, as this is just a request, the windowing system can deny the state change.
When maximizing a window, whether the constraints set via Window.SetMaximumSize() are honored depends on the policy of the window manager. Win32 and macOS enforce the constraints when maximizing, while X11 and Wayland window managers may vary.
Error | on failure. |
|
inline |
Non-resizable windows can't be maximized. The window must have the WINDOW_RESIZABLE flag set, or this will have no effect.
On some windowing systems this request is asynchronous and the new window state may not have have been applied immediately upon the return of this function. If an immediate change is required, call Window.Sync() to block until the changes have taken effect.
When the window state changes, an EVENT_WINDOW_MAXIMIZED event will be emitted. Note that, as this is just a request, the windowing system can deny the state change.
When maximizing a window, whether the constraints set via Window.SetMaximumSize() are honored depends on the policy of the window manager. Win32 and macOS enforce the constraints when maximizing, while X11 and Wayland window managers may vary.
window | the window to maximize. |
Error | on failure. |
|
inline |
If the window is in a fullscreen state, this request has no direct effect. It may alter the state the window is returned to when leaving fullscreen.
On some windowing systems this request is asynchronous and the new window state may not have been applied immediately upon the return of this function. If an immediate change is required, call Window.Sync() to block until the changes have taken effect.
When the window state changes, an EVENT_WINDOW_MINIMIZED event will be emitted. Note that, as this is just a request, the windowing system can deny the state change.
Error | on failure. |
|
inline |
If the window is in a fullscreen state, this request has no direct effect. It may alter the state the window is returned to when leaving fullscreen.
On some windowing systems this request is asynchronous and the new window state may not have been applied immediately upon the return of this function. If an immediate change is required, call Window.Sync() to block until the changes have taken effect.
When the window state changes, an EVENT_WINDOW_MINIMIZED event will be emitted. Note that, as this is just a request, the windowing system can deny the state change.
window | the window to minimize. |
Error | on failure. |
|
inline |
The result of this request is subject to desktop window manager policy, particularly if raising the requested window would result in stealing focus from another application. If the window is successfully raised and gains input focus, an EVENT_WINDOW_FOCUS_GAINED event will be emitted, and the window will have the WINDOW_INPUT_FOCUS flag set.
Error | on failure. |
|
inline |
The result of this request is subject to desktop window manager policy, particularly if raising the requested window would result in stealing focus from another application. If the window is successfully raised and gains input focus, an EVENT_WINDOW_FOCUS_GAINED event will be emitted, and the window will have the WINDOW_INPUT_FOCUS flag set.
window | the window to raise. |
Error | on failure. |
|
inline |
If the window is in a fullscreen state, this request has no direct effect. It may alter the state the window is returned to when leaving fullscreen.
On some windowing systems this request is asynchronous and the new window state may not have have been applied immediately upon the return of this function. If an immediate change is required, call Window.Sync() to block until the changes have taken effect.
When the window state changes, an EVENT_WINDOW_RESTORED event will be emitted. Note that, as this is just a request, the windowing system can deny the state change.
Error | on failure. |
|
inline |
If the window is in a fullscreen state, this request has no direct effect. It may alter the state the window is returned to when leaving fullscreen.
On some windowing systems this request is asynchronous and the new window state may not have have been applied immediately upon the return of this function. If an immediate change is required, call Window.Sync() to block until the changes have taken effect.
When the window state changes, an EVENT_WINDOW_RESTORED event will be emitted. Note that, as this is just a request, the windowing system can deny the state change.
window | the window to restore. |
Error | on failure. |
|
inline |
The screensaver is disabled by default.
The default can also be changed using SDL_HINT_VIDEO_ALLOW_SCREENSAVER
.
|
inline |
This will add or remove the window's WINDOW_ALWAYS_ON_TOP
flag. This will bring the window to the front and keep the window above the rest.
on_top | true to set the window always on top, false to disable. |
Error | on failure. |
|
inline |
The aspect ratio is the ratio of width divided by height, e.g. 2560x1600 would be 1.6. Larger aspect ratios are wider and smaller aspect ratios are narrower.
If, at the time of this request, the window in a fixed-size state, such as maximized or fullscreen, the request will be deferred until the window exits this state and becomes resizable again.
On some windowing systems, this request is asynchronous and the new window aspect ratio may not have have been applied immediately upon the return of this function. If an immediate change is required, call Window.Sync() to block until the changes have taken effect.
When the window size changes, an EVENT_WINDOW_RESIZED event will be emitted with the new window dimensions. Note that the new dimensions may not match the exact aspect ratio requested, as some windowing systems can restrict the window size in certain scenarios (e.g. constraining the size of the content area to remain within the usable desktop bounds). Additionally, as this is just a request, it can be denied by the windowing system.
min_aspect | the minimum aspect ratio of the window, or 0.0f for no limit. |
max_aspect | the maximum aspect ratio of the window, or 0.0f for no limit. |
Error | on failure. |
|
inline |
This will add or remove the window's 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.
You can't change the border state of a fullscreen window.
bordered | false to remove border, true to add border. |
Error | on failure. |
|
inline |
|
inline |
By default a window in fullscreen state uses borderless fullscreen desktop mode, but a specific exclusive display mode can be set using Window.SetFullscreenMode().
On some windowing systems this request is asynchronous and the new fullscreen state may not have have been applied immediately upon the return of this function. If an immediate change is required, call Window.Sync() to block until the changes have taken effect.
When the window state changes, an EVENT_WINDOW_ENTER_FULLSCREEN or EVENT_WINDOW_LEAVE_FULLSCREEN event will be emitted. Note that, as this is just a request, it can be denied by the windowing system.
fullscreen | true for fullscreen mode, false for windowed mode. |
Error | on failure. |
|
inline |
This only affects the display mode used when the window is fullscreen. To change the window size when the window is not fullscreen, use Window.SetSize().
If the window is currently in the fullscreen state, this request is asynchronous on some windowing systems and the new mode dimensions may not be applied immediately upon the return of this function. If an immediate change is required, call Window.Sync() to block until the changes have taken effect.
When the new mode takes effect, an EVENT_WINDOW_RESIZED and/or an EVENT_WINDOW_PIXEL_SIZE_CHANGED event will be emitted with the new mode dimensions.
mode | a pointer to the display mode to use, which can be nullptr for borderless fullscreen desktop mode, or one of the fullscreen modes returned by Display.GetFullscreenModes() to set an exclusive fullscreen mode. |
Error | on failure. |
|
inline |
If this function is passed a surface with alternate representations, the surface will be interpreted as the content to be used for 100% display scale, and the alternate representations will be used for high DPI situations. For example, if the original surface is 32x32, then on a 2x macOS display or 200% display scale on Windows, a 64x64 version of the image will be used, if available. If a matching version of the image isn't available, the closest larger size image will be downscaled to the appropriate size and be used instead, if available. Otherwise, the closest smaller image will be upscaled and be used instead.
icon | an Surface structure containing the icon for the window. |
Error | on failure. |
|
inline |
Keyboard grab enables capture of system keyboard shortcuts like Alt+Tab or the Meta/Super key. Note that not all system keyboard shortcuts can be captured by applications (one example is Ctrl+Alt+Del on Windows).
This is primarily intended for specialized applications such as VNC clients or VM frontends. Normal games should not use keyboard grab.
When keyboard grab is enabled, SDL will continue to handle Alt+Tab when the window is full-screen to ensure the user is not trapped in your application. If you have a custom keyboard shortcut to exit fullscreen mode, you may suppress this behavior with SDL_HINT_ALLOW_ALT_TAB_WHILE_GRABBED
.
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.
grabbed | this is true to grab keyboard, and false to release. |
Error | on failure. |
|
inline |
|
inline |
|
inline |
To enable modal status on a window, the window must currently be the child window of a parent, or toggling modal status on will fail.
modal | true to toggle modal status on, false to toggle it off. |
Error | on failure. |
|
inline |
|
inline |
Note that this does NOT grab the cursor, it only defines the area a cursor is restricted to when the window has mouse focus.
rect | a rectangle area in window-relative coordinates. If nullptr the barrier for the specified window will be destroyed. |
Error | on failure. |
|
inline |
The parameter opacity
will be clamped internally between 0.0f (transparent) and 1.0f (opaque).
This function also returns false if setting the opacity isn't supported.
opacity | the opacity value (0.0f - transparent, 1.0f - opaque). |
Error | on failure. |
|
inline |
If the window is already the child of an existing window, it will be reparented to the new owner. Setting the parent window to nullptr unparents the window and removes child window status.
If a parent window is hidden or destroyed, the operation will be recursively applied to child windows. Child windows hidden with the parent that did not have their hidden status explicitly set will be restored when the parent is shown.
Attempting to set the parent of a window that is currently in the modal state will fail. Use Window.SetModal() to cancel the modal status before attempting to change the parent.
Popup windows cannot change parents and attempts to do so will fail.
Setting a parent window that is currently the sibling or descendent of the child window results in undefined behavior.
parent | the new parent window for the child window. |
Error | on failure. |
|
inline |
If the window is in an exclusive fullscreen or maximized state, this request has no effect.
This can be used to reposition fullscreen-desktop windows onto a different display, however, as exclusive fullscreen windows are locked to a specific display, they can only be repositioned programmatically via Window.SetFullscreenMode().
On some windowing systems this request is asynchronous and the new coordinates may not have have been applied immediately upon the return of this function. If an immediate change is required, call Window.Sync() to block until the changes have taken effect.
When the window position changes, an EVENT_WINDOW_MOVED event will be emitted with the window's new coordinates. Note that the new coordinates may not match the exact coordinates requested, as some windowing systems can restrict the position of the window in certain scenarios (e.g. constraining the position so the window is always within desktop bounds). Additionally, as this is just a request, it can be denied by the windowing system.
p | the coordinates of the window, or SDL_WINDOWPOS_CENTERED or SDL_WINDOWPOS_UNDEFINED . |
Error | on failure. |
|
inline |
This will add or remove the window's WINDOW_RESIZABLE
flag and allow/disallow user resizing of the window. This is a no-op if the window's resizable state already matches the requested state.
You can't change the resizable state of a fullscreen window.
resizable | true to allow resizing, false to disallow. |
Error | on failure. |
|
inline |
This sets the alpha channel of a transparent window and any fully transparent areas are also transparent to mouse clicks. If you are using something besides the SDL render API, then you are responsible for drawing the alpha channel of the window to match the shape alpha channel to get consistent cross-platform results.
The shape is copied inside this function, so you can free it afterwards. If your shape surface changes, you should call Window.SetShape() again to update the window. This is an expensive operation, so should be done sparingly.
The window must have been created with the WINDOW_TRANSPARENT flag.
shape | the surface representing the shape of the window, or nullptr to remove any current shape. |
Error | on failure. |
|
inline |
If the window is in a fullscreen or maximized state, this request has no effect.
To change the exclusive fullscreen mode of a window, use Window.SetFullscreenMode().
On some windowing systems, this request is asynchronous and the new window size may not have have been applied immediately upon the return of this function. If an immediate change is required, call Window.Sync() to block until the changes have taken effect.
When the window size changes, an EVENT_WINDOW_RESIZED event will be emitted with the new window dimensions. Note that the new dimensions may not match the exact size requested, as some windowing systems can restrict the window size in certain scenarios (e.g. constraining the size of the content area to remain within the usable desktop bounds). Additionally, as this is just a request, it can be denied by the windowing system.
p | the width and height of the window, must be > 0. |
Error | on failure. |
|
inline |
When a window surface is created, vsync defaults to WINDOW_SURFACE_VSYNC_DISABLED.
The vsync
parameter can be 1 to synchronize present with every vertical refresh, 2 to synchronize present with every second vertical refresh, etc., WINDOW_SURFACE_VSYNC_ADAPTIVE for late swap tearing (adaptive vsync), or WINDOW_SURFACE_VSYNC_DISABLED to disable. Not every value is supported by every driver, so you should check the return value to see whether the requested setting is supported.
vsync | the vertical refresh sync interval. |
Error | on failure. |
|
inline |
This string is expected to be in UTF-8 encoding.
title | the desired window title in UTF-8 format. |
Error | on failure. |
|
inline |
This will add or remove the window's WINDOW_ALWAYS_ON_TOP
flag. This will bring the window to the front and keep the window above the rest.
window | the window of which to change the always on top state. |
on_top | true to set the window always on top, false to disable. |
Error | on failure. |
|
inline |
The aspect ratio is the ratio of width divided by height, e.g. 2560x1600 would be 1.6. Larger aspect ratios are wider and smaller aspect ratios are narrower.
If, at the time of this request, the window in a fixed-size state, such as maximized or fullscreen, the request will be deferred until the window exits this state and becomes resizable again.
On some windowing systems, this request is asynchronous and the new window aspect ratio may not have have been applied immediately upon the return of this function. If an immediate change is required, call Window.Sync() to block until the changes have taken effect.
When the window size changes, an EVENT_WINDOW_RESIZED event will be emitted with the new window dimensions. Note that the new dimensions may not match the exact aspect ratio requested, as some windowing systems can restrict the window size in certain scenarios (e.g. constraining the size of the content area to remain within the usable desktop bounds). Additionally, as this is just a request, it can be denied by the windowing system.
window | the window to change. |
min_aspect | the minimum aspect ratio of the window, or 0.0f for no limit. |
max_aspect | the maximum aspect ratio of the window, or 0.0f for no limit. |
Error | on failure. |
|
inline |
This will add or remove the window's 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.
You can't change the border state of a fullscreen window.
window | the window of which to change the border state. |
bordered | false to remove border, true to add border. |
Error | on failure. |
|
inline |
|
inline |
By default a window in fullscreen state uses borderless fullscreen desktop mode, but a specific exclusive display mode can be set using Window.SetFullscreenMode().
On some windowing systems this request is asynchronous and the new fullscreen state may not have have been applied immediately upon the return of this function. If an immediate change is required, call Window.Sync() to block until the changes have taken effect.
When the window state changes, an EVENT_WINDOW_ENTER_FULLSCREEN or EVENT_WINDOW_LEAVE_FULLSCREEN event will be emitted. Note that, as this is just a request, it can be denied by the windowing system.
window | the window to change. |
fullscreen | true for fullscreen mode, false for windowed mode. |
Error | on failure. |
|
inline |
This only affects the display mode used when the window is fullscreen. To change the window size when the window is not fullscreen, use Window.SetSize().
If the window is currently in the fullscreen state, this request is asynchronous on some windowing systems and the new mode dimensions may not be applied immediately upon the return of this function. If an immediate change is required, call Window.Sync() to block until the changes have taken effect.
When the new mode takes effect, an EVENT_WINDOW_RESIZED and/or an EVENT_WINDOW_PIXEL_SIZE_CHANGED event will be emitted with the new mode dimensions.
window | the window to affect. |
mode | a pointer to the display mode to use, which can be nullptr for borderless fullscreen desktop mode, or one of the fullscreen modes returned by Display.GetFullscreenModes() to set an exclusive fullscreen mode. |
Error | on failure. |
|
inline |
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 nullptr for a callback disables hit-testing. Hit-testing is disabled by default.
Platforms that don't support this functionality will return false 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.
window | the window to set hit-testing on. |
callback | the function to call when doing a hit-test. |
callback_data | an app-defined void pointer passed to callback. |
Error | on failure. |
|
inline |
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 nullptr for a callback disables hit-testing. Hit-testing is disabled by default.
Platforms that don't support this functionality will return false 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.
window | the window to set hit-testing on. |
callback | the function to call when doing a hit-test. |
Error | on failure. |
|
inline |
If this function is passed a surface with alternate representations, the surface will be interpreted as the content to be used for 100% display scale, and the alternate representations will be used for high DPI situations. For example, if the original surface is 32x32, then on a 2x macOS display or 200% display scale on Windows, a 64x64 version of the image will be used, if available. If a matching version of the image isn't available, the closest larger size image will be downscaled to the appropriate size and be used instead, if available. Otherwise, the closest smaller image will be upscaled and be used instead.
window | the window to change. |
icon | an Surface structure containing the icon for the window. |
Error | on failure. |
|
inline |
Keyboard grab enables capture of system keyboard shortcuts like Alt+Tab or the Meta/Super key. Note that not all system keyboard shortcuts can be captured by applications (one example is Ctrl+Alt+Del on Windows).
This is primarily intended for specialized applications such as VNC clients or VM frontends. Normal games should not use keyboard grab.
When keyboard grab is enabled, SDL will continue to handle Alt+Tab when the window is full-screen to ensure the user is not trapped in your application. If you have a custom keyboard shortcut to exit fullscreen mode, you may suppress this behavior with SDL_HINT_ALLOW_ALT_TAB_WHILE_GRABBED
.
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.
window | the window for which the keyboard grab mode should be set. |
grabbed | this is true to grab keyboard, and false to release. |
Error | on failure. |
|
inline |
|
inline |
|
inline |
To enable modal status on a window, the window must currently be the child window of a parent, or toggling modal status on will fail.
window | the window on which to set the modal state. |
modal | true to toggle modal status on, false to toggle it off. |
Error | on failure. |
|
inline |
Mouse grab confines the mouse cursor to the window.
window | the window for which the mouse grab mode should be set. |
grabbed | this is true to grab mouse, and false to release. |
Error | on failure. |
|
inline |
Note that this does NOT grab the cursor, it only defines the area a cursor is restricted to when the window has mouse focus.
window | the window that will be associated with the barrier. |
rect | a rectangle area in window-relative coordinates. If nullptr the barrier for the specified window will be destroyed. |
Error | on failure. |
|
inline |
The parameter opacity
will be clamped internally between 0.0f (transparent) and 1.0f (opaque).
This function also returns false if setting the opacity isn't supported.
window | the window which will be made transparent or opaque. |
opacity | the opacity value (0.0f - transparent, 1.0f - opaque). |
Error | on failure. |
|
inline |
If the window is already the child of an existing window, it will be reparented to the new owner. Setting the parent window to nullptr unparents the window and removes child window status.
If a parent window is hidden or destroyed, the operation will be recursively applied to child windows. Child windows hidden with the parent that did not have their hidden status explicitly set will be restored when the parent is shown.
Attempting to set the parent of a window that is currently in the modal state will fail. Use Window.SetModal() to cancel the modal status before attempting to change the parent.
Popup windows cannot change parents and attempts to do so will fail.
Setting a parent window that is currently the sibling or descendent of the child window results in undefined behavior.
window | the window that should become the child of a parent. |
parent | the new parent window for the child window. |
Error | on failure. |
|
inline |
If the window is in an exclusive fullscreen or maximized state, this request has no effect.
This can be used to reposition fullscreen-desktop windows onto a different display, however, as exclusive fullscreen windows are locked to a specific display, they can only be repositioned programmatically via Window.SetFullscreenMode().
On some windowing systems this request is asynchronous and the new coordinates may not have have been applied immediately upon the return of this function. If an immediate change is required, call Window.Sync() to block until the changes have taken effect.
When the window position changes, an EVENT_WINDOW_MOVED event will be emitted with the window's new coordinates. Note that the new coordinates may not match the exact coordinates requested, as some windowing systems can restrict the position of the window in certain scenarios (e.g. constraining the position so the window is always within desktop bounds). Additionally, as this is just a request, it can be denied by the windowing system.
window | the window to reposition. |
p | the coordinates of the window, or SDL_WINDOWPOS_CENTERED or SDL_WINDOWPOS_UNDEFINED . |
Error | on failure. |
|
inline |
This will add or remove the window's WINDOW_RESIZABLE
flag and allow/disallow user resizing of the window. This is a no-op if the window's resizable state already matches the requested state.
You can't change the resizable state of a fullscreen window.
window | the window of which to change the resizable state. |
resizable | true to allow resizing, false to disallow. |
Error | on failure. |
|
inline |
This sets the alpha channel of a transparent window and any fully transparent areas are also transparent to mouse clicks. If you are using something besides the SDL render API, then you are responsible for drawing the alpha channel of the window to match the shape alpha channel to get consistent cross-platform results.
The shape is copied inside this function, so you can free it afterwards. If your shape surface changes, you should call Window.SetShape() again to update the window. This is an expensive operation, so should be done sparingly.
The window must have been created with the WINDOW_TRANSPARENT flag.
window | the window. |
shape | the surface representing the shape of the window, or nullptr to remove any current shape. |
Error | on failure. |
|
inline |
If the window is in a fullscreen or maximized state, this request has no effect.
To change the exclusive fullscreen mode of a window, use Window.SetFullscreenMode().
On some windowing systems, this request is asynchronous and the new window size may not have have been applied immediately upon the return of this function. If an immediate change is required, call Window.Sync() to block until the changes have taken effect.
When the window size changes, an EVENT_WINDOW_RESIZED event will be emitted with the new window dimensions. Note that the new dimensions may not match the exact size requested, as some windowing systems can restrict the window size in certain scenarios (e.g. constraining the size of the content area to remain within the usable desktop bounds). Additionally, as this is just a request, it can be denied by the windowing system.
window | the window to change. |
p | the width and height of the window, must be > 0. |
Error | on failure. |
|
inline |
When a window surface is created, vsync defaults to WINDOW_SURFACE_VSYNC_DISABLED.
The vsync
parameter can be 1 to synchronize present with every vertical refresh, 2 to synchronize present with every second vertical refresh, etc., WINDOW_SURFACE_VSYNC_ADAPTIVE for late swap tearing (adaptive vsync), or WINDOW_SURFACE_VSYNC_DISABLED to disable. Not every value is supported by every driver, so you should check the return value to see whether the requested setting is supported.
window | the window. |
vsync | the vertical refresh sync interval. |
Error | on failure. |
|
inline |
This string is expected to be in UTF-8 encoding.
window | the window to change. |
title | the desired window title in UTF-8 format. |
Error | on failure. |
|
inline |
Error | on failure. |
|
inline |
This default window menu is provided by the system and on some platforms provides functionality for setting or changing privileged state on the window, such as moving it between workspaces or displays, or toggling the always-on-top property.
On platforms or desktops where this is unsupported, this function does nothing.
p | the x, y coordinates of the menu, relative to the origin (top-left) of the client area. |
Error | on failure. |
|
inline |
window | the window to show. |
Error | on failure. |
|
inline |
This default window menu is provided by the system and on some platforms provides functionality for setting or changing privileged state on the window, such as moving it between workspaces or displays, or toggling the always-on-top property.
On platforms or desktops where this is unsupported, this function does nothing.
window | the window for which the menu will be displayed. |
p | the coordinates of the menu, relative to the origin (top-left) of the client area. |
Error | on failure. |
|
inline |
On asynchronous windowing systems, this acts as a synchronization barrier for pending window state. It will attempt to wait until any pending window state has been applied and is guaranteed to return within finite time. Note that for how long it can potentially block depends on the underlying window system, as window state changes may involve somewhat lengthy animations that must complete before the window is in its final requested state.
On windowing systems where changes are immediate, this does nothing.
applied.
Error | on failure. |
|
inline |
On asynchronous windowing systems, this acts as a synchronization barrier for pending window state. It will attempt to wait until any pending window state has been applied and is guaranteed to return within finite time. Note that for how long it can potentially block depends on the underlying window system, as window state changes may involve somewhat lengthy animations that must complete before the window is in its final requested state.
On windowing systems where changes are immediate, this does nothing.
window | the window for which to wait for the pending state to be applied. |
Error | on failure. |
|
inline |
This is the function you use to reflect changes to portions of the surface on the screen.
This function is equivalent to the SDL 1.2 API SDL_UpdateRects().
Note that this function will update at least the rectangles specified, but this is only intended as an optimization; in practice, this might update more of the screen (or all of the screen!), depending on what method SDL uses to send pixels to the system.
rects | an array of Rect structures representing areas of the surface to copy, in pixels. |
Error | on failure. |
|
inline |
This is the function you use to reflect any changes to the surface on the screen.
This function is equivalent to the SDL 1.2 API SDL_Flip().
window | the window to update. |
Error | on failure. |
|
inline |
This is the function you use to reflect changes to portions of the surface on the screen.
This function is equivalent to the SDL 1.2 API SDL_UpdateRects().
Note that this function will update at least the rectangles specified, but this is only intended as an optimization; in practice, this might update more of the screen (or all of the screen!), depending on what method SDL uses to send pixels to the system.
window | the window to update. |
rects | an array of Rect structures representing areas of the surface to copy, in pixels. |
Error | on failure. |
|
inline |
window | the window to query. |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
See GLProfile; default value depends on platform.
|
constexpr |
See GLContextReleaseFlag; defaults to FLUSH.
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
See GLContextResetNotification; defaults to NO_NOTIFICATION.
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |