LWXGL uses a fixed 16-entry indexed palette, where every color in the system is identified by an integer index fromDocumentation 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.
0 to 15. Every color parameter throughout the API — background colors, foreground colors, button states, text colors, and image pixel data — takes a palette index rather than a direct RGB value. This keeps the API uniform and makes it straightforward to retheme an entire application by changing a handful of palette entries. The special constant CLR_NONE (-1) means “no color” or transparent, and is accepted wherever a fill or background color is optional.
Default Palette
The 16 default colors are defined inmain.cc and allocated into the X11 colormap when CreateWindow is called. Named constants for each index are declared in libLWXGL.h.
| Index | Constant | Default Color | RGB |
|---|---|---|---|
| 0 | CLR_BLACK | Black | 0, 0, 0 |
| 1 | CLR_BLUE | Dark Blue | 3, 3, 173 |
| 2 | CLR_GREEN | Dark Green | 0, 170, 0 |
| 3 | CLR_CYAN | Dark Cyan | 0, 168, 168 |
| 4 | CLR_RED | Dark Red | 186, 6, 6 |
| 5 | CLR_MAGENTA | Dark Magenta | 168, 0, 168 |
| 6 | CLR_ORANGE | Orange | 230, 126, 34 |
| 7 | CLR_LGRAY | Light Gray | 168, 168, 168 |
| 8 | CLR_GRAY | Dark Gray | 85, 87, 83 |
| 9 | CLR_LBLUE | Light Blue | 87, 87, 255 |
| 10 | CLR_LGREEN | Light Green | 85, 255, 85 |
| 11 | CLR_LCYAN | Light Cyan | 96, 240, 240 |
| 12 | CLR_LRED | Light Red | 255, 85, 85 |
| 13 | CLR_LMAGENTA | Light Magenta | 240, 84, 240 |
| 14 | CLR_YELLOW | Yellow | 244, 242, 54 |
| 15 | CLR_WHITE | White | 255, 255, 255 |
CreateWindow. If any allocation fails, CreateWindow returns 127 + i where i is the index of the first failing entry.
Using Color Constants
Pass the named constants anywhere the API accepts a color parameter. This applies toCreateWindow, CreateText, CreateButton, CreateRect, CreateEllipse, CreateConsole, and all immediate-mode drawing functions:
Querying Palette Entries
PaletteQuery reads the current RGB values for a given palette slot. The values are written into the three unsigned char pointers you provide:
PaletteModify.
Modifying Palette Entries
PaletteModify replaces one palette slot with a new RGB color and optionally redraws all image elements so they reflect the change:
redraw to a non-zero value calls RedrawAllImages internally, which regenerates the pixel data for every Image element (type 4) using the updated palette. If you are modifying several entries at once, pass 0 for all but the last call to avoid redundant redraws:
Resetting the Palette
PaletteReset restores all 16 entries to the built-in defaults shown in the table above and always triggers a full image redraw:
PaletteModify sixteen times with the original RGB values, except it is implemented as a single atomic colormap operation — it frees all 16 current color pixels and reallocates them in one pass.