LWXGL (Lightweight X11 Graphics Library) is a C shared library that makes it practical to build native Linux desktop GUI applications without reaching for a full widget toolkit. It wraps Xlib’s verbose, low-level API into a concise flat C interface — no classes, no callbacks to register against objects, no heavyweight framework to link against. You get a singleDocumentation 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.
.so and a single header, and you own the event loop.
What problem does it solve?
Writing directly against Xlib means managing display connections, graphics contexts, double-buffering, colormap allocation, font loading, and event dispatch yourself — thousands of lines of boilerplate before a window even appears. LWXGL handles all of that internally, exposing only the operations an application actually needs: create a window, place widgets, run the loop. At the same time, LWXGL deliberately avoids the complexity of toolkits like GTK or Qt. There is no object system, no build-time code generation, no mandatory runtime. If your program callsCreateWindow and MainWindowLoop, you are done. The tradeoff is intentional: LWXGL is the right choice for small utilities, game UIs, embedded panels, and learner projects — not for building a web browser.
Architecture overview
libLWXGL.so) paired with one header (libLWXGL.h). The header is the entire public API — there are no sub-headers, no generated code, and no pkg-config files to manage. The only external dependency is libX11; LWXGL links against it at build time so your application does not need to.
Key design decisions
ID-based element system. Every widget — text labels, buttons, input fields, images, rectangles, checkboxes — is identified by an integerid that you assign at creation. There are no handles or pointer types to manage. DeleteElement(id) removes any element regardless of type, and ElemSetVisible(id, 0) hides it without destroying it.
16-color indexed palette. All colors are expressed as 4-bit indices into a fixed 16-entry palette modelled on the classic CGA/VGA palette. The constants CLR_BLACK through CLR_WHITE cover all 16 values. The palette can be queried, modified per-index with PaletteModify, or reset to defaults with PaletteReset. Multi-color widget states (normal, hover, pressed) pack two color indices into one byte — the low nibble is the fill color, the high nibble is the border color.
Frame-rate-controlled main loop. MainWindowLoop(target_fps, on_every) drives everything. The loop measures elapsed time with std::chrono::steady_clock, sleeps between frames, and invokes your optional per-frame callback with the current tick counter and delta time in seconds. All Xlib event processing and widget rendering happen inside the loop; you never call XNextEvent yourself.
Double-buffered rendering. All drawing goes to an off-screen Pixmap (the back-buffer) and is presented atomically each frame, eliminating flicker without any effort on your part.
Canvas mode and scroll. Passing FLAG_CANVAS to CreateWindow allocates a full-window image element at id 0 that you can draw into with primitive operations and pixel manipulation functions. FLAG_RESIZE permits the window to be resized by the user. ReserveScroll (called before CreateWindow) enables a scrollable virtual canvas taller than the window.
Platform requirements
| Requirement | Details |
|---|---|
| Operating system | Linux (any distribution with an X11 server) |
| Display server | X11 (Xorg or XWayland) |
| Compiler | g++ with C++17 support (-std=gnu++17) |
| Runtime dependency | libX11 (Xlib) |
| Build dependency | libx11-dev (or distro equivalent) |
Where to go next
Installation
Build and install
libLWXGL.so from source in under five minutes.Quickstart
Write your first window, label, and button with a working event loop.
Core Concepts
Learn the ID system, color palette, flags, and the main loop in depth.
API Reference
Complete reference for every function, constant, and macro in the header.