LWXGL provides built-in modal dialogs for common interactions — alerts, confirmations, and text prompts — as well as a virtual scroll canvas that lets your UI extend beyond the visible window height. Both features integrate seamlessly with the main render loop without requiring any manual overlay management.Documentation 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.
Modal Dialogs
Spawn a modal dialog with:type parameter selects the dialog style. message is the text displayed in the dialog body. on_confirm is a callback invoked when the user clicks OK — its argument depends on the modal type.
| Constant | Value | Behavior |
|---|---|---|
MODAL_ALERT | 0 | Displays the message with a single OK button. on_confirm is called with NULL. |
MODAL_CONFIRM | 1 | Displays Cancel and OK buttons. on_confirm is called with NULL when OK is clicked; cancel dismisses without calling the callback. |
MODAL_INPUT | 2 | Displays a text input field with Cancel and OK buttons. on_confirm is called with the entered string (up to 150 characters) when OK is clicked. |
Only one modal can be active at a time. Calling
SpawnModal while a modal is already open replaces the current message but keeps the same active state.Checking If a Modal Is Open
1 if a modal dialog is currently displayed, 0 otherwise. While a modal is open, all element interaction callbacks (button clicks, key events, etc.) and user event handlers are suppressed — only the modal itself receives input. You can use QueryModalOpen in your on_every callback to pause game logic or animations while waiting for user input.
Scrollable Canvas
ReserveScroll configures a virtual canvas that is taller than the physical window, enabling the user to scroll through content with the mouse wheel:
virtual_height— the total height of the back-buffer in pixels. This must be larger than the window height for scrolling to have any effect.scrollbar_color— a palette index for the scrollbar handle. PassCLR_NONE(-1) to hide the scrollbar visually while still allowing scroll.Scroll— avoid callback(int offset)called whenever the scroll position changes.offsetis the new scroll position in pixels from the top.
Anchoring Elements in Scroll Mode
When scrolling is active, all elements move with the virtual canvas by default — theiry coordinates are interpreted relative to the top of the virtual canvas, not the visible viewport. To pin specific elements to the viewport (such as a fixed toolbar or status bar that should always remain visible), use ElemAnchor and ResolveAnchors.
Call ElemAnchor once to register which elements should be viewport-pinned:
ResolveAnchors each frame (typically at the start of your on_every callback) to recompute the absolute y position of anchored elements from the current scroll offset: