Window & Display Subsystem (`engine.Window`)

The window subsystem handles GLFW context initialization, multi-monitor configuration, fullscreen toggling, event polling, and client area management.

Functions & Methods Reference

Function / Method Signature Description
engine.Window.create(title, w, h, [fs, mon]) (str, int, int, [bool, int]) → Window Initializes an OpenGL GLFW window. Set fs = true for fullscreen on monitor index mon.
engine.Window.getMonitors() () → table Returns a list of connected physical displays with name, resolution, and desktop coordinates.
win:isOpen() () → bool Returns true as long as the user has not clicked close or sent a termination signal.
win:close() () → void Signals the window to close on the next frame boundary.
win:pollEvents() () → void Dispatches pending OS window events. Handled automatically inside engine.run().
win:getSize() () → (int, int) Returns current window client area width, height in pixels.
win:setSize(w, h) (int, int) → void Resizes the client area dynamically.
win:setTitle(title) (str) → void Dynamically updates the window title text (e.g. displaying live FPS).

Display Querying Example

query_monitors.lua
import engine

monitors = engine.Window.getMonitors()
for idx, mon in ipairs(monitors) {
    print(string.format("Monitor %d: %s (%dx%d at %d,%d)",
        idx, mon.name, mon.width, mon.height, mon.x, mon.y))
}

-- Launch borderless fullscreen on primary monitor:
win = engine.Window.create("PyLua Fullscreen", 1920, 1080, true, 1)