XDPXI's Documentation
SDL2

Window Management

Required version: Sponge >=1.0.4

sdl2.init()

Initializes the SDL2 library. This should be called before creating any windows.

Parameters: None

Returns: boolean - Returns true on success

Example:

sdl2.init();

sdl2.create_window(title, width, height)

Creates an SDL2 window with the specified title and dimensions.

Parameters:

  • title (string) - The window title
  • width (number) - Window width in pixels
  • height (number) - Window height in pixels

Returns: number - Window handle (currently returns 1)

Example:

sdl2.create_window("Sponge Application", 1024, 768);

sdl2.destroy_window()

Closes and destroys the current window. The window is typically automatically destroyed when the program exits.

Parameters: None

Returns: null

Example:

sdl2.destroy_window();

sdl2.set_window_title(title)

Changes the title of the current window.

Parameters:

  • title (string) - New window title

Returns: null

Example:

sdl2.set_window_title("Updated Title");

sdl2.set_window_mode(mode)

Required version: Sponge >=1.0.7

Sets the window mode (windowed, fullscreen, or windowed fullscreen).

Parameters:

  • mode (string) - Window mode, one of:
    • "windowed" - Standard windowed mode
    • "fullscreen" - True fullscreen mode
    • "windowed_fullscreen" - Borderless fullscreen (covers entire desktop)

Returns: null

Example:

// Set to fullscreen
sdl2.set_window_mode("fullscreen");

// Set to windowed
sdl2.set_window_mode("windowed");

// Set to borderless fullscreen
sdl2.set_window_mode("windowed_fullscreen");