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 (Lightweight X11 Graphics Library) is a small, dependency-light C library that makes it straightforward to open a window on Linux and populate it with interactive UI elements — text, buttons, inputs, checkboxes, images, and more. It sits directly on top of Xlib, compiles to a single shared object (libLWXGL.so), and exposes a plain C API that is usable from both C and C++ projects.

Installation

Build and install libLWXGL.so on your Linux system in two commands.

Quickstart

Create your first window and add interactive elements in minutes.

Guides

Learn how the window loop, elements, events, and palette work together.

API Reference

Full reference for every function in the public LWXGL header.

What you can build

LWXGL covers the full surface area for simple desktop GUI apps and 2-D interactive programs:

UI Elements

Text labels, buttons, text inputs, checkboxes, and rectangle panels — all managed by integer IDs.

Image Canvas

Allocate pixel buffers, draw with palette indices, and flush to the screen efficiently with GUpdateImage.

Primitives

Draw rectangles, circles, lines, and sprites (with RLE encoding) directly onto any image element.

Event Handling

Attach callbacks for keyboard, mouse-click, and window-close events, or poll input state every frame.

16-Color Palette

A built-in CGA-like palette maps color indices 0–15 to RGB values you can query and modify at runtime.

Game Loop

GSimpleWindowLoop drives a fixed-FPS render loop so you can focus on per-frame logic.

How it works

1

Build and install the library

Run make build && make install to compile libLWXGL.so and copy it to /usr/local/lib along with the header.
2

Include the header

Add #include <libLWXGL.h> to your C or C++ source file. The header uses an extern "C" guard so it works in both languages.
3

Create a window and add elements

Call GCreateWindow to open an X11 window, then create UI elements by ID using functions like GCreateButton and GCreateText.
4

Run the event loop

Use GSimpleWindowLoop for an automatic FPS-capped loop, or drive your own loop with GHandleWindowEvents and GRenderWindow.
LWXGL requires an X11 display server. It links against libX11 and uses the 9x15 bitmap font; both must be present on the target system.

Build docs developers (and LLMs) love