Skip to main content

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.

LWXGL provides six built-in element types: text labels, buttons, input fields, rectangles, images, and checkboxes. Each is created by calling its constructor function with an integer ID and position/size parameters. Elements are stored in a global vector indexed by ID, and the renderer iterates over every non-NULL slot on every frame — so once you create an element, it is drawn automatically without any additional calls.

Text Labels

Text elements render a string at a fixed position using the library’s built-in 9×15 bitmap font. The string is rendered in a single palette color and supports newlines for multiline output.Signature
void GCreateText(int id, int x, int y, int color, const char* text);
ParameterDescription
idElement ID. If an element with this ID already exists it is destroyed and replaced.
x, yTop-left position of the text baseline in pixels.
colorPalette index (0–15) used to draw the text.
textThe string to display. Use \n to start a new line; each line is 16 px tall.
Creating a text label
// White (palette index 15) label at (10, 10)
GCreateText(0, 10, 10, 15, "Score: 0");
Updating a labelRe-calling GCreateText with the same ID replaces the existing element in-place. The old element is freed and a new one is allocated at the same slot.
// Later, update the score — same ID, same position, new string
GCreateText(0, 10, 10, 15, "Score: 100");
Multiline text
GCreateText(1, 20, 50, 11, "Line one\nLine two\nLine three");

Modifying Element Bounds

You can reposition or resize any element at runtime without destroying and recreating it:
void GElemModifyBounds(int id, int x, int y, int w, int h);
ParameterDescription
idID of the element to modify.
x, yNew top-left position.
w, hNew width and height.
// Move element 2 to (100, 200) and resize to 300×50
GElemModifyBounds(2, 100, 200, 300, 50);
GElemModifyBounds updates the bounding box used by both the renderer and the hit-testing logic for buttons, inputs, and checkboxes. For image elements the underlying pixel buffer is not resized — only the draw position and clipping bounds change.

Deleting Elements

void GDeleteElement(int id);
Frees the element and its associated memory. The slot is set to NULL and is safely skipped by the renderer and event system on subsequent frames. For image elements (type 4) the underlying XImage is also destroyed with XDestroyImage.
// Remove the button created at slot 1
GDeleteElement(1);

Build docs developers (and LLMs) love