The UI element functions create and manage visible widgets rendered to the window. Each widget is assigned an integer ID by the caller — IDs are indices into a flat global element array. If an element already exists at a given ID, it is deleted and replaced before the new element is created.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.
Packed-nibble color encoding
Many element creation functions accept packed-nibble color parameters. The high nibble (bits 7–4) is the border/outline color; the low nibble (bits 3–0) is the fill color.
Example: 0x72 = border color 7 (Light Gray), fill color 2 (Dark Green).
Text
GCreateText
y + 11.
Element ID. If an element already exists at this ID it is deleted and replaced.
Left edge of the text in window pixels.
Top edge of the text in window pixels.
Palette index (0–15) for the text foreground color.
Null-terminated string to display. Embed
\n to insert line breaks; each subsequent line is drawn 15 px below the previous one.Button
GCreateButton
onclick callback fires on a left-mouse-button release while the cursor is inside the button.
Element ID.
Left edge of the button.
Top edge of the button.
Width of the button in pixels.
Height of the button in pixels.
Packed-nibble color for the unpressed state. High nibble = border color, low nibble = fill color.
Packed-nibble color for the hover state (cursor inside, mouse button up).
Packed-nibble color for the pressed state (cursor inside, mouse button held).
Null-terminated string displayed centered on the button face.
Callback invoked on left-button release inside the button. Pass
NULL for no callback.Input
GCreateInput
_ cursor character is appended to the displayed text. Key events are routed to the active input automatically. The internal buffer is 128 bytes.
Element ID.
Left edge of the input box.
Top edge of the input box.
Width in pixels. Pass
-1 to auto-size: width is computed as (max + 1) * 9 + 10.Height in pixels.
Packed-nibble color for the inactive state.
Packed-nibble color for the active (focused) state.
Maximum number of characters the user can type. The internal buffer is always 128 bytes regardless of this value.
GGetInput
ID of an existing input element.
char* — pointer into the element’s internal buffer. Do not free this pointer.
Example
Rect
GCreateRect
fg and bg here are plain palette indices. Either can be omitted by passing -1.
Element ID.
Left edge of the rectangle.
Top edge of the rectangle.
Width in pixels.
Height in pixels.
Border color as a palette index. Pass
-1 to draw no border.Fill color as a palette index. Pass
-1 to draw no fill (transparent interior).Checkbox
GCreateCheckbox
Element ID.
Left edge of the checkbox square.
Top edge of the checkbox square.
Width and height of the checkbox square in pixels.
Packed-nibble color for the checkbox box. High nibble = border, low nibble = fill.
Palette index for the label text color.
Null-terminated label string displayed 5 px to the right of the box. Pass
NULL for no label.GGetCheckbox
ID of an existing checkbox element.
1 if the checkbox is checked, 0 if unchecked.
Example
Console
GCreateConsole
cols and rows: width = cols * 9 + 17, height = rows * 15 + 10. A scrollbar is drawn on the right edge; the thumb scales proportionally to the visible fraction of total content. When the mouse is inside the element, a hover overlay shows the current scroll position.
Element ID.
Left edge of the console box.
Top edge of the console box.
Visible column count. Each column is 9 px wide. Lines longer than
cols characters are soft-wrapped onto the next row.Visible row count. Each row is 15 px tall.
Packed-nibble color for the console box. High nibble = border, low nibble = background fill.
Packed-nibble color for text rendering. The high nibble is the main text color. The low nibble is the text color used in the hover scroll overlay; it is also used as the scrollbar thumb color.
GConsolePrint
printf-style. Tab characters (\t) are expanded to four spaces during rendering. Characters outside the printable range (ASCII 27–126) and outside \n are rendered as ?. If the console is already scrolled to the bottom before the print, the scroll position advances automatically to keep the new content in view.
ID of an existing console element.
printf-compatible format string.Format arguments.
GConsoleClear
ID of an existing console element.
Element Management
GDeleteElement
index and sets the slot to NULL. For image elements this also destroys the underlying XImage. Calling this on a NULL slot or an out-of-range index is a no-op.
ID of the element to delete.
GElemModifyBounds
ID of an existing element.
New left edge in window pixels.
New top edge in window pixels.
New width in pixels.
New height in pixels.
GElemSetVisible
visible = 0) are skipped during rendering and do not receive mouse or keyboard input. Visibility defaults to 1 on creation.
ID of an existing element.
Pass
1 to show the element, 0 to hide it.GElemInside
ID of an existing element.
1 if the cursor is inside the element and the element is on the active screen, 0 otherwise.
Example