LWXGL renders every pixel using a fixed 16-color palette. Each color is allocated in the X server’s colormap at startup, and every image element stores pixel data as 4-bit palette indices rather than direct RGB values. This means changing a single palette entry immediately affects every pixel that uses that index — across all image elements, text elements, rectangles, and buttons — as soon as those elements are next redrawn.Documentation 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.
Default Palette
The default palette is defined inmain.cc and loaded at CreateWindow time. Use these constants (defined in libLWXGL.h) to refer to palette entries by name throughout your application.
| Index | Constant | Default RGB |
|---|---|---|
0x0 | CLR_BLACK | (0, 0, 0) |
0x1 | CLR_BLUE | (3, 3, 173) |
0x2 | CLR_GREEN | (0, 170, 0) |
0x3 | CLR_CYAN | (0, 168, 168) |
0x4 | CLR_RED | (186, 6, 6) |
0x5 | CLR_MAGENTA | (168, 0, 168) |
0x6 | CLR_ORANGE | (230, 126, 34) |
0x7 | CLR_LGRAY | (168, 168, 168) |
0x8 | CLR_GRAY | (85, 87, 83) |
0x9 | CLR_LBLUE | (87, 87, 255) |
0xA | CLR_LGREEN | (85, 255, 85) |
0xB | CLR_LCYAN | (96, 240, 240) |
0xC | CLR_LRED | (255, 85, 85) |
0xD | CLR_LMAGENTA | (240, 84, 240) |
0xE | CLR_YELLOW | (244, 242, 54) |
0xF | CLR_WHITE | (255, 255, 255) |
PaletteQuery
idx via XQueryColor. The values returned reflect the live colormap state, so they will differ from the defaults if you have called PaletteModify.
Palette index to query — must be in the range
0–15.Output pointer. Receives the red component (0–255).
Output pointer. Receives the green component (0–255).
Output pointer. Receives the blue component (0–255).
PaletteModify
idx with a new RGB color. The old X server color allocation is freed, and a new one is requested via XAllocColor. If redraw is 1, RedrawAllImages() is called immediately to update all image elements.
Palette index to modify — must be in the range
0–15.New red component (0–255).
New green component (0–255).
New blue component (0–255).
Pass
1 to trigger an immediate full redraw of all image elements. Pass 0 to defer — useful when modifying several entries in a loop (call RedrawAllImages() manually after all changes).PaletteReset
color_palette[] defaults, then calls RedrawAllImages(). Use this to undo a temporary palette swap applied by a TGA with change_palette = 1.
TGA files loaded with
change_palette = 1 override the palette each time DrawIndexedTGA is called. Call PaletteReset() after drawing them if you want to restore the standard colors for subsequent rendering.