All color parameters in LWXGL are integer indices into a fixed, 16-entry RGB palette. Rather than accepting arbitrary hex values, every API that takes a color argument expects a number from 0 to 15. The palette is allocated as X11 color cells 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 is called and can be read or modified at runtime through the GPalette* family of functions.
Default Palette
The following 16 colors are loaded automatically at startup. They cover a classic CGA/terminal-inspired range from black through to white, including dark and light variants of the primary and secondary colors.| 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 |
Packed Color Encoding
Several element types — Button, Input, and Checkbox — have both a border/outline color and a fill/background color. Rather than taking two separate color parameters, these elements accept a single packed byte where each nibble holds one palette index. The encoding is:main.cc extract each nibble:
| Packed value | Border (H) | Fill (L) | Result |
|---|---|---|---|
0x07 | 0 — Black | 7 — Light Gray | Black border, light gray fill |
0xF0 | 15 — White | 0 — Black | White border, black fill |
0x2A | 2 — Dark Green | 10 — Light Green | Dark green border, light green fill |
Rect’s
fg and bg parameters are plain palette indices, not packed bytes. Use -1 for either to skip drawing that layer. Only Button, Input, and Checkbox use the packed nibble encoding.Runtime Palette Modification
The palette is stored as live X11 color cells, so changes take effect immediately on the next rendered frame.GPaletteModify
idx with the given RGB values. The existing color cell is freed and a new one is allocated in the X11 colormap. If redraw is nonzero, all image elements are immediately redrawn so their pixel data reflects the new color mapping.
GPaletteQuery
idx back from the X11 colormap into the provided output pointers. Values are in the range 0–255.
GPaletteReset
color_palette[], and calls GRedrawAllImages to refresh every image element. Use this to restore the palette after experimental modifications.