v2026.6.4
All Bundles
Bundle SDL2 multimedia library for 2D graphics, input handling, audio playback, and window management. Core types: Window, Renderer, Texture, Surface, Event, and Mixer. Compile with -lib sdl2.

Window

SDL Window

Operations

Destroy #

Destroy a window

method : public : Destroy() ~ Nil

DisableScreenSaver # function

Prevent the screen from being blanked by a screen saver

function : DisableScreenSaver() ~ Nil

EnableScreenSaver # function

Allow the screen to be blanked by a screen saver

function : EnableScreenSaver() ~ Nil

GLGetDrawableSize #

Get the size of a window's underlying drawable in pixels (for use with glViewport).

method : public : GLGetDrawableSize(w:IntRef, h:IntRef) ~ Nil

Parameters

NameTypeDescription
wIntRefa holder to variable for storing the width in pixels
hIntRefa holder to variable for storing the height in pixels

GLSwap #

Update a window with OpenGL rendering.

method : public : GLSwap() ~ Nil

GetBrightness #

Gets the brightness (gamma multiplier) for the display that owns a given window

method : public : GetBrightness() ~ Float

Return

TypeDescription
Floatbrightness for the display where 0.0 is completely dark and 1.0 is normal brightness

GetDisplayIndex #

Get the index of the display associated with a window

method : public : GetDisplayIndex() ~ Int

Return

TypeDescription
Intindex of the display containing the center of the window on success or a negative error code on failure

GetFlags #

Get the window flags

method : public : GetFlags() ~ Int

Return

TypeDescription
IntOR'd mask of the SDL_WindowFlags associated with window

GetFromID #

Get the numeric ID of a window, for logging purposes

method : public : GetFromID(id:Int) ~ Window

Parameters

NameTypeDescription
idIntwindow ID

Return

TypeDescription
Windowthe ID of the window on success or 0 on failure

GetGammaRamp #

Gets the gamma ramp for the display that owns a given window

method : public : GetGammaRamp(red:IntRef, green:IntRef, blue:IntRef) ~ Int

Parameters

NameTypeDescription
redIntRefa 256 element array of 16-bit quantities representing the translation table for the red channel
greenIntRefa 256 element array of 16-bit quantities representing the translation table for the green channel
blueIntRefa 256 element array of 16-bit quantities representing the translation table for the blue channel,

Return

TypeDescription
Int0 on success or a negative error code on failure

GetGrab #

Get a window's input grab mode

method : public : GetGrab() ~ Bool

Return

TypeDescription
BoolReturns true if input is grabbed, false otherwise

GetGrabbedWindow # function

Get the window that currently has an input grab enabled

function : GetGrabbedWindow() ~ Window

Return

TypeDescription
Windowwindow if input is grabbed or NULL otherwise

GetID #

Get the numeric ID of a window, for logging purposes

method : public : GetID() ~ Int

Return

TypeDescription
Intthe ID of the window on success or 0 on failure

GetMaximumSize #

Get the maximum size of a window's client area

method : public : GetMaximumSize(w:IntRef, h:IntRef) ~ Nil

Parameters

NameTypeDescription
wIntRefpointer filled in with the maximum width of the window,
hIntRefpointer filled in with the maximum height of the window

GetMinimumSize #

Get the minimum size of a window's client area

method : public : GetMinimumSize(w:IntRef, h:IntRef) ~ Nil

Parameters

NameTypeDescription
wIntRefpointer filled in with the minimum width of the window
hIntRefpointer filled in with the minimum height of the window

GetPixelFormat #

Get the pixel format associated with the window

method : public : GetPixelFormat() ~ Int

Return

TypeDescription
Intpixel format of the window on success or SDL_PIXELFORMAT_UNKNOWN on failure

GetPosition #

Get the position of a window

method : public : GetPosition(x:IntRef, y:IntRef) ~ Nil

Parameters

NameTypeDescription
xIntRefpointer filled in with the x position of the window, in screen coordinates
yIntRefpointer filled in with the y position of the window, in screen coordinates

GetSize #

Get the size of a window's client area

method : public : GetSize(w:IntRef, h:IntRef) ~ Nil

Parameters

NameTypeDescription
wIntRefpointer filled in with the width of the window, in screen coordinates
hIntRefpointer filled in with the height of the window, in screen coordinates

GetSurface #

Get the SDL surface associated with the window

method : public : GetSurface() ~ Surface

Return

TypeDescription
Surfacesurface associated with the window, or NULL on failure

Hide #

Hide a window

method : public : Hide() ~ Nil

IsNull #

Determines if the underlying SDL C-struct is NULL

method : public : IsNull() ~ Bool

Return

TypeDescription
Booltrue if NULL, false otherwise

IsScreenSaverEnabled # function

Check whether the screensaver is currently enabled

function : IsScreenSaverEnabled() ~ Bool

Return

TypeDescription
BoolReturns true if the screensaver is enabled, false if it is disabled

Maximize #

Make a window as large as possible

method : public : Maximize() ~ Nil

Minimize #

Minimize a window to an iconic representation

method : public : Minimize() ~ Nil

New # constructor

