The window API covers all functions that manage the X11 window itself — creation, the render loop, window properties, screen management, modal dialogs, and region capture. Every other LWXGL function depends on a successfully created window, soDocumentation 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.
GCreateWindow must always be the first call in your program.
GCreateWindow
9x15 bitmap font, and allocates all 16 palette colors from the default colormap. Must be called before any other LWXGL function.
Width of the window in pixels.
Height of the window in pixels.
Initial window title bar text.
Background fill color as a palette index (0–15). This is the color the back-buffer is cleared to on every call to
GRenderWindow.| Value | Meaning |
|---|---|
0 | Success. |
1 | Could not open the X display — the DISPLAY environment variable is likely not set. |
2 | Could not load the default font (9x15). |
3 | A window is already open; GCreateWindow was called twice without an intervening GTerminateWindow. |
127 + i | Could not allocate palette color i from the X colormap. Any colors allocated before the failure are freed before returning. |
GTerminateWindow
GWindowShouldClose() returns 1 and your main loop exits.
GDeleteWindow
GWindowShouldClose() to return 1 on the next check. If a delete callback has been registered with GEventAttachDelete, that callback is invoked first; its return value determines whether closing is actually allowed (1 = allow, 0 = block).
This function is called automatically by the library when the user clicks the window manager’s close button (the WM_DELETE_WINDOW protocol message), but you can also call it directly — for example from a quit button’s onclick handler.
GWindowShouldClose
1 when the window has been signaled to close, 0 otherwise. Use this as the condition of a manual render loop:
GHandleWindowEvents
ConfigureNotify (resize), and ClientMessage (window close). Call this once per frame, before GRenderWindow, so that input state and element focus are up to date when rendering begins.
GRenderWindow
XCopyArea. The render sequence is:
- Clear the back-buffer to the current background color.
- Draw all elements whose
screenfield matches the active screen, or whosescreenis-1(visible on all screens). - Draw the active modal dialog, if one is open.
- Draw the debug performance overlay, if enabled (toggled by pressing F12 at runtime).
GSimpleWindowLoop
GHandleWindowEvents and GRenderWindow each frame, then calls on_every with the current frame counter and delta time. The loop exits when GWindowShouldClose() returns 1.
Frame pacing uses std::chrono monotonic timing. When the work time is shorter than the target frame duration, the loop sleeps the remaining time (minus 1 ms as a scheduling margin) and yields to other threads when the slack is very small.
Desired frames per second. The loop targets a frame interval of
1 000 000 / target_fps microseconds.Callback invoked once per frame after rendering.
tick is the zero-based frame counter incremented each frame. delta_time is the elapsed time in seconds since the previous frame. Pass NULL if no per-frame callback is needed.GSetWindowTitle
XStoreName. Takes effect immediately; no redraw is required.
New null-terminated title string.
GSetWindowColor
GRenderWindow. The change takes effect on the next rendered frame.
Palette index (0–15) to use as the new background color.
GEnableResizing
GCreateWindow (which lock min and max dimensions to the initial width and height), allowing the user to freely resize the window. Registers a resize callback that is invoked after the back-buffer pixmap has been recreated for the new dimensions. Must be called after GCreateWindow.
Callback invoked whenever the window is resized.
w and h are the new width and height in pixels. Use this callback to reposition or rescale elements that depend on window dimensions.GScreenActive
-1) are rendered by GRenderWindow.
GScreenApply
s. After this call, those elements are only rendered (and interactive) when *GScreenActive() == s. Elements with a screen value of -1 are always visible regardless of the active screen.
Screen index to assign the elements to.
Array of element IDs to reassign.
Number of entries in
ids.GSpawnModal
0 — show an OK button only. 1 — show both OK and Cancel buttons.Message text displayed inside the modal dialog.
Callback invoked when the user clicks OK. Pass
NULL if no confirmation action is needed.GQueryModalOpen
1 if a modal dialog is currently displayed, 0 otherwise. Useful for suppressing application actions that should not run while a dialog is on screen.
GCaptureRegion
w × h bytes of palette-index pixel data. The caller is responsible for freeing the returned buffer with free().
Left edge of the capture region in back-buffer coordinates.
Top edge of the capture region in back-buffer coordinates.
Width of the region in pixels.
Height of the region in pixels.
66 + w * h bytes containing a complete TGA file. Free with free() when done.