Window & System

Window lifecycle, monitors, clipboard, cursor, frame loop, timing.

Window reference

Every raylib window/system function bound to the Window namespace. Covers lifecycle, state toggles, properties, monitor enumeration, clipboard, events, cursor, frame loop, and misc utilities.

Lifecycle

Window.init(w: Int32, h: Int32, title: String)

Category: Lifecycle · raylib: InitWindow(w, h, title)

Opens the window, creates the GL context. Must be called once at program start.

Window.init(800, 600, "Iron Pong")

raylib cheatsheet · Iron source · Test usage

Window.should_close() -> Bool

Category: Lifecycle · raylib: WindowShouldClose()

True if user clicked X, pressed ESC (unless set_exit_key(KEY_NULL)), or OS requested close.

while not Window.should_close() {
    -- frame loop
}

raylib cheatsheet · Iron source · Test usage

State queries

Window.is_fullscreen() -> Bool

Category: State · raylib: IsWindowFullscreen()

True if window is currently fullscreen.

if not Window.is_fullscreen() { Window.toggle_fullscreen() }

raylib cheatsheet · Iron source · Test usage

Window.is_hidden / is_minimized / is_maximized / is_focused / is_resized() -> Bool

Category: State · raylib: IsWindowHidden / Minimized / Maximized / Focused / Resized

Per-state predicates. is_resized() is true for exactly one frame after a resize.

if Window.is_resized() { -- rebuild framebuffer }

raylib cheatsheet · Iron source · Test usage

State toggles

Window.toggle_borderless_windowed / maximize / minimize / restore()

Category: State toggles · raylib: ToggleBorderlessWindowed / MaximizeWindow / MinimizeWindow / RestoreWindow

Imperative transitions between window states.

Window.maximize()

raylib cheatsheet · Iron source · Test usage

Properties

Window.set_icon(image: Image)

Category: Properties · raylib: SetWindowIcon

Set the window title bar icon. Image format must be UNCOMPRESSED_R8G8B8A8.

val icon = Image.load("icon.png")
Window.set_icon(icon)

raylib cheatsheet · Iron source · Test usage

Window.set_size / set_min_size / set_max_size(w: Int32, h: Int32)

Category: Properties · raylib: SetWindowSize / SetWindowMinSize / SetWindowMaxSize

Resize the window or constrain its future resize range.

Window.set_min_size(Int32(400), Int32(300))
Window.set_size(Int32(1280), Int32(720))

raylib cheatsheet · Iron source · Test usage

Window.set_opacity(opacity: Float32)

Category: Properties · raylib: SetWindowOpacity

Alpha from 0.0 (transparent) to 1.0 (opaque). Requires WINDOW_TRANSPARENT config flag on some platforms.

Window.set_opacity(Float32(0.9))

raylib cheatsheet · Iron source · Test usage

Screen geometry

Window.get_screen_width / get_screen_height() -> Int32

Category: Geometry · raylib: GetScreenWidth / GetScreenHeight

Current window inner size in pixels.

val w = Window.get_screen_width()
val h = Window.get_screen_height()

raylib cheatsheet · Iron source · Test usage

Window.get_render_width / get_render_height() -> Int32

Category: Geometry · raylib: GetRenderWidth / GetRenderHeight

Framebuffer size (may differ from screen size on HiDPI).

val fbw = Window.get_render_width()

raylib cheatsheet · Iron source · Test usage

Window.get_window_position / get_window_scale_dpi() -> Vector2

Category: Geometry · raylib: GetWindowPosition / GetWindowScaleDPI

Top-left corner in screen pixels / DPI scale vector.

val p = Window.get_window_position()
val dpi = Window.get_window_scale_dpi()

raylib cheatsheet · Iron source · Test usage

Monitor enumeration

Window.get_monitor_* (position / width / height / physical_* / refresh_rate / name)

Category: Monitors · raylib: GetMonitor*

Per-monitor metadata by index. get_monitor_position returns Vector2; physical w/h are in mm; refresh rate in Hz.

val pos = Window.get_monitor_position(Int32(0))
val name = Window.get_monitor_name(Int32(0))

raylib cheatsheet · Iron source · Test usage

Clipboard

Window.get_clipboard_text / set_clipboard_text / get_clipboard_image()

Category: Clipboard · raylib: GetClipboardText / SetClipboardText / GetClipboardImage

OS clipboard access. Text is UTF-8; image is a screenshot-style Image that must be Image.unload(...)'d after use.

Window.set_clipboard_text("copied!")
val current = Window.get_clipboard_text()

raylib cheatsheet · Iron source · Test usage

Events + cursor

Window.enable_event_waiting / disable_event_waiting()

Category: Events · raylib: EnableEventWaiting / DisableEventWaiting

When enabled, main loop blocks on events instead of polling — low-power mode for GUI apps.

Window.enable_event_waiting()  -- wait for input

raylib cheatsheet · Iron source · Test usage

Window.show_cursor / hide_cursor / is_cursor_hidden / enable_cursor / disable_cursor / is_cursor_on_screen / set_mouse_cursor

Category: Cursor · raylib: ShowCursor / HideCursor / EnableCursor / DisableCursor / SetMouseCursor

Cursor visibility + FPS-style locking. disable_cursor hides and locks cursor to window center (for FPS controls).

Window.set_mouse_cursor(MouseCursor.CROSSHAIR)
Window.hide_cursor()

raylib cheatsheet · Iron source · Test usage

Window.set_config_flags(flags: ConfigFlags) / set_trace_log_level(level: TraceLogLevel)

Category: Config · raylib: SetConfigFlags / SetTraceLogLevel

Window hints to apply on next Window.init(). Trace log threshold (default INFO).

Window.set_config_flags(ConfigFlags.MSAA_4X_HINT)
Window.set_trace_log_level(TraceLogLevel.WARNING)

raylib cheatsheet · Iron source · Test usage

Frame loop

Window.get_frame_time() -> Float32

Category: Frame loop · raylib: GetFrameTime

Seconds elapsed since last frame — use as delta-time for velocity integration.

val dt = Window.get_frame_time()
pos.x = pos.x + velocity.x * dt

raylib cheatsheet · Iron source · Test usage

Window.wait_time(seconds: Float)

Category: Frame loop · raylib: WaitTime

High-precision sleep. Used by raylib internally for the FPS cap; exposed for manual pacing.

Window.wait_time(0.016)  -- 16 ms (~60 FPS)

raylib cheatsheet · Iron source · Test usage

Misc

Window.take_screenshot(filename: String)

Category: Misc · raylib: TakeScreenshot

Save current framebuffer to a PNG file.

if Keyboard.is_pressed(KeyboardKey.F12) {
    Window.take_screenshot("screen.png")
}

raylib cheatsheet · Iron source · Test usage

Window.load_image_from_screen() -> Image

Category: Misc · raylib: LoadImageFromScreen

Capture framebuffer as an in-memory Image. Remember to Image.unload(img).

val shot = Window.load_image_from_screen()
Image.unload(shot)

raylib cheatsheet · Iron source · Test usage

See also