LWXGL uses a fixed 16-entry indexed color palette (indices 0–15). Every color argument in the API is an integer index into this palette — there are no raw RGB values in the public API. This keeps the interface simple and ensures consistent, theme-able colors across all elements.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.
Default Palette
The palette is initialised at startup with the following values. All 16 entries are allocated from the X11 default colormap insideGCreateWindow.
| Index | Name | R | G | B |
|---|---|---|---|---|
| 0 | Black | 0 | 0 | 0 |
| 1 | Dark Blue | 3 | 3 | 173 |
| 2 | Dark Green | 0 | 170 | 0 |
| 3 | Dark Cyan | 0 | 168 | 168 |
| 4 | Dark Red | 186 | 6 | 6 |
| 5 | Dark Magenta | 168 | 0 | 168 |
| 6 | Orange | 230 | 126 | 34 |
| 7 | Light Gray | 168 | 168 | 168 |
| 8 | Dark Gray | 85 | 87 | 83 |
| 9 | Light Blue | 87 | 87 | 255 |
| 10 | Light Green | 85 | 255 | 85 |
| 11 | Light Cyan | 96 | 240 | 240 |
| 12 | Light Red | 255 | 85 | 85 |
| 13 | Light Magenta | 240 | 84 | 240 |
| 14 | Yellow | 244 | 242 | 54 |
| 15 | White | 255 | 255 | 255 |
Packed Color Bytes (Nibble Encoding)
Several widget creation functions —GCreateButton, GCreateInput, and GCreateCheckbox — accept packed color byte arguments rather than single palette indices. A packed byte encodes two palette indices in one value using nibble (4-bit half) encoding:
- High nibble (
H(b)— bits 7–4): border / outline color - Low nibble (
L(b)— bits 3–0): fill / background color
0x72 means:
- High nibble
7→ border is index 7 (Light Gray) - Low nibble
2→ fill is index 2 (Dark Green)
| Function | Packed parameters |
|---|---|
GCreateButton | u (unpressed), hvr (hover), p (pressed) |
GCreateInput | u (inactive), hvr (hover) |
GCreateCheckbox | cb_col (checkbox box colors) |
Runtime Palette Modification
The palette can be changed at any point afterGCreateWindow returns.
GPaletteModify
idx with the given RGB values. The old X11 color allocation is freed and a new one is allocated in its place.
- If
redrawis non-zero, allImage-type elements (GCreateImage) are immediately redrawn to pick up the new color. - Widget elements (buttons, inputs, etc.) pick up the new color automatically on the next rendered frame because they look up
colors[idx]at draw time.
GPaletteReset
GRedrawAllImages() to refresh image canvases.
GPaletteQuery
idx back from the X11 colormap into *r, *g, *b. Useful for inspecting a live palette that may have been modified.