Skip to main content

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.

All colors in LWXGL are expressed as integers 0–15 that index into a shared 16-color palette. This keeps the rendering model simple and uniform: every element, image canvas, and primitive operation refers to the same palette, so a palette swap takes effect instantly across the entire window without touching any individual element.

Default palette table

IndexNameRGB
0Black000
1Dark Blue33173
2Dark Green01700
3Dark Cyan0168168
4Dark Red18666
5Dark Magenta1680168
6Orange23012634
7Light Gray168168168
8Dark Gray858783
9Light Blue8787255
10Light Green8525585
11Light Cyan96240240
12Light Red2558585
13Light Magenta24084240
14Yellow24424254
15White255255255

Packed-nibble color encoding

Many UI elements — buttons, inputs, checkboxes, and consoles — are styled with a single int that encodes two palette indices in one value:
  • The high nibble (bits 7–4) is the border or outline color.
  • The low nibble (bits 3–0) is the fill or background color.
For example, 0x72 selects Light Gray (7) as the border and Dark Green (2) as the fill:
// 0x72 = border: Light Gray (7), fill: Dark Green (2)
GCreateButton(0, 10, 10, 100, 30, 0x70, 0x72, 0x07, "OK", on_click);
Here the button has three packed-color states: 0x70 (unpressed), 0x72 (hovered), and 0x07 (pressed), giving it a visible state change using only palette indices.

Querying a palette entry

void GPaletteQuery(int idx, unsigned char* r, unsigned char* g, unsigned char* b);
Fills *r, *g, and *b with the current 8-bit RGB values for palette index idx. The values are read back from the X server colormap, so they reflect any in-flight modifications made with GPaletteModify.

Modifying a palette entry

void GPaletteModify(int idx, unsigned char r, unsigned char g, unsigned char b, int redraw);
Replaces the X server color cell at palette index idx with the given RGB values. If redraw is non-zero, GRedrawAllImages is called immediately so that every image canvas re-renders with the updated color — otherwise the change takes effect on the next render pass.

Resetting the palette

void GPaletteReset();
Restores all 16 palette entries to their default RGB values and calls GRedrawAllImages to update every image canvas. Use this to undo any runtime palette modifications and return to the standard color set.

Palette and TGA images

TGA image files loaded with change_palette = 1 (via GAllocateTGA or GCreateTGAImage) will overwrite palette entries 0–15 with the colors embedded in the TGA file’s color map when the image is drawn with GDrawIndexedTGA. This lets a single TGA file carry its own color scheme. See the TGA image guide for details.
Use GPaletteModify to implement global visual effects without touching any element directly. Cycling palette entries 0–15 through darker or warmer RGB values creates flash effects, day/night transitions, or full theme switches that take effect across every element in a single call.

Build docs developers (and LLMs) love