Every color in LWXGL is referenced by a palette index from 0 to 15. WhenDocumentation 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.
GCreateWindow runs, all 16 colors are allocated upfront as X11 colormap entries using XAllocColor. From that point on, every drawing call — text, buttons, primitives, image pixels — uses one of these 16 indices rather than raw RGB values. This indexed approach keeps the API simple and enables instant global theme changes: modifying a single palette slot immediately affects every element that references that index.
Default Palette
The table below lists the 16 default colors as they are defined in the LWXGL source. These values are loaded at startup and can be changed at runtime withGPaletteModify.
| 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 Palette Entry
idx by querying the X server’s colormap directly. The results reflect any previous GPaletteModify calls, not the compile-time defaults.
Modifying a Palette Entry
idx with the new RGB values. The old pixel value is freed from the colormap and a new one is allocated in its place.
| Parameter | Description |
|---|---|
idx | Palette index to replace (0–15) |
r, g, b | New color components (0–255 each) |
redraw | Pass 1 to call GRedrawAllImages() immediately, 0 to defer |
redraw to 1 when you want image canvases to reflect the new color right away. Set it to 0 when you are changing multiple palette slots in a single frame — call GRedrawAllImages() manually after the last change to avoid redundant work.
Modifying a palette entry affects how all image pixels that use that index render. This includes every
GCreateImage canvas currently in the element table. It does not affect the stored byte values in the pixel buffers — only the X11 color that those index values map to.Resetting the Palette
GRedrawAllImages() after restoring the palette.
How Colors Are Used in the API
Colors appear in three distinct forms across LWXGL’s API:Single palette index
A plain integer 0–15 representing one color directly. Used by
GCreateText (text color), image primitive functions (GPrimitiveLine, GPrimitiveCircle fill/border, etc.), GClearImage, GPrimitiveSprite, and the bgcol parameter of GCreateWindow.Nibble-packed byte
A single
int where the low nibble (bits 0–3) is the fill/background palette index and the high nibble (bits 4–7) is the border/outline palette index. Used by GCreateButton (unpressed/hover/pressed), GCreateInput (inactive/hover), GCreateCheckbox (cb_col), and GCreateRect — but note that GCreateRect accepts two separate plain indices for fg and bg rather than a packed byte.Background color
The
bgcol parameter passed to GCreateWindow is a single palette index used to clear the window background at the start of every GRenderWindow call.