LWXGL supports embedding a hardware-accelerated OpenGL surface inside a window via a GLX pixmap. The surface appears as a regular LWXGL element — sized and positioned like any other — but receives OpenGL draw calls instead of palette-indexed pixels. This lets you mix retained UI elements and OpenGL rendering in the same window without an additional toolkit or window split.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.
Requirements
The display depth must be 24 or 32 bpp.CreateOpenGL queries glXChooseFBConfig for a matching framebuffer configuration and returns 0 immediately if none is found. Check the return value before proceeding.
Creating the OpenGL Element
id— integer element slot, used in subsequentChangeGLXContextcalls.x,y— position of the surface within the window.w,h— dimensions of the OpenGL rendering surface in pixels.border— palette color index for a 1-pixel decorative border drawn around the surface by the LWXGL compositor. PassCLR_NONE(-1) for no border.
1 on success, 0 if no suitable GLXFBConfig was found or if the display depth is unsupported.
When a non-
CLR_NONE border is specified, LWXGL internally increases the element’s bounding box by 2 pixels in each dimension (1-pixel border on each side). The OpenGL surface itself remains w × h; the border is drawn outside it during compositing.Making the Context Current
id current for all subsequent OpenGL calls on the calling thread. Pass -1 to detach from any active context (equivalent to glXMakeContextCurrent(dpy, None, None, NULL)).
Rendering
After callingChangeGLXContext(id), the full OpenGL API is available — state changes, draw calls, texture uploads, and so on. At the end of each frame, call SynchronizeOpenGL before returning control to LWXGL:
glFlush() followed by glXWaitGL(), ensuring all pending GPU commands are flushed and the pixmap is ready for the LWXGL compositor to copy to the window back-buffer. Skipping this step can cause tearing or partial frames.
Typical Per-Frame Flow
Integrate OpenGL rendering with theon_every callback passed to MainWindowLoop:
Using TGA Textures in OpenGL
LWXGL can convert a previously loaded TGA image (see TGA & XBM) into an OpenGL texture:GL_NEAREST filtering. Returns the GLuint texture ID on success, or 0 if:
- No TGA with the given name exists, or
- The TGA’s palette pointer is
NULL(e.g., it was loaded as an XBM).
GLConvertTGA. The texture is created with GL_REPEAT wrapping and GL_NEAREST min/mag filters. The transparent palette index (if set via AllocateTGA) is emitted as alpha 0 in the uploaded RGBA data.
The OpenGL pixmap is composited into LWXGL’s back-buffer each frame automatically. All standard LWXGL elements — buttons, text, image canvases — and immediate-mode drawing functions (
ImmediateRect, ImmediateText, etc.) continue to work alongside the OpenGL element. Use SetRenderingOrder if you need to control whether LWXGL elements appear in front of or behind the OpenGL surface.