Class Window

D class that wraps SDL_Window managing a window instance specific to the OS

class Window ;

dsdl2.Window provides access to creating windows and managing them for rendering. Internally, SDL uses OS functions to summon the window.

Constructors

NameDescription
this (sdlWindow, isOwner, userRef) Constructs a dsdl2.Window from a vanilla SDL_Window* from bindbc-sdl
this (nativeHandle) Creates an SDL-handled window from a native pointer handle of the OS, which wraps SDL_CreateWindowFrom
this (title, position, size, shaped, fullscreen, fullscreenDesktop, openGL, shown, hidden, borderless, resizable, minimized, maximized, inputGrabbed, inputFocus, mouseFocus, foreign, allowHighDPI, mouseCapture, alwaysOnTop, skipTaskbar, utility, tooltip, popupMenu, vulkan, metal, mouseGrabbed, keyboardGrabbed) Creates a window on the desktop placed at a coordinate in the screen, which wraps SDL_CreateWindow

Fields

NameTypeDescription
sdlWindow sdl.video.SDL_Window*Internal SDL_Window pointer

Properties

NameTypeDescription
allowsHighDPI[get] boolWraps SDL_GetWindowFlags to check whether the window allows high DPI (from SDL 2.0.1)
alwaysOnTop[get] boolWraps SDL_GetWindowFlags to check whether the window is always on top (from SDL 2.0.5)
bordered[get] boolWraps SDL_GetWindowFlags to check whether the borders of the window are visible
bordered[set] boolWraps SDL_SetWindowBordered which sets whether the borders' visibility
borderless[get] boolWraps SDL_GetWindowFlags to check whether the borders of the window are non-existent
brightness[get] floatWraps SDL_GetWindowBrightness which gets the window's brightness value
brightness[set] floatWraps SDL_SetWindowBrightness which sets the window's brightness value
display[get] const(Display)Wraps SDL_GetWindowDisplayIndex which gets the display where the center of the window is located
displayMode[get] DisplayModeWraps SDL_GetWindowDisplayMode which gets the window's display mode attributes
displayMode[set] DisplayModeWraps SDL_SetWindowDisplayMode which sets new display mode attributes to the window
drawableGLHeight[get] uintWraps SDL_GL_GetDrawableSize (from SDL 2.0.1) which gets the drawable width of the window in OpenGL in pixels
drawableGLSize[get] uint[2]Wraps SDL_GL_GetDrawableSize (from SDL 2.0.1) which gets the drawable size of the window in OpenGL in pixels
drawableGLWidth[get] uintWraps SDL_GL_GetDrawableSize (from SDL 2.0.1) which gets the drawable height of the window in OpenGL in pixels
foreign[get] boolWraps SDL_GetWindowFlags to check whether the window is foreign
fullscreen[get] boolWraps SDL_GetWindowFlags to check whether the window is in real fullscreen
fullscreen[set] boolWraps SDL_SetWindowFullscreen which sets the fullscreen mode of the window
fullscreenDesktop[get] boolWraps SDL_GetWindowFlags to check whether the window is in desktop fullscreen
hasShownScreenKeyboard[get] boolWraps SDL_IsScreenKeyboardShown which checks whether the screen keyboard is shown on the window
hasSurface[get] boolWraps SDL_HasWindowSurface (from SDL 2.28) which checks whether there is a surface associated with the window
height[get] uintWraps SDL_GetWindowSize which gets the height of the window in pixels
height[set] uintWraps SDL_SetWindowSize which resizes the height of the window in pixels
hidden[get] boolWraps SDL_GetWindowFlags to check whether the window is hidden
iccProfile[get] void[]Wraps SDL_GetWindowICCProfile (from SDL 2.0.18) which gets the raw ICC profile data for the screen the window is currently on
icon[set] SurfaceWraps SDL_SetWindowIcon which sets a new icon to the window
id[get] uintWraps SDL_GetWindowID which gets the internal window ID of the dsdl2.Window
inputGrab[get] boolWraps SDL_GetWindowGrab which gets the window's input grab mode
inputGrab[set] boolWraps SDL_SetWindowGrab which sets the window's input grab mode
keyboardFocused[get] boolWraps SDL_GetKeyboardFocus which verifies whether keyboard input is focused to the window
keyboardGrab[get] boolWraps SDL_GetWindowKeyboardGrab (from SDL 2.0.16) which gets the status of the window grabbing onto keyboard input
keyboardGrab[set] boolWraps SDL_SetWindowKeyboardGrab (from SDL 2.0.16) which sets the status of the window grabbing onto keyboard input
maximized[get] boolWraps SDL_GetWindowFlags to check whether the window is maximized
maximumSize[get] uint[2]Wraps SDL_GetWindowMaximumSize which gets the maximum size in pixels that the window can be resized to
maximumSize[set] uint[2]Wraps SDL_SetWindowMaximumSize which sets the maximum size in pixels that the window can be resized to
metal[get] boolWraps SDL_GetWindowFlags to check whether the window utilizes Metal (from SDL 2.0.6)
minimized[get] boolWraps SDL_GetWindowFlags to check whether the window is minimized
minimumSize[get] uint[2]Wraps SDL_GetWindowMinimumSize which gets the minimum size in pixels that the window can be resized to
minimumSize[set] uint[2]Wraps SDL_SetWindowMinimumSize which sets the minimum size in pixels that the window can be resized to
mouseFocused[get] boolWraps SDL_GetMouseFocus which verifies whether mouse input is focused to the window
mouseGrab[get] boolWraps SDL_GetWindowMouseGrab (from SDL 2.0.16) which gets the status of the window grabbing onto mouse input
mouseGrab[set] boolWraps SDL_SetWindowMouseGrab (from SDL 2.0.16) which sets the status of the window grabbing onto mouse input
mousePosition[get] int[2]Wraps SDL_GetMouseState which gets the mouse position in the window
mousePosition[set] int[2]Wraps SDL_WarpMouseInWindow which sets the mouse position in the window
mouseRect[get] std.typecons.Nullable!(dsdl2.rect.Rect)Wraps SDL_GetWindowMouseRect (from SDL 2.0.18) which gets the window's mouse confinement rectangle
mouseRect[set] RectWraps SDL_SetWindowMouseRect (from SDL 2.0.18) which sets the window's mouse confinement rectangle
mouseRect[set] typeof(null)Acts as SDL_SetWindowMouseRect(window, NULL) (from SDL 2.0.18) which resets the window's mouse confinement rectangle
mouseRect[set] std.typecons.Nullable!(dsdl2.rect.Rect)Wraps SDL_SetWindowMouseRect (from SDL 2.0.18) which sets or resets the window's mouse confinement rectangle
onTop[set] boolWraps SDL_SetWindowAlwaysOnTop (from SDL 2.0.16) which sets the status of the window always being on top above other windows
opacity[get] floatWraps SDL_GetWindowOpacity (from SDL 2.0.5) which gets the opacity of the window
opacity[set] floatWraps SDL_SetWindowOpacity (from SDL 2.0.5) which sets the opacity of the window
openGL[get] boolWraps SDL_GetWindowFlags to check whether the window utilizes OpenGL
pixelFormat[get] const(PixelFormat)Gets the dsdl2.PixelFormat used for pixel data of the window
popupMenu[get] boolWraps SDL_GetWindowFlags to check whether the window is treated as a popup menu (from SDL 2.0.5)
position[get] int[2]Wraps SDL_GetWindowPosition which gets the top-left coordinate position of the window in the desktop environment
position[set] int[2]Wraps SDL_SetWindowPosition which sets the position of the window in the desktop environment
renderer[get] inout(Renderer)Wraps SDL_GetRenderer which gets the renderer of the window
resizable[get] boolWraps SDL_GetWindowFlags to check whether the window's size is resizable by the user
resizable[set] boolWraps SDL_SetWindowResizable (from SDL 2.0.5) which sets the window's resizability
shown[get] boolWraps SDL_GetWindowFlags to check whether the window is shown
size[get] uint[2]Wraps SDL_GetWindowSize which gets the size of the window in pixels
size[set] uint[2]Wraps SDL_SetWindowSize which resizes the size of the window in pixels
sizeInPixels[get] uint[2]Wraps SDL_GetWindowSizeInPixels (from SDL 2.26) which gets the actual size of the window in the screen in pixels
skipsTaskbar[get] boolWraps SDL_GetWindowFlags to check whether the window is not on the taskbar (from SDL 2.0.5)
surface[get] inout(Surface)Wraps SDL_GetWindowSurface which gets the window's surface for software rendering
surface[set] typeof(null)Wraps SDL_DestroyWindowSurface (from SDL 2.28) which destructs the underlying associated surface of the window
title[get] stringWraps SDL_GetWindowTitle which gets the shown title of the window
title[set] stringWraps SDL_SetWindowTitle which sets a new title to the window
tooltip[get] boolWraps SDL_GetWindowFlags to check whether the window is treated as a tooltip window (from SDL 2.0.5)
utility[get] boolWraps SDL_GetWindowFlags to check whether the window is treated as a utility window (from SDL 2.0.5)
vulkan[get] boolWraps SDL_GetWindowFlags to check whether the window utilizes Vulkan (from SDL 2.0.6)
width[get] uintWraps SDL_GetWindowSize which gets the width of the window in pixels
width[set] uintWraps SDL_SetWindowSize which resizes the width of the window in pixels
x[get] intWraps SDL_GetWindowPosition which gets the top-left X coordinate position of the window in the desktop environment
x[set] intWraps SDL_SetWindowPosition which sets the X position of the window in the desktop environment
y[get] intWraps SDL_GetWindowPosition which gets the top-left Y coordinate position of the window in the desktop environment
y[set] intWraps SDL_SetWindowPosition which sets the Y position of the window in the desktop environment

Methods

NameDescription
flash (operation) Wraps SDL_FlashWindow (from SDL 2.0.16) which flashes the window in the desktop environment
focus () Wraps SDL_SetWindowInputFocus (from SDL 2.0.5) which focuses the window to be in reach to the user
hide () Wraps SDL_HideWindow which sets the window to be invisible in the desktop environment
maximize () Wraps SDL_MaximizeWindow which maximizes the window in the desktop environment
minimize () Wraps SDL_MinimizeWindow which minimizes the window in the desktop environment
modalFor (parent) Wraps SDL_SetWindowModalFor (from SDL 2.0.5) which sets the window to be a modal of another parent window, making the window always be above its parent window
opEquals (rhs) Equality operator overload
raise () Wraps SDL_RaiseWindow which raises the window above other windows, and sets input focus to the window
restore () Wraps SDL_RestoreWindow which restores the size and position of the window as it was originally
show () Wraps SDL_ShowWindow which sets the window to be visible in the desktop environment
swapGL () Wraps SDL_GL_SwapWindow which updates the window with any OpenGL changes
toHash () Gets the hash of the dsdl2.Window
toString () Formats the dsdl2.Window into its construction representation: "dsdl2.Window(<sdlWindow>)"
update () Wraps SDL_UpdateWindowSurface which makes the changes to the window's surface current
update (rects) Wraps SDL_UpdateWindowSurfaceRects which makes the changes of certain parts of the window surface as defined by a list of dsdl2.Rects current

Example

auto window = new dsdl2.Window("My Window", [dsdl2.WindowPos.centered, dsdl2.WindowPos.centered], [800, 600]);
window.surface.fill(dsdl2.Color(255, 0, 0));
window.update();