LWXGL uses a fixed 16-entry color palette, initialized from theDocumentation 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.
color_palette[] table in main.cc when GCreateWindow is called. Every color reference throughout the library — element colors, primitive drawing colors, image pixel values — is a palette index from 0 to 15. The Palette API lets you read back the current RGB value of any entry, replace an entry with new RGB values, and restore all entries to their defaults.
GPaletteQuery
idx by calling XQueryColor on the X11 colormap. The result reflects the color as actually allocated in the X server, which is scaled back from the 16-bit X11 representation.
Palette entry index to query (0–15).
Receives the red component of the color (0–255).
Receives the green component of the color (0–255).
Receives the blue component of the color (0–255).
GPaletteModify
idx with the given RGB values. The old X11 color allocation for that index is freed and a new one is allocated. If redraw is non-zero, GRedrawAllImages() is called after the update so that image canvases immediately reflect the new color.
Palette entry index to modify (0–15).
New red component (0–255).
New green component (0–255).
New blue component (0–255).
Pass a non-zero value to call
GRedrawAllImages() immediately after updating the palette entry. Pass 0 to defer the visual update (useful when modifying several palette entries in one go — call GRedrawAllImages() manually once at the end).GPaletteReset
color_palette[] array in main.cc). All existing X11 color allocations are freed first, then re-allocated from the defaults. Calls GRedrawAllImages() automatically after the reset.
GRedrawAllImages
GUpdateImage to force a complete pixel-by-pixel repaint using the current palette. Typically called internally by GPaletteModify (when redraw != 0) and GPaletteReset, but may also be called manually whenever a full image refresh is needed.
Default Palette
The following table shows the 16 default palette entries as defined incolor_palette[] in main.cc. These are the values restored by GPaletteReset.
| 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 |