LWXGL has a built-in modal dialog system that renders a centered dialog box over the window content, blocking all element interaction until the user dismisses it. While a modal is active, buttonDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/DREssedAlarm184/LWXGL/llms.txt
Use this file to discover all available pages before exploring further.
onclick callbacks and keyboard input handlers are suppressed — only the modal’s own OK and Cancel controls respond to clicks.
Spawning a modal
| Parameter | Description |
|---|---|
type | 0 — alert (OK button only); 1 — confirm (OK + Cancel buttons) |
msg | Message text. Supports \n for line breaks. Lines longer than ~31 characters are truncated at the right edge of the dialog. |
on_confirm | Callback invoked when the user clicks OK. Pass NULL for informational alerts. |
1 only) dismisses the modal without invoking on_confirm. Clicking OK dismisses the modal and, if on_confirm is not NULL, calls it immediately.
Checking modal state
1 if a modal is currently displayed, 0 otherwise. You can use this to pause game logic or skip input processing while the dialog is open.
Modal layout
The modal is rendered as a fixed-size centered box (306 × 156 pixels, positioned near the top-center of the window). The message text starts at the top-left of the dialog interior and wraps on \n characters, with each line 15 pixels tall. Button labels are positioned in the lower-right area of the dialog:
- OK is rendered in palette color 10 (bright green by default).
- Cancel (type
1only) is rendered in palette color 12 (bright red by default).
Usage pattern in a game loop
When usingGSimpleWindowLoop, integrate modal awareness into your per-frame callback to prevent game state from advancing while the dialog is visible:
Only one modal can be active at a time. Calling
GSpawnModal while a modal is already open immediately replaces it — the previous message and callback are discarded.