LWXGL uses a 16-color indexed palette (slots 0–15) that is allocated as X11 colors when the window is first created viaDocumentation 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. Every color argument throughout the API — for text, buttons, rectangles, image primitives, and checkboxes — is an index into this palette rather than a direct RGB value. The palette functions let you read current color values from the X server, replace individual slots at runtime, and restore all slots to their built-in defaults.
Default Palette
The table below lists the 16 built-in colors as defined in the library source. These values are restored byGPaletteReset.
| 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 |
Palette index
0 (black) is also used as the “transparent” color by GPrimitiveSprite for . pixels. Modifying slot 0 will affect both the background color treatment in sprites and any element that explicitly references index 0.GPaletteQuery
idx by querying the X server’s colormap directly. The returned values reflect whatever color is currently allocated in that slot — which may differ from the built-in defaults if GPaletteModify has been called. Values are written to the caller-supplied output pointers.
Palette slot to query (0–15).
Output pointer that receives the red component (0–255).
Output pointer that receives the green component (0–255).
Output pointer that receives the blue component (0–255).
GPaletteModify
idx with a new RGB value. Internally, the function frees the existing pixel allocation for that slot from the X server’s colormap and allocates a fresh one for the supplied r, g, b values. The updated pixel value is stored in the library’s internal colors[idx] array and will be used for all subsequent rendering of that palette index.
If redraw is set to 1, GRedrawAllImages() is called automatically after the update, which forces all image elements to re-flush their pixel buffers to the screen with the new color. Set redraw to 0 if you are batch-modifying multiple slots and want to trigger the redraw yourself at the end.
Palette slot to modify (0–15).
New red component (0–255).
New green component (0–255).
New blue component (0–255).
Pass
1 to call GRedrawAllImages() immediately after the color change. Pass 0 to skip the automatic redraw.GPaletteReset
GRedrawAllImages() is called unconditionally to refresh every image element on screen.
This function takes no parameters and has no return value.