LWXGL uses a fixed 16-color palette (indices 0–15) for all rendering. Widgets, drawing primitives, and image canvases all reference palette indices rather than raw RGB values. This means changing a single palette entry instantly recolors every element that uses that index — you can retheme an entire UI by swapping a handful of entries.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 16 default colors are allocated from the X11 colormap duringGCreateWindow. They approximate the classic CGA/VGA color set:
| 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 |
Querying a Color
r, g, and b with the current RGB values for palette entry idx. The values are read back from the X11 colormap via XQueryColor, so they reflect any modifications made with GPaletteModify.
Modifying a Color
| Parameter | Description |
|---|---|
idx | Palette index to replace (0–15). |
r, g, b | New RGB values (0–255 each). |
redraw | If non-zero, calls GRedrawAllImages() to immediately update all image canvases. Widget colors (buttons, text, etc.) update on the next GRenderWindow() call without needing redraw. |
XFreeColors and a new one is allocated with XAllocColor at the same colors[idx] slot.
GPaletteModify does not force a full window redraw on its own. Widget and background color changes take effect on the next GRenderWindow() call. Pass redraw=1 only when you have image canvases that need to reflect the new color immediately.Resetting the Palette
XFreeColors call, then reallocates all 16 from scratch. Automatically calls GRedrawAllImages() to refresh canvases.
Packed Color Parameters
Many widget creation functions accept packed color bytes for their appearance parameters. A packed color byte encodes two palette indices in a singleint:
- Upper nibble (bits 4–7): border or outline color index.
- Lower nibble (bits 0–3): fill or background color index.
| Function | Packed Parameters |
|---|---|
GCreateButton | u (unpressed), hvr (hover), p (pressed) |
GCreateInput | u (inactive), hvr (active/hover) |
GCreateCheckbox | cb_col (checkbox square) |
GCreateConsole | con_clr (console background) |
Color index values for packed bytes must fit in a nibble (0–15), which matches exactly the 16 entries in the LWXGL palette.