Creates a window with the specified position, dimensions, and flags

New(title:String, x:Int, y:Int, w:Int, h:Int, flags:Int)

Parameters

NameTypeDescription
titleStringthe title of the window, in UTF-8 encoding
xIntthe x position of the window, WindowFlags->SDL_WINDOWPOS_CENTERED, or WindowFlags->SDL_WINDOWPOS_UNDEFINED
yIntthe y position of the window, WindowFlags->SDL_WINDOWPOS_CENTERED, or WindowFlags->SDL_WINDOWPOS_UNDEFINED
wIntthe width of the window, in screen coordinates
hIntthe height of the window, in screen coordinates
flagsInt0, or one or more WindowFlags OR'd together

Raise #

Raise a window above other windows and set the input focus

method : public : Raise() ~ Nil

Restore #

Restore the size and position of a minimized or maximized window

method : public : Restore() ~ Nil

SetBordered #

Set the border state of a window

method : public : SetBordered(bordered:Bool) ~ Nil

Parameters

NameTypeDescription
borderedBoolfalse to remove border, true to add border

SetBrightness #

Sets the brightness (gamma multiplier) for the display that owns a given window

method : public : SetBrightness(brightness:Float) ~ Int

Parameters

NameTypeDescription
brightnessFloatthe brightness (gamma multiplier) value to set where 0.0 is completely dark and 1.0 is normal brightness

Return

TypeDescription
Int0 on success or a negative error code on failure

SetDisplayMode #

Set the display mode to use when a window is visible at full-screen

method : public : SetDisplayMode(mode:DisplayMode) ~ Int

Parameters

NameTypeDescription
modeDisplayModethe SDL_DisplayMode structure representing the mode to use, or NULL to use the window's dimensions and the desktop's format and refresh rate

SetFullscreen #

Set a window's full-screen state

method : public : SetFullscreen(flags:Int) ~ Int

Parameters

NameTypeDescription
flagsIntWindowFlags->SDL_WINDOW_FULLSCREEN, WindowFlags->SDL_WINDOW_FULLSCREEN_DESKTOP or 0

SetGammaRamp #

Sets the gamma ramp for the display that owns a given window

method : public : SetGammaRamp(red:IntRef, green:IntRef, blue:IntRef) ~ Int

Parameters

NameTypeDescription
redIntRefa 256 element array of 16-bit quantities representing the translation table for the red channel
greenIntRefa 256 element array of 16-bit quantities representing the translation table for the green channel
blueIntRefa 256 element array of 16-bit quantities representing the translation table for the blue channel,

Return

TypeDescription
Int0 on success or a negative error code on failure

SetGrab #

Set a window's input grab mode

method : public : SetGrab(grabbed:Bool) ~ Nil

Parameters

NameTypeDescription
grabbedBooltrue to grab input or false to release input

SetIcon #

Set the icon for a window

method : public : SetIcon(icon:Surface) ~ Nil

Parameters

NameTypeDescription
iconSurfacea Surface instance containing the icon for the window

SetMaximumSize #

Set the maximum size of a window's client area

method : public : SetMaximumSize(max_w:Int, max_h:Int) ~ Nil

Parameters

NameTypeDescription
max_wIntmaximum width of the window in pixels
max_hIntmaximum height of the window in pixels

SetMinimumSize #

Set the minimum size of a window's client area

method : public : SetMinimumSize(min_w:Int, min_h:Int) ~ Nil

Parameters

NameTypeDescription
min_wIntthe minimum width of the window in pixels
min_hIntthe minimum height of the window in pixels

SetPosition #

Set the position of a window

method : public : SetPosition(x:Int, y:Int) ~ Nil

Parameters

NameTypeDescription
xIntthe x coordinate of the window in screen coordinates, or WindowFlags->SDL_WINDOWPOS_CENTERED or WindowFlags->SDL_WINDOWPOS_UNDEFINED
yIntthe y coordinate of the window in screen coordinates, or WindowFlags->SDL_WINDOWPOS_CENTERED or WindowFlags->SDL_WINDOWPOS_UNDEFINED

SetSize #

Set the size of a window's client area

method : public : SetSize(w:Int, h:Int) ~ Nil

Parameters

NameTypeDescription
wIntwidth of the window in pixels, in screen coordinates, must be > 0
hIntheight of the window in pixels, in screen coordinates, must be > 0

SetTitle #

Set the title of a window

method : public : SetTitle(title:String) ~ Nil

Parameters

NameTypeDescription
titleStringthe desired window title in UTF-8 format

Show #

Show a window

method : public : Show() ~ Nil

ShowSimpleMessageBox # function

Display a simple modal message box

function : ShowSimpleMessageBox(flags:Int, title:String, message:String, window:Window) ~ Int

Parameters

NameTypeDescription
flagsIntan SDL_MessageBoxFlags value
titleStringUTF-8 title text
messageStringUTF-8 message text
windowWindowthe parent window, or NULL for no parent

Return

TypeDescription
Int0 on success or a negative error code on failure

UpdateSurface #

Use this function to copy the window surface to the screen

method : public : UpdateSurface() ~ Int