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 palette indices 0–15. Rather than specifying raw RGB values directly when drawing, every element and image canvas references one of these 16 slots. The palette functions let you read, modify, and reset the RGB values behind each index at runtime — changes take effect immediately across all rendered content that references the affected slot.

GPaletteQuery

void GPaletteQuery(int idx, unsigned char* r, unsigned char* g, unsigned char* b);
Retrieves the current RGB values for palette index idx by querying the X colormap.

Parameters

ParameterTypeDescription
idxintPalette index to query (0–15)
runsigned char*Output pointer filled with the red component (0–255)
gunsigned char*Output pointer filled with the green component (0–255)
bunsigned char*Output pointer filled with the blue component (0–255)

Example

unsigned char r, g, b;
GPaletteQuery(4, &r, &g, &b);
printf("Palette 4: rgb(%d, %d, %d)\n", r, g, b);

GPaletteModify

void GPaletteModify(int idx, unsigned char r, unsigned char g, unsigned char b, int redraw);
Replaces palette index idx with the given RGB values. The old X colormap entry is freed and a new one is allocated in its place.

Parameters

ParameterTypeDescription
idxintPalette index to modify (0–15)
runsigned charNew red component (0–255)
gunsigned charNew green component (0–255)
bunsigned charNew blue component (0–255)
redrawintIf non-zero, calls GRedrawAllImages() after updating the color
When modifying multiple palette entries in sequence, pass redraw=0 for all but the last call to avoid redundant redraws. GRedrawAllImages will then fire exactly once after all changes are in place.

Example

GPaletteModify(0,  20,  20,  40, 0); // Dark background — no redraw yet
GPaletteModify(15, 220, 220, 255, 1); // Bright foreground — redraw on last

GPaletteReset

void GPaletteReset(void);
Restores all 16 palette entries to their built-in default values (the CGA-like color set defined in main.cc) and calls GRedrawAllImages().

Default palette

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

Build docs developers (and LLMs) love