// // Generated by Brutal.Sdl.Generate; do not edit by hand. #nullable enable namespace Brutal.SdlApi { public static unsafe partial class Sdl { public static unsafe partial class Video { /// /// Get the number of video drivers compiled into SDL. /// /// the number of built in video drivers. /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// public static int GetNumVideoDrivers() => PInvoke.GetNumVideoDrivers(); /// /// Get the name of a built in video driver. /// /// the index of a video driver. /// /// the name of the video driver with the given index, or NULL if /// index is out of bounds. /// /// /// /// 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. /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// public static string? GetVideoDriver(int index) => PInvoke.GetVideoDriver(index); /// /// Get the name of the currently initialized video driver. /// /// /// the name of the current video driver or NULL if no driver has been /// initialized. /// /// /// /// 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. /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// /// public static string? GetCurrentVideoDriver() => PInvoke.GetCurrentVideoDriver(); /// /// Get the current system theme. /// /// the current system theme, light, dark, or unknown. /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// public static SdlSystemTheme GetSystemTheme() => PInvoke.GetSystemTheme(); /// /// Ergonomic wrapper over SDL_GetDisplays. /// /// The SDL call failed; the message carries the /// SDL_GetError text. /// /// SDL returns a freshly SDL_malloc'd buffer for this call; the returned array is a managed copy, /// and the native buffer is freed with SDL_free before this method returns. /// public static uint[] GetDisplays() { int count; var ptr = PInvoke.GetDisplays(&count); if (ptr is null) throw SdlException.FromError("SDL_GetDisplays failed"); try { return new ReadOnlySpan(ptr, count).ToArray(); } finally { PInvoke.Free(ptr); } } /// /// Return the primary display. /// /// /// the instance ID of the primary display on success or 0 on failure; /// call SDL_GetError() for more information. /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// public static uint GetPrimaryDisplay() => PInvoke.GetPrimaryDisplay(); /// /// Get the properties associated with a display. /// /// the instance ID of the display to query. /// /// a valid property ID on success or 0 on failure; call /// SDL_GetError() for more information. /// /// /// /// The following read-only properties are provided by SDL: /// /// /// - 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: /// /// /// - SDL_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. /// /// /// On Wayland: /// /// /// - SDL_PROP_DISPLAY_WAYLAND_WL_OUTPUT_POINTER: the wl_output associated /// with the display /// /// /// On Windows: /// /// /// - SDL_PROP_DISPLAY_WINDOWS_HMONITOR_POINTER: the monitor handle /// (HMONITOR) associated with the display /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// public static uint GetDisplayProperties(uint displayID) => PInvoke.GetDisplayProperties(displayID); /// /// Get the name of a display in UTF-8 encoding. /// /// the instance ID of the display to query. /// /// the name of a display or NULL on failure; call SDL_GetError() for /// more information. /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// public static string? GetDisplayName(uint displayID) => PInvoke.GetDisplayName(displayID); /// /// Get the desktop area represented by a display. /// /// the instance ID of the display to query. /// the SDL_Rect structure filled in with the display bounds. /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// /// The primary display is often located at (0,0), but may be placed at a /// different location depending on monitor layout. /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// /// public static bool GetDisplayBounds(uint displayID, SdlRect* rect) => PInvoke.GetDisplayBounds(displayID, rect) != 0; /// /// Get the usable desktop area represented by a display, in screen /// coordinates. /// /// the instance ID of the display to query. /// the SDL_Rect structure filled in with the display bounds. /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// /// This is the same area as SDL_GetDisplayBounds() 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. /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// /// public static bool GetDisplayUsableBounds(uint displayID, SdlRect* rect) => PInvoke.GetDisplayUsableBounds(displayID, rect) != 0; /// /// Get the orientation of a display when it is unrotated. /// /// the instance ID of the display to query. /// /// the SDL_DisplayOrientation enum value of the display, or /// SDL_ORIENTATION_UNKNOWN if it isn't available. /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// public static SdlDisplayOrientation GetNaturalDisplayOrientation(uint displayID) => PInvoke.GetNaturalDisplayOrientation(displayID); /// /// Get the orientation of a display. /// /// the instance ID of the display to query. /// /// the SDL_DisplayOrientation enum value of the display, or /// SDL_ORIENTATION_UNKNOWN if it isn't available. /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// public static SdlDisplayOrientation GetCurrentDisplayOrientation(uint displayID) => PInvoke.GetCurrentDisplayOrientation(displayID); /// /// Get the content scale of a display. /// /// the instance ID of the display to query. /// /// the content scale of the display, or 0.0f on failure; call /// SDL_GetError() for more information. /// /// /// /// 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, SDL_GetWindowDisplayScale() 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. /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// /// public static float GetDisplayContentScale(uint displayID) => PInvoke.GetDisplayContentScale(displayID); /// /// Ergonomic wrapper over SDL_GetFullscreenDisplayModes. /// /// the instance ID of the display to query. /// The SDL call failed; the message carries the /// SDL_GetError text. /// /// SDL returns a freshly SDL_malloc'd buffer for this call; the returned array is a managed copy, /// and the native buffer is freed with SDL_free before this method returns. /// public static SdlDisplayMode[] GetFullscreenDisplayModes(uint displayID) { int count; var ptr = PInvoke.GetFullscreenDisplayModes(displayID, &count); if (ptr is null) throw SdlException.FromError("SDL_GetFullscreenDisplayModes failed"); try { var result = new SdlDisplayMode[count]; for (var i = 0; i < count; i++) result[i] = *ptr[i]; return result; } finally { PInvoke.Free(ptr); } } /// /// Get the closest match to the requested display mode. /// /// the instance ID of the display to query. /// the width in pixels of the desired display mode. /// the height in pixels of the desired display mode. /// /// the refresh rate of the desired display mode, or 0.0f /// for the desktop refresh rate. /// /// /// boolean to include high density modes in /// the search. /// /// /// a pointer filled in with the closest display mode equal to /// or larger than the desired mode. /// /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// /// 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. /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// /// public static bool GetClosestFullscreenDisplayMode( uint displayID, int w, int h, float refresh_rate, bool include_high_density_modes, SdlDisplayMode* closest ) => PInvoke.GetClosestFullscreenDisplayMode( displayID, w, h, refresh_rate, include_high_density_modes ? (byte)1 : (byte)0, closest ) != 0; /// /// Get the display containing a point. /// /// the point to query. /// /// the instance ID of the display containing the point or 0 on /// failure; call SDL_GetError() for more information. /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// /// public static uint GetDisplayForPoint(SdlPoint* point) => PInvoke.GetDisplayForPoint(point); /// /// Get the display primarily containing a rect. /// /// the rect to query. /// /// the instance ID of the display entirely containing the rect or /// closest to the center of the rect on success or 0 on failure; call /// SDL_GetError() for more information. /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// /// public static uint GetDisplayForRect(SdlRect* rect) => PInvoke.GetDisplayForRect(rect); /// /// Get the display associated with a window. /// /// the window to query. /// /// the instance ID of the display containing the center of the window /// on success or 0 on failure; call SDL_GetError() for more /// information. /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// /// public static uint GetDisplayForWindow(SdlWindow window) => PInvoke.GetDisplayForWindow(window); /// /// Get the pixel density of a window. /// /// the window to query. /// /// the pixel density or 0.0f on failure; call SDL_GetError() for more /// information. /// /// /// /// 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. /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// public static float GetWindowPixelDensity(SdlWindow window) => PInvoke.GetWindowPixelDensity(window); /// /// Get the content display scale relative to a window's pixel size. /// /// the window to query. /// /// the display scale, or 0.0f on failure; call SDL_GetError() for /// more information. /// /// /// /// 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 function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// public static float GetWindowDisplayScale(SdlWindow window) => PInvoke.GetWindowDisplayScale(window); /// /// Set the display mode to use when a window is visible and fullscreen. /// /// the window to affect. /// /// a pointer to the display mode to use, which can be NULL for /// borderless fullscreen desktop mode, or one of the fullscreen /// modes returned by SDL_GetFullscreenDisplayModes() to set an /// exclusive fullscreen mode. /// /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// /// This only affects the display mode used when the window is fullscreen. To /// change the window size when the window is not fullscreen, use /// SDL_SetWindowSize(). /// /// /// 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 SDL_SyncWindow() to block until the changes have /// taken effect. /// /// /// When the new mode takes effect, an SDL_EVENT_WINDOW_RESIZED and/or an /// SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED event will be emitted with the new mode /// dimensions. /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// /// /// public static bool SetWindowFullscreenMode(SdlWindow window, SdlDisplayMode* mode) => PInvoke.SetWindowFullscreenMode(window, mode) != 0; /// /// Ergonomic wrapper over SDL_GetWindowICCProfile. /// /// the window to query. /// The SDL call failed; the message carries the /// SDL_GetError text. /// /// SDL returns a freshly SDL_malloc'd buffer for this call; the returned array is a managed copy, /// and the native buffer is freed with SDL_free before this method returns. /// public static byte[] GetWindowICCProfile(SdlWindow window) { nuint size; var ptr = PInvoke.GetWindowICCProfile(window, &size); if (ptr is null) throw SdlException.FromError("SDL_GetWindowICCProfile failed"); try { return new ReadOnlySpan(ptr, checked((int)size)).ToArray(); } finally { PInvoke.Free(ptr); } } /// /// Get the pixel format associated with the window. /// /// the window to query. /// /// the pixel format of the window on success or /// SDL_PIXELFORMAT_UNKNOWN on failure; call SDL_GetError() for more /// information. /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// public static SdlPixelFormat GetWindowPixelFormat(SdlWindow window) => PInvoke.GetWindowPixelFormat(window); /// /// Ergonomic wrapper over SDL_GetWindows. /// /// The SDL call failed; the message carries the /// SDL_GetError text. /// /// SDL returns a freshly SDL_malloc'd buffer for this call; the returned array is a managed copy, /// and the native buffer is freed with SDL_free before this method returns. Each element is a /// borrowed handle: it is owned by SDL, not created by this call, and must not be disposed. Do not /// call on any element. /// public static SdlWindow[] GetWindows() { int count; var ptr = PInvoke.GetWindows(&count); if (ptr is null) throw SdlException.FromError("SDL_GetWindows failed"); try { return new ReadOnlySpan(ptr, count).ToArray(); } finally { PInvoke.Free(ptr); } } /// /// Ergonomic wrapper over SDL_CreateWindow. Throws instead of returning a null handle on failure. /// /// the title of the window, in UTF-8 encoding. /// the width of the window. /// the height of the window. /// 0, or one or more SDL_WindowFlags OR'd together. /// The created handle (never a null handle). /// The SDL call failed; the message carries the /// SDL_GetError text. public static SdlWindow CreateWindow(string title, int w, int h, SdlWindowFlags flags) { SdlWindow result = PInvoke.CreateWindow(title, w, h, flags); if (result.IsNull()) { throw SdlException.FromError("SDL_CreateWindow failed"); } return result; } /// /// Ergonomic wrapper over SDL_CreatePopupWindow. Throws instead of returning a null handle on /// failure. /// /// the parent of the window, must not be NULL. /// /// the x position of the popup window relative to the origin /// of the parent. /// /// /// the y position of the popup window relative to the origin /// of the parent window. /// /// the width of the window. /// the height of the window. /// /// SDL_WINDOW_TOOLTIP or SDL_WINDOW_POPUP_MENU, and zero or more /// additional SDL_WindowFlags OR'd together. /// /// The created handle (never a null handle). /// The SDL call failed; the message carries the /// SDL_GetError text. public static SdlWindow CreatePopupWindow( SdlWindow parent, int offset_x, int offset_y, int w, int h, SdlWindowFlags flags ) { SdlWindow result = PInvoke.CreatePopupWindow(parent, offset_x, offset_y, w, h, flags); if (result.IsNull()) { throw SdlException.FromError("SDL_CreatePopupWindow failed"); } return result; } /// /// Ergonomic wrapper over SDL_CreateWindowWithProperties. Throws instead of returning a null /// handle on failure. /// /// the properties to use. /// The created handle (never a null handle). /// The SDL call failed; the message carries the /// SDL_GetError text. public static SdlWindow CreateWindowWithProperties(uint props) { SdlWindow result = PInvoke.CreateWindowWithProperties(props); if (result.IsNull()) { throw SdlException.FromError("SDL_CreateWindowWithProperties failed"); } return result; } /// /// Get the numeric ID of a window. /// /// the window to query. /// /// the ID of the window on success or 0 on failure; call /// SDL_GetError() for more information. /// /// /// /// The numeric ID is what SDL_WindowEvent references, and is necessary to map /// these events to specific SDL_Window objects. /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// public static uint GetWindowID(SdlWindow window) => PInvoke.GetWindowID(window); /// /// Ergonomic wrapper over SDL_GetWindowFromID. /// /// the ID of the window. /// /// Borrowed handle: the returned handle is owned by SDL (or by another object) and must not be /// disposed. Do not call on it; doing so would free a resource /// this call does not own. A null handle is returned on failure. /// public static SdlWindow GetWindowFromID(uint id) => PInvoke.GetWindowFromID(id); /// /// Ergonomic wrapper over SDL_GetWindowParent. /// /// the window to query. /// /// Borrowed handle: the returned handle is owned by SDL (or by another object) and must not be /// disposed. Do not call on it; doing so would free a resource /// this call does not own. A null handle is returned on failure. /// public static SdlWindow GetWindowParent(SdlWindow window) => PInvoke.GetWindowParent(window); /// /// Get the properties associated with a window. /// /// the window to query. /// /// a valid property ID on success or 0 on failure; call /// SDL_GetError() for more information. /// /// /// /// The following read-only properties are provided by SDL: /// /// /// - SDL_PROP_WINDOW_SHAPE_POINTER: the surface associated with a shaped /// window /// - SDL_PROP_WINDOW_HDR_ENABLED_BOOLEAN: true if the window has HDR /// headroom above the SDR white point. This property can change dynamically /// when SDL_EVENT_WINDOW_HDR_STATE_CHANGED is sent. /// - SDL_PROP_WINDOW_SDR_WHITE_LEVEL_FLOAT: the value of SDR white in the /// SDL_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 /// SDL_EVENT_WINDOW_HDR_STATE_CHANGED is sent. /// - SDL_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 /// SDL_EVENT_WINDOW_HDR_STATE_CHANGED is sent. /// /// /// On Android: /// /// /// - SDL_PROP_WINDOW_ANDROID_WINDOW_POINTER: the ANativeWindow associated /// with the window /// - SDL_PROP_WINDOW_ANDROID_SURFACE_POINTER: the EGLSurface associated with /// the window /// /// /// On iOS: /// /// /// - SDL_PROP_WINDOW_UIKIT_WINDOW_POINTER: the (__unsafe_unretained) /// UIWindow associated with the window /// - SDL_PROP_WINDOW_UIKIT_METAL_VIEW_TAG_NUMBER: the NSInteger tag /// associated with metal views on the window /// - SDL_PROP_WINDOW_UIKIT_OPENGL_FRAMEBUFFER_NUMBER: the OpenGL view's /// framebuffer object. It must be bound when rendering to the screen using /// OpenGL. /// - SDL_PROP_WINDOW_UIKIT_OPENGL_RENDERBUFFER_NUMBER: the OpenGL view's /// renderbuffer object. It must be bound when SDL_GL_SwapWindow is called. /// - SDL_PROP_WINDOW_UIKIT_OPENGL_RESOLVE_FRAMEBUFFER_NUMBER: the OpenGL /// view's resolve framebuffer, when MSAA is used. /// /// /// On KMS/DRM: /// /// /// - SDL_PROP_WINDOW_KMSDRM_DEVICE_INDEX_NUMBER: the device index associated /// with the window (e.g. the X in /dev/dri/cardX) /// - SDL_PROP_WINDOW_KMSDRM_DRM_FD_NUMBER: the DRM FD associated with the /// window /// - SDL_PROP_WINDOW_KMSDRM_GBM_DEVICE_POINTER: the GBM device associated /// with the window /// /// /// On macOS: /// /// /// - SDL_PROP_WINDOW_COCOA_WINDOW_POINTER: the (__unsafe_unretained) /// NSWindow associated with the window /// - SDL_PROP_WINDOW_COCOA_METAL_VIEW_TAG_NUMBER: the NSInteger tag /// associated with metal views on the window /// /// /// On OpenVR: /// /// /// - SDL_PROP_WINDOW_OPENVR_OVERLAY_ID_NUMBER: the OpenVR Overlay Handle ID /// for the associated overlay window. /// /// /// On Vivante: /// /// /// - SDL_PROP_WINDOW_VIVANTE_DISPLAY_POINTER: the EGLNativeDisplayType /// associated with the window /// - SDL_PROP_WINDOW_VIVANTE_WINDOW_POINTER: the EGLNativeWindowType /// associated with the window /// - SDL_PROP_WINDOW_VIVANTE_SURFACE_POINTER: the EGLSurface associated with /// the window /// /// /// On Windows: /// /// /// - SDL_PROP_WINDOW_WIN32_HWND_POINTER: the HWND associated with the window /// - SDL_PROP_WINDOW_WIN32_HDC_POINTER: the HDC associated with the window /// - SDL_PROP_WINDOW_WIN32_INSTANCE_POINTER: the HINSTANCE associated with /// the window /// /// /// On 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. /// /// /// - SDL_PROP_WINDOW_WAYLAND_DISPLAY_POINTER: the wl_display associated with /// the window /// - SDL_PROP_WINDOW_WAYLAND_SURFACE_POINTER: the wl_surface associated with /// the window /// - SDL_PROP_WINDOW_WAYLAND_VIEWPORT_POINTER: the wp_viewport associated /// with the window /// - SDL_PROP_WINDOW_WAYLAND_EGL_WINDOW_POINTER: the wl_egl_window /// associated with the window /// - SDL_PROP_WINDOW_WAYLAND_XDG_SURFACE_POINTER: the xdg_surface associated /// with the window /// - SDL_PROP_WINDOW_WAYLAND_XDG_TOPLEVEL_POINTER: the xdg_toplevel role /// associated with the window /// - 'SDL_PROP_WINDOW_WAYLAND_XDG_TOPLEVEL_EXPORT_HANDLE_STRING': the export /// handle associated with the window /// - SDL_PROP_WINDOW_WAYLAND_XDG_POPUP_POINTER: the xdg_popup role /// associated with the window /// - SDL_PROP_WINDOW_WAYLAND_XDG_POSITIONER_POINTER: the xdg_positioner /// associated with the window, in popup mode /// /// /// On X11: /// /// /// - SDL_PROP_WINDOW_X11_DISPLAY_POINTER: the X11 Display associated with /// the window /// - SDL_PROP_WINDOW_X11_SCREEN_NUMBER: the screen number associated with /// the window /// - SDL_PROP_WINDOW_X11_WINDOW_NUMBER: the X11 Window associated with the /// window /// /// /// On Emscripten: /// /// /// - SDL_PROP_WINDOW_EMSCRIPTEN_CANVAS_ID_STRING: the id the canvas element /// will have /// - SDL_PROP_WINDOW_EMSCRIPTEN_KEYBOARD_ELEMENT_STRING: the keyboard /// element that associates keyboard events to this window /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// public static uint GetWindowProperties(SdlWindow window) => PInvoke.GetWindowProperties(window); /// /// Get the window flags. /// /// the window to query. /// a mask of the SDL_WindowFlags associated with window. /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// /// /// /// /// /// /// /// public static SdlWindowFlags GetWindowFlags(SdlWindow window) => PInvoke.GetWindowFlags(window); /// /// Set the title of a window. /// /// the window to change. /// the desired window title in UTF-8 format. /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// /// This string is expected to be in UTF-8 encoding. /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// public static bool SetWindowTitle(SdlWindow window, string title) => PInvoke.SetWindowTitle(window, title) != 0; /// /// Get the title of a window. /// /// the window to query. /// /// the title of the window in UTF-8 format or "" if there is no /// title. /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// public static string? GetWindowTitle(SdlWindow window) => PInvoke.GetWindowTitle(window); /// /// Set the icon for a window. /// /// the window to change. /// an SDL_Surface structure containing the icon for the window. /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// /// If this function is passed a surface with alternate representations added /// using SDL_AddSurfaceAlternateImage(), 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. /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// public static bool SetWindowIcon(SdlWindow window, SdlSurface* icon) => PInvoke.SetWindowIcon(window, icon) != 0; /// /// Request that the window's position be set. /// /// the window to reposition. /// /// the x coordinate of the window, or SDL_WINDOWPOS_CENTERED or /// SDL_WINDOWPOS_UNDEFINED. /// /// /// the y coordinate of the window, or SDL_WINDOWPOS_CENTERED or /// SDL_WINDOWPOS_UNDEFINED. /// /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// /// 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 /// SDL_SetWindowFullscreenMode(). /// /// /// 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 SDL_SyncWindow() to /// block until the changes have taken effect. /// /// /// When the window position changes, an SDL_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. /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// /// public static bool SetWindowPosition(SdlWindow window, int x, int y) => PInvoke.SetWindowPosition(window, x, y) != 0; /// /// Get the position of a window. /// /// the window to query. /// /// a pointer filled in with the x position of the window, may be /// NULL. /// /// /// a pointer filled in with the y position of the window, may be /// NULL. /// /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// /// 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 NULL may be passed /// in the x or y parameter. /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// public static bool GetWindowPosition(SdlWindow window, out int x, out int y) { x = default; y = default; fixed (int* xPtr = &x) { fixed (int* yPtr = &y) { return PInvoke.GetWindowPosition(window, xPtr, yPtr) != 0; } } } /// /// Request that the size of a window's client area be set. /// /// the window to change. /// the width of the window, must be > 0. /// the height of the window, must be > 0. /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// /// 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 /// SDL_SetWindowFullscreenMode(). /// /// /// 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 SDL_SyncWindow() to /// block until the changes have taken effect. /// /// /// When the window size changes, an SDL_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. /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// /// /// public static bool SetWindowSize(SdlWindow window, int w, int h) => PInvoke.SetWindowSize(window, w, h) != 0; /// /// Get the size of a window's client area. /// /// the window to query the width and height from. /// a pointer filled in with the width of the window, may be NULL. /// a pointer filled in with the height of the window, may be NULL. /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// /// The window pixel size may differ from its window coordinate size if the /// window is on a high pixel density display. Use SDL_GetWindowSizeInPixels() /// or SDL_GetRenderOutputSize() to get the real client area size in pixels. /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// /// /// public static bool GetWindowSize(SdlWindow window, out int w, out int h) { w = default; h = default; fixed (int* wPtr = &w) { fixed (int* hPtr = &h) { return PInvoke.GetWindowSize(window, wPtr, hPtr) != 0; } } } /// /// Get the safe area for this window. /// /// the window to query. /// /// a pointer filled in with the client area that is safe for /// interactive content. /// /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// /// 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 interactable content. /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// public static bool GetWindowSafeArea(SdlWindow window, SdlRect* rect) => PInvoke.GetWindowSafeArea(window, rect) != 0; /// /// Request that the aspect ratio of a window's client area be set. /// /// the window to change. /// /// the minimum aspect ratio of the window, or 0.0f for no /// limit. /// /// /// the maximum aspect ratio of the window, or 0.0f for no /// limit. /// /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// /// 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 SDL_SyncWindow() to /// block until the changes have taken effect. /// /// /// When the window size changes, an SDL_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. /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// /// public static bool SetWindowAspectRatio(SdlWindow window, float min_aspect, float max_aspect) => PInvoke.SetWindowAspectRatio(window, min_aspect, max_aspect) != 0; /// /// Get the aspect ratio of a window's client area. /// /// the window to query the width and height from. /// /// a pointer filled in with the minimum aspect ratio of the /// window, may be NULL. /// /// /// a pointer filled in with the maximum aspect ratio of the /// window, may be NULL. /// /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// public static bool GetWindowAspectRatio(SdlWindow window, out float min_aspect, out float max_aspect) { min_aspect = default; max_aspect = default; fixed (float* min_aspectPtr = &min_aspect) { fixed (float* max_aspectPtr = &max_aspect) { return PInvoke.GetWindowAspectRatio(window, min_aspectPtr, max_aspectPtr) != 0; } } } /// /// Get the size of a window's borders (decorations) around the client area. /// /// /// the window to query the size values of the border /// (decorations) from. /// /// /// pointer to variable for storing the size of the top border; NULL /// is permitted. /// /// /// pointer to variable for storing the size of the left border; /// NULL is permitted. /// /// /// pointer to variable for storing the size of the bottom /// border; NULL is permitted. /// /// /// pointer to variable for storing the size of the right border; /// NULL is permitted. /// /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// /// Note: If this function fails (returns false), the size values will be /// initialized to 0, 0, 0, 0 (if a non-NULL pointer is provided), as if the /// window in question was borderless. /// /// /// Note: This function may fail on systems where the window has not yet been /// decorated by the display server (for example, immediately after calling /// SDL_CreateWindow). 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. /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// public static bool GetWindowBordersSize( SdlWindow window, out int top, out int left, out int bottom, out int right ) { top = default; left = default; bottom = default; right = default; fixed (int* topPtr = &top) { fixed (int* leftPtr = &left) { fixed (int* bottomPtr = &bottom) { fixed (int* rightPtr = &right) { return PInvoke.GetWindowBordersSize(window, topPtr, leftPtr, bottomPtr, rightPtr) != 0; } } } } } /// /// Get the size of a window's client area, in pixels. /// /// the window from which the drawable size should be queried. /// /// a pointer to variable for storing the width in pixels, may be /// NULL. /// /// /// a pointer to variable for storing the height in pixels, may be /// NULL. /// /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// /// public static bool GetWindowSizeInPixels(SdlWindow window, out int w, out int h) { w = default; h = default; fixed (int* wPtr = &w) { fixed (int* hPtr = &h) { return PInvoke.GetWindowSizeInPixels(window, wPtr, hPtr) != 0; } } } /// /// Set the minimum size of a window's client area. /// /// the window to change. /// the minimum width of the window, or 0 for no limit. /// the minimum height of the window, or 0 for no limit. /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// /// public static bool SetWindowMinimumSize(SdlWindow window, int min_w, int min_h) => PInvoke.SetWindowMinimumSize(window, min_w, min_h) != 0; /// /// Get the minimum size of a window's client area. /// /// the window to query. /// /// a pointer filled in with the minimum width of the window, may be /// NULL. /// /// /// a pointer filled in with the minimum height of the window, may be /// NULL. /// /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// /// public static bool GetWindowMinimumSize(SdlWindow window, out int w, out int h) { w = default; h = default; fixed (int* wPtr = &w) { fixed (int* hPtr = &h) { return PInvoke.GetWindowMinimumSize(window, wPtr, hPtr) != 0; } } } /// /// Set the maximum size of a window's client area. /// /// the window to change. /// the maximum width of the window, or 0 for no limit. /// the maximum height of the window, or 0 for no limit. /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// /// public static bool SetWindowMaximumSize(SdlWindow window, int max_w, int max_h) => PInvoke.SetWindowMaximumSize(window, max_w, max_h) != 0; /// /// Get the maximum size of a window's client area. /// /// the window to query. /// /// a pointer filled in with the maximum width of the window, may be /// NULL. /// /// /// a pointer filled in with the maximum height of the window, may be /// NULL. /// /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// /// public static bool GetWindowMaximumSize(SdlWindow window, out int w, out int h) { w = default; h = default; fixed (int* wPtr = &w) { fixed (int* hPtr = &h) { return PInvoke.GetWindowMaximumSize(window, wPtr, hPtr) != 0; } } } /// /// Set the border state of a window. /// /// the window of which to change the border state. /// false to remove border, true to add border. /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// /// This will add or remove the window's SDL_WINDOW_BORDERLESS flag and add /// or remove the border from the actual window. This is a no-op if the /// window's border already matches the requested state. /// /// /// You can't change the border state of a fullscreen window. /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// public static bool SetWindowBordered(SdlWindow window, bool bordered) => PInvoke.SetWindowBordered(window, bordered ? (byte)1 : (byte)0) != 0; /// /// Set the user-resizable state of a window. /// /// the window of which to change the resizable state. /// true to allow resizing, false to disallow. /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// /// This will add or remove the window's SDL_WINDOW_RESIZABLE flag and /// allow/disallow user resizing of the window. This is a no-op if the window's /// resizable state already matches the requested state. /// /// /// You can't change the resizable state of a fullscreen window. /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// public static bool SetWindowResizable(SdlWindow window, bool resizable) => PInvoke.SetWindowResizable(window, resizable ? (byte)1 : (byte)0) != 0; /// /// Set the window to always be above the others. /// /// the window of which to change the always on top state. /// true to set the window always on top, false to disable. /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// /// This will add or remove the window's SDL_WINDOW_ALWAYS_ON_TOP flag. This /// will bring the window to the front and keep the window above the rest. /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// public static bool SetWindowAlwaysOnTop(SdlWindow window, bool on_top) => PInvoke.SetWindowAlwaysOnTop(window, on_top ? (byte)1 : (byte)0) != 0; /// /// Set the window to fill the current document space (Emscripten only). /// /// the window of which to change the fill-document state. /// true to set the window to fill the document, false to disable. /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// /// This will add or remove the window's SDL_WINDOW_FILL_DOCUMENT flag. /// /// /// Currently this flag only applies to the Emscripten target. /// /// /// When enabled, the canvas element fills the entire document. Resize events /// will be generated as the browser window is resized, as that will adjust the /// canvas size as well. The canvas will cover anything else on the page, /// including any controls provided by Emscripten in its generated HTML file /// (in fact, any elements on the page that aren't the canvas will be moved /// into a hidden div element). /// /// /// Often times this is desirable for a browser-based game, but it means /// several things that we expect of an SDL window on other platforms might not /// work as expected, such as minimum window sizes and aspect ratios. /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.4.0. /// /// public static bool SetWindowFillDocument(SdlWindow window, bool fill) => PInvoke.SetWindowFillDocument(window, fill ? (byte)1 : (byte)0) != 0; /// /// Show a window. /// /// the window to show. /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// /// public static bool ShowWindow(SdlWindow window) => PInvoke.ShowWindow(window) != 0; /// /// Hide a window. /// /// the window to hide. /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// public static bool HideWindow(SdlWindow window) => PInvoke.HideWindow(window) != 0; /// /// Request that a window be raised above other windows and gain the input /// focus. /// /// the window to raise. /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// /// 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 SDL_EVENT_WINDOW_FOCUS_GAINED event will be emitted, and /// the window will have the SDL_WINDOW_INPUT_FOCUS flag set. /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// public static bool RaiseWindow(SdlWindow window) => PInvoke.RaiseWindow(window) != 0; /// /// Request that the window be made as large as possible. /// /// the window to maximize. /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// /// Non-resizable windows can't be maximized. The window must have the /// SDL_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 SDL_SyncWindow() to /// block until the changes have taken effect. /// /// /// When the window state changes, an SDL_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 /// SDL_SetWindowMaximumSize() 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. /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// /// /// public static bool MaximizeWindow(SdlWindow window) => PInvoke.MaximizeWindow(window) != 0; /// /// Request that the window be minimized to an iconic representation. /// /// the window to minimize. /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// /// 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 SDL_SyncWindow() to /// block until the changes have taken effect. /// /// /// When the window state changes, an SDL_EVENT_WINDOW_MINIMIZED event will be /// emitted. Note that, as this is just a request, the windowing system can /// deny the state change. /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// /// /// public static bool MinimizeWindow(SdlWindow window) => PInvoke.MinimizeWindow(window) != 0; /// /// Request that the size and position of a minimized or maximized window be /// restored. /// /// the window to restore. /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// /// 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 SDL_SyncWindow() to /// block until the changes have taken effect. /// /// /// When the window state changes, an SDL_EVENT_WINDOW_RESTORED event will be /// emitted. Note that, as this is just a request, the windowing system can /// deny the state change. /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// /// /// public static bool RestoreWindow(SdlWindow window) => PInvoke.RestoreWindow(window) != 0; /// /// Request that the window's fullscreen state be changed. /// /// the window to change. /// true for fullscreen mode, false for windowed mode. /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// /// By default a window in fullscreen state uses borderless fullscreen desktop /// mode, but a specific exclusive display mode can be set using /// SDL_SetWindowFullscreenMode(). /// /// /// 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 SDL_SyncWindow() /// to block until the changes have taken effect. /// /// /// When the window state changes, an SDL_EVENT_WINDOW_ENTER_FULLSCREEN or /// SDL_EVENT_WINDOW_LEAVE_FULLSCREEN event will be emitted. Note that, as this /// is just a request, it can be denied by the windowing system. /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// /// /// public static bool SetWindowFullscreen(SdlWindow window, bool fullscreen) => PInvoke.SetWindowFullscreen(window, fullscreen ? (byte)1 : (byte)0) != 0; /// /// Block until any pending window state is finalized. /// /// /// the window for which to wait for the pending state to be /// applied. /// /// /// true on success or false if the operation timed out before the /// window was in the requested state. /// /// /// /// 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. /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// /// /// /// /// /// public static bool SyncWindow(SdlWindow window) => PInvoke.SyncWindow(window) != 0; /// /// Return whether the window has a surface associated with it. /// /// the window to query. /// /// true if there is a surface associated with the window, or false /// otherwise. /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// public static bool WindowHasSurface(SdlWindow window) => PInvoke.WindowHasSurface(window) != 0; /// /// Toggle VSync for the window surface. /// /// the window. /// the vertical refresh sync interval. /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// /// When a window surface is created, vsync defaults to /// SDL_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., /// SDL_WINDOW_SURFACE_VSYNC_ADAPTIVE for late swap tearing (adaptive vsync), /// or SDL_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. /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// public static bool SetWindowSurfaceVSync(SdlWindow window, int vsync) => PInvoke.SetWindowSurfaceVSync(window, vsync) != 0; /// /// Get VSync for the window surface. /// /// the window to query. /// /// an int filled with the current vertical refresh sync interval. /// See SDL_SetWindowSurfaceVSync() for the meaning of the value. /// /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// public static bool GetWindowSurfaceVSync(SdlWindow window, out int vsync) { vsync = default; fixed (int* vsyncPtr = &vsync) { return PInvoke.GetWindowSurfaceVSync(window, vsyncPtr) != 0; } } /// /// Copy the window surface to the screen. /// /// the window to update. /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// /// 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(). /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// /// public static bool UpdateWindowSurface(SdlWindow window) => PInvoke.UpdateWindowSurface(window) != 0; /// /// Copy areas of the window surface to the screen. /// /// the window to update. /// /// an array of SDL_Rect structures representing areas of the /// surface to copy, in pixels. /// /// the number of rectangles. /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// /// 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. /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// /// public static bool UpdateWindowSurfaceRects(SdlWindow window, SdlRect* rects, int numrects) => PInvoke.UpdateWindowSurfaceRects(window, rects, numrects) != 0; /// /// Destroy the surface associated with the window. /// /// the window to update. /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// /// public static bool DestroyWindowSurface(SdlWindow window) => PInvoke.DestroyWindowSurface(window) != 0; /// /// Set a window's keyboard grab mode. /// /// the window for which the keyboard grab mode should be set. /// this is true to grab keyboard, and false to release. /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// /// 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. /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// /// public static bool SetWindowKeyboardGrab(SdlWindow window, bool grabbed) => PInvoke.SetWindowKeyboardGrab(window, grabbed ? (byte)1 : (byte)0) != 0; /// /// Set a window's mouse grab mode. /// /// the window for which the mouse grab mode should be set. /// this is true to grab mouse, and false to release. /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// /// Mouse grab confines the mouse cursor to the window. /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// /// /// public static bool SetWindowMouseGrab(SdlWindow window, bool grabbed) => PInvoke.SetWindowMouseGrab(window, grabbed ? (byte)1 : (byte)0) != 0; /// /// Get a window's keyboard grab mode. /// /// the window to query. /// true if keyboard is grabbed, and false otherwise. /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// public static bool GetWindowKeyboardGrab(SdlWindow window) => PInvoke.GetWindowKeyboardGrab(window) != 0; /// /// Get a window's mouse grab mode. /// /// the window to query. /// true if mouse is grabbed, and false otherwise. /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// /// /// /// public static bool GetWindowMouseGrab(SdlWindow window) => PInvoke.GetWindowMouseGrab(window) != 0; /// /// Ergonomic wrapper over SDL_GetGrabbedWindow. /// /// /// Borrowed handle: the returned handle is owned by SDL (or by another object) and must not be /// disposed. Do not call on it; doing so would free a resource /// this call does not own. A null handle is returned on failure. /// public static SdlWindow GetGrabbedWindow() => PInvoke.GetGrabbedWindow(); /// /// Confines the cursor to the specified area of a window. /// /// the window that will be associated with the barrier. /// /// a rectangle area in window-relative coordinates. If NULL the /// barrier for the specified window will be destroyed. /// /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// /// Note that this does NOT grab the cursor, it only defines the area a cursor /// is restricted to when the window has mouse focus. /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// /// /// public static bool SetWindowMouseRect(SdlWindow window, SdlRect* rect) => PInvoke.SetWindowMouseRect(window, rect) != 0; /// /// Set the opacity for a window. /// /// the window which will be made transparent or opaque. /// the opacity value (0.0f - transparent, 1.0f - opaque). /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// /// 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. /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// public static bool SetWindowOpacity(SdlWindow window, float opacity) => PInvoke.SetWindowOpacity(window, opacity) != 0; /// /// Get the opacity of a window. /// /// the window to get the current opacity value from. /// /// the opacity, (0.0f - transparent, 1.0f - opaque), or -1.0f on /// failure; call SDL_GetError() for more information. /// /// /// /// If transparency isn't supported on this platform, opacity will be returned /// as 1.0f without error. /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// public static float GetWindowOpacity(SdlWindow window) => PInvoke.GetWindowOpacity(window); /// /// Set the window as a child of a parent window. /// /// the window that should become the child of a parent. /// the new parent window for the child window. /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// /// If the window is already the child of an existing window, it will be /// reparented to the new owner. Setting the parent window to NULL 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 SDL_SetWindowModal() 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. /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// public static bool SetWindowParent(SdlWindow window, SdlWindow parent) => PInvoke.SetWindowParent(window, parent) != 0; /// /// Toggle the state of the window as modal. /// /// the window on which to set the modal state. /// true to toggle modal status on, false to toggle it off. /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// /// 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. /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// public static bool SetWindowModal(SdlWindow window, bool modal) => PInvoke.SetWindowModal(window, modal ? (byte)1 : (byte)0) != 0; /// /// Set whether the window may have input focus. /// /// the window to set focusable state. /// true to allow input focus, false to not allow input focus. /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// public static bool SetWindowFocusable(SdlWindow window, bool focusable) => PInvoke.SetWindowFocusable(window, focusable ? (byte)1 : (byte)0) != 0; /// /// Display the system-level window menu. /// /// the window for which the menu will be displayed. /// /// the x coordinate of the menu, relative to the origin (top-left) of /// the client area. /// /// /// the y coordinate of the menu, relative to the origin (top-left) of /// the client area. /// /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// /// 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. /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// public static bool ShowWindowSystemMenu(SdlWindow window, int x, int y) => PInvoke.ShowWindowSystemMenu(window, x, y) != 0; /// /// Set the shape of a transparent window. /// /// the window. /// /// the surface representing the shape of the window, or NULL to /// remove any current shape. /// /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// /// 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 SDL_SetWindowShape() again to /// update the window. This is an expensive operation, so should be done /// sparingly. /// /// /// The window must have been created with the SDL_WINDOW_TRANSPARENT flag. /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// public static bool SetWindowShape(SdlWindow window, SdlSurface* shape) => PInvoke.SetWindowShape(window, shape) != 0; /// /// Request a window to demand attention from the user. /// /// the window to be flashed. /// the operation to perform. /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// public static bool FlashWindow(SdlWindow window, SdlFlashOperation operation) => PInvoke.FlashWindow(window, operation) != 0; /// /// Sets the state of the progress bar for the given window’s taskbar icon. /// /// the window whose progress state is to be modified. /// /// the progress state. SDL_PROGRESS_STATE_NONE stops displaying /// the progress bar. /// /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.4.0. /// public static bool SetWindowProgressState(SdlWindow window, SdlProgressState state) => PInvoke.SetWindowProgressState(window, state) != 0; /// /// Get the state of the progress bar for the given window’s taskbar icon. /// /// the window to get the current progress state from. /// /// the progress state, or SDL_PROGRESS_STATE_INVALID on failure; /// call SDL_GetError() for more information. /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.4.0. /// public static SdlProgressState GetWindowProgressState(SdlWindow window) => PInvoke.GetWindowProgressState(window); /// /// Sets the value of the progress bar for the given window’s taskbar icon. /// /// the window whose progress value is to be modified. /// /// the progress value in the range of [0.0f - 1.0f]. If the value /// is outside the valid range, it gets clamped. /// /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.4.0. /// public static bool SetWindowProgressValue(SdlWindow window, float value) => PInvoke.SetWindowProgressValue(window, value) != 0; /// /// Get the value of the progress bar for the given window’s taskbar icon. /// /// the window to get the current progress value from. /// /// the progress value in the range of [0.0f - 1.0f], or -1.0f on /// failure; call SDL_GetError() for more information. /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.4.0. /// public static float GetWindowProgressValue(SdlWindow window) => PInvoke.GetWindowProgressValue(window); /// /// Destroy a window. /// /// the window to destroy. /// /// /// 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 /// SDL_Window is no longer valid after this call. /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// /// /// public static void DestroyWindow(SdlWindow window) => PInvoke.DestroyWindow(window); /// /// Check whether the screensaver is currently enabled. /// /// true if the screensaver is enabled, false if it is disabled. /// /// /// The screensaver is disabled by default. /// /// /// The default can also be changed using SDL_HINT_VIDEO_ALLOW_SCREENSAVER. /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// /// public static bool ScreenSaverEnabled() => PInvoke.ScreenSaverEnabled() != 0; /// /// Allow the screen to be blanked by a screen saver. /// /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// /// public static bool EnableScreenSaver() => PInvoke.EnableScreenSaver() != 0; /// /// Prevent the screen from being blanked by a screen saver. /// /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// /// 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. /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// /// public static bool DisableScreenSaver() => PInvoke.DisableScreenSaver() != 0; /// /// Dynamically load an OpenGL library. /// /// /// the platform dependent OpenGL library name, or NULL to open the /// default OpenGL library. /// /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// /// 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 SDL_GL_GetProcAddress(). /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// /// public static bool GLLoadLibrary(string path) => PInvoke.GLLoadLibrary(path) != 0; /// /// Unload the OpenGL library previously loaded by SDL_GL_LoadLibrary(). /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// public static void GLUnloadLibrary() => PInvoke.GLUnloadLibrary(); /// /// Check if an OpenGL extension is supported for the current context. /// /// the name of the extension to check. /// true if the extension is supported, false otherwise. /// /// /// 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. /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// public static bool GLExtensionSupported(string extension) => PInvoke.GLExtensionSupported(extension) != 0; /// /// Reset all previously set OpenGL context attributes to their default values. /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// /// public static void GLResetAttributes() => PInvoke.GLResetAttributes(); /// /// Set an OpenGL window attribute before window creation. /// /// an enum value specifying the OpenGL attribute to set. /// the desired value for the attribute. /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// /// This function sets the OpenGL attribute attr to value. The requested /// attributes should be set before creating an OpenGL window. You should use /// SDL_GL_GetAttribute() to check the values after creating the OpenGL /// context, since the values obtained can differ from the requested ones. /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// /// /// public static bool GLSetAttribute(SdlGLAttr attr, int value) => PInvoke.GLSetAttribute(attr, value) != 0; /// /// Get the actual value for an attribute from the current context. /// /// /// an SDL_GLAttr enum value specifying the OpenGL attribute to /// get. /// /// a pointer filled in with the current value of attr. /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// /// public static bool GLGetAttribute(SdlGLAttr attr, out int value) { value = default; fixed (int* valuePtr = &value) { return PInvoke.GLGetAttribute(attr, valuePtr) != 0; } } /// /// Create an OpenGL context for an OpenGL window, and make it current. /// /// the window to associate with the context. /// /// the OpenGL context associated with window or NULL on failure; /// call SDL_GetError() for more information. /// /// /// /// The OpenGL context will be created with the current states set through /// SDL_GL_SetAttribute(). /// /// /// The SDL_Window specified must have been created with the SDL_WINDOW_OPENGL /// flag, or context creation will fail. /// /// /// 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 SDL_GL_GetProcAddress() and its related /// functions. /// /// /// SDL_GLContext is opaque to the application. /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// /// public static nint GLCreateContext(SdlWindow window) => PInvoke.GLCreateContext(window); /// /// Set up an OpenGL context for rendering into an OpenGL window. /// /// the window to associate with the context. /// the OpenGL context to associate with the window. /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// /// The context must have been created with a compatible window. /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// public static bool GLMakeCurrent(SdlWindow window, nint context) => PInvoke.GLMakeCurrent(window, context) != 0; /// /// Ergonomic wrapper over SDL_GL_GetCurrentWindow. /// /// /// Borrowed handle: the returned handle is owned by SDL (or by another object) and must not be /// disposed. Do not call on it; doing so would free a resource /// this call does not own. A null handle is returned on failure. /// public static SdlWindow GLGetCurrentWindow() => PInvoke.GLGetCurrentWindow(); /// /// Get the currently active OpenGL context. /// /// /// the currently active OpenGL context or NULL on failure; call /// SDL_GetError() for more information. /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// public static nint GLGetCurrentContext() => PInvoke.GLGetCurrentContext(); /// /// Set the swap interval for the current OpenGL context. /// /// /// 0 for immediate updates, 1 for updates synchronized with /// the vertical retrace, -1 for adaptive vsync. /// /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// /// 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 /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// public static bool GLSetSwapInterval(int interval) => PInvoke.GLSetSwapInterval(interval) != 0; /// /// Get the swap interval for the current OpenGL context. /// /// /// 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. /// /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// /// 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. /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// public static bool GLGetSwapInterval(out int interval) { interval = default; fixed (int* intervalPtr = &interval) { return PInvoke.GLGetSwapInterval(intervalPtr) != 0; } } /// /// Update a window with OpenGL rendering. /// /// the window to change. /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// /// 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. /// /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// public static bool GLSwapWindow(SdlWindow window) => PInvoke.GLSwapWindow(window) != 0; /// /// Delete an OpenGL context. /// /// the OpenGL context to be deleted. /// /// true on success or false on failure; call SDL_GetError() for more /// information. /// /// /// This function should only be called on the main thread. /// /// /// This function is available since SDL 3.2.0. /// /// public static bool GLDestroyContext(nint context) => PInvoke.GLDestroyContext(context) != 0; } } }