Every visible widget in LWXGL — text labels, buttons, inputs, rectangles, image canvases, checkboxes, and consoles — is an “element” stored in a flat vector indexed by an integer ID that you supply at creation time. The renderer iterates this vector each frame and draws each visible element that belongs to the currently active screen.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.
Element types
| Type | Creation function | Type integer |
|---|---|---|
| Text | GCreateText | 0 |
| Button | GCreateButton | 1 |
| Input | GCreateInput | 2 |
| Rect | GCreateRect | 3 |
| Image | GCreateImage | 4 |
| Checkbox | GCreateCheckbox | 5 |
| Console | GCreateConsole | 6 |
IDs are integers you manage
Every creation function takes anint id as its first argument. LWXGL stores the element at that index in the internal vector. If an element already exists at that ID, it is deleted first before the new one is stored — so IDs are naturally reusable.
IDs are completely local to your application; LWXGL assigns no meaning to specific numbers. Using named constants or an enum makes code far easier to read and maintain:
Position and size
All elements have an(x, y) top-left position and, for most types, a (w, h) size, all expressed in pixels. These can be changed at any time with:
GRenderWindow call. This is the correct way to animate or reposition elements at runtime.
Visibility
1 to show an element and 0 to hide it. Hidden elements are neither rendered nor tested for mouse hit detection, so they are effectively inert until made visible again.
Hit testing
1 if the mouse cursor is currently inside the element’s bounding box, the element is visible, and the element is on the active screen. For checkboxes, the hit area extends to include the label text to the right of the box. Returns 0 otherwise.
Deletion
XImage data for image canvases) and sets the slot in the vector to NULL. The ID is free to be reused immediately. Passing an out-of-range or already-NULL ID is a no-op.
Screen assignment
Each element belongs to a screen — an integer used to group elements into logical pages or tabs. Elements only render and receive input events when their screen value matches*GScreenActive().
Assign elements to a screen with:
GScreenActive():
-1 makes it visible on all screens, regardless of the active screen value. This is useful for persistent UI chrome such as a navigation bar or a status line.
The following pattern implements a simple two-page tab interface:
0 when created, so a single-screen application requires no screen management at all.
The element vector grows dynamically as you create elements with higher IDs. IDs do not need to be contiguous — but large sparse gaps (e.g., using IDs 0 and 10000) will allocate all intervening
NULL slots, wasting memory proportional to the gap. Keep IDs reasonably dense.