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.

LWXGL maintains a 16-entry color palette (indices 0–15). Every color argument throughout the API — border colors, fill colors, text colors, primitive drawing colors — is an index into this palette. The palette is initialized from compile-time defaults when GCreateWindow is called, and can be freely inspected and modified at runtime.
Modifying a palette entry changes the appearance of every element currently using that color index — including UI widgets (buttons, rects, checkboxes, consoles) that reference it as a border or fill color. Changes take effect globally and immediately.

GPaletteQuery

void GPaletteQuery(int idx, unsigned char* r, unsigned char* g, unsigned char* b)
Reads the current RGB values of palette entry idx by querying the X11 colormap via XQueryColor.
  • idx — palette index to query (0–15).
  • r, g, b — pointers to unsigned char variables that receive the red, green, and blue components (0–255) of the color at that index.
Notes: Values are queried live from the X11 colormap, so this always reflects the current allocated color even after a prior GPaletteModify call.

GPaletteModify

void GPaletteModify(int idx, unsigned char r, unsigned char g, unsigned char b, int redraw)
Replaces palette entry idx with a new RGB color. The old X11 color allocation is freed and a new one is allocated in the default colormap.
  • idx — palette index to replace (0–15).
  • r, g, b — new red, green, and blue components (0–255).
  • redraw — if non-zero, calls GRedrawAllImages after updating the palette entry to repaint all image canvases using the new color mapping.
Notes: Only the internal colors[idx] pixel value is updated — the color_palette defaults array is not modified, so GPaletteReset will still restore the original factory values.

GPaletteReset

void GPaletteReset(void)
Restores all 16 palette entries to their factory defaults (the values defined in main.cc) and then calls GRedrawAllImages to repaint all image canvases. All 16 existing color allocations are freed at once before the defaults are re-allocated, ensuring no stale entries remain in the X11 colormap.

Default Palette

IndexNameHexRGB
0Black#000000000
1Dark Blue#0303AD33173
2Dark Green#00AA0001700
3Dark Cyan#00A8A80168168
4Dark Red#BA060618666
5Dark Magenta#A800A81680168
6Orange#E67E2223012634
7Light Gray#A8A8A8168168168
8Dark Gray#555753858783
9Light Blue#5757FF8787255
10Light Green#55FF558525585
11Light Cyan#60F0F096240240
12Light Red#FF55552558585
13Light Magenta#F054F024084240
14Yellow#F4F23624424254
15White#FFFFFF255255255

GRedrawAllImages

void GRedrawAllImages(void)
Forces all image elements to fully repaint on the next render pass by invalidating their dirty-pixel caches (sets all prev buffer bytes to 255, guaranteeing every pixel is considered changed and re-pushed to the X11 image). This function is called automatically by GPaletteModify (when redraw != 0) and always by GPaletteReset. Call it manually after any external change — such as directly modifying an image’s raw data buffer via GGetImageData — that requires a full canvas refresh rather than an incremental update.

Code Example — Query, Modify, and Reset

unsigned char r, g, b;

// inspect current slot 6 (Orange by default)
GPaletteQuery(6, &r, &g, &b);
printf("Original slot 6: rgb(%d, %d, %d)\n", r, g, b);
// prints: Original slot 6: rgb(230, 126, 34)

// replace slot 6 with a custom purple and immediately repaint all images
GPaletteModify(6, 120, 40, 200, 1);

// ... some time later, restore all factory defaults ...
GPaletteReset();

Build docs developers (and LLMs) love