LWXGL uses a fixed 16-entry palette stored in the X11 colormap. Every pixel in everyDocumentation 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.
ImageElement is stored as a 4-bit palette index (0–15), and every drawing primitive — including text, buttons, rectangles, and image data — references these indices. The palette API lets you query the live RGB value of any entry, replace individual entries at runtime, and restore the factory defaults. Because the palette is global, a single PaletteModify call instantly changes the appearance of every element that uses that color index.
PaletteQuery
Queries the current RGB values of a palette entry from the X11 colormap.
XQueryColor on the Colormap for the pixel value stored at colors[idx] and converts the 16-bit X11 channel values to 8-bit by dividing by 257. The result reflects the true color allocated in the colormap at query time, including any runtime modifications made with PaletteModify.
Palette index to query (0–15).
Pointer to receive the red channel value (0–255).
Pointer to receive the green channel value (0–255).
Pointer to receive the blue channel value (0–255).
PaletteModify
Replaces one palette entry with a new RGB color.
colors[idx] with XFreeColors, then allocates a new color with XAllocColor using the supplied RGB values (scaled to 16-bit internally by multiplying by 257). The resulting pixel value is stored back into colors[idx]. If redraw is non-zero, RedrawAllImages() is called immediately after to force all ImageElement canvases to re-upload their pixel data with the new color mapping.
Palette index to replace (0–15).
New red channel value (0–255).
New green channel value (0–255).
New blue channel value (0–255).
Pass
1 to call RedrawAllImages() after modifying the color, forcing all image elements to re-render with the new palette. Pass 0 to defer the redraw (useful when modifying multiple entries in a loop — call RedrawAllImages() manually afterwards).PaletteReset
Restores all 16 palette entries to the LWXGL factory defaults and redraws all image elements.
XFreeColors call, then re-allocates each entry from the compile-time color_palette table. RedrawAllImages() is called unconditionally at the end.
Default palette
The table below lists the 16 factory-default palette entries as defined inmain.cc.
| Index | Constant | Name | R | G | B |
|---|---|---|---|---|---|
0x0 | CLR_BLACK | Black | 0 | 0 | 0 |
0x1 | CLR_BLUE | Dark Blue | 3 | 3 | 173 |
0x2 | CLR_GREEN | Dark Green | 0 | 170 | 0 |
0x3 | CLR_CYAN | Dark Cyan | 0 | 168 | 168 |
0x4 | CLR_RED | Dark Red | 186 | 6 | 6 |
0x5 | CLR_MAGENTA | Dark Magenta | 168 | 0 | 168 |
0x6 | CLR_ORANGE | Orange | 230 | 126 | 34 |
0x7 | CLR_LGRAY | Light Gray | 168 | 168 | 168 |
0x8 | CLR_GRAY | Dark Gray | 85 | 87 | 83 |
0x9 | CLR_LBLUE | Light Blue | 87 | 87 | 255 |
0xA | CLR_LGREEN | Light Green | 85 | 255 | 85 |
0xB | CLR_LCYAN | Light Cyan | 96 | 240 | 240 |
0xC | CLR_LRED | Light Red | 255 | 85 | 85 |
0xD | CLR_LMAGENTA | Light Magenta | 240 | 84 | 240 |
0xE | CLR_YELLOW | Yellow | 244 | 242 | 54 |
0xF | CLR_WHITE | White | 255 | 255 | 255 |