LWXGL’s primitive drawing functions write palette-indexed pixels directly into an image element’s data buffer. All coordinates are in image-local space (relative to the top-left corner of the image, not the window). None of these functions callDocumentation 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.
UpdateImage — you must call it yourself after all drawing for a frame is complete.
The special sentinel value CLR_NONE (-1) can be passed for fg or bg on any primitive that accepts both; the corresponding layer (border or fill) is then skipped entirely.
PrimitiveRect
fg; interior pixels receive color bg. If fg == -1 (i.e., CLR_NONE passed as sentinel for “same as fill”), the border color is set equal to bg, effectively producing a solid rectangle.
Pixels outside the image bounds are silently clipped.
Element slot index of the target image element.
Left edge of the rectangle, in image-local coordinates.
Top edge of the rectangle, in image-local coordinates.
Width of the rectangle in pixels.
Height of the rectangle in pixels.
Border color — palette index 0–15, or
CLR_NONE (-1) to skip the border. If fg == -1, it is automatically set to bg before drawing (solid fill shortcut).Fill color — palette index 0–15, or
CLR_NONE (-1) to leave the interior untouched (outline-only rectangle).PrimitiveCircle
(cx, cy) with radius r. The border ring (pixels where |dist² - r²| < r) is drawn in color fg; interior pixels (dist² ≤ r²) are drawn in color bg. Either may be CLR_NONE to skip that layer.
Element slot index of the target image element.
X coordinate of the circle center, in image-local coordinates.
Y coordinate of the circle center, in image-local coordinates.
Radius in pixels.
Border color — palette index 0–15, or
CLR_NONE to skip the outline.Fill color — palette index 0–15, or
CLR_NONE to skip the interior.The border thickness grows slightly with radius because the proximity test uses
abs(dist² - r²) < r. For large circles the border will be approximately 1–2 pixels wide.PrimitiveLine
(x1, y1) to (x2, y2) using floating-point increments. The number of steps equals max(abs(dx), abs(dy)); at each step x and y are each advanced by dx/steps and dy/steps respectively, and the pixel position is rounded to the nearest integer with std::round. Pixels outside the image bounds are skipped.
Element slot index of the target image element.
X coordinate of the line start, in image-local coordinates.
Y coordinate of the line start, in image-local coordinates.
X coordinate of the line end, in image-local coordinates.
Y coordinate of the line end, in image-local coordinates.
Line color — palette index 0–15.
PrimitiveTriangle
(x1,y1), (x2,y2), and (x3,y3). The interior is filled with bg using a barycentric (edge-function) test; the three edges are drawn with fg via three PrimitiveLine calls. Either fg or bg may be CLR_NONE to skip outline or fill respectively.
The fill bounding box is clamped to [0, w-1] × [0, h-1] before iteration, so overdraw outside the image is impossible.
Element slot index of the target image element.
X coordinate of the first vertex.
Y coordinate of the first vertex.
X coordinate of the second vertex.
Y coordinate of the second vertex.
X coordinate of the third vertex.
Y coordinate of the third vertex.
Edge color — palette index 0–15, or
CLR_NONE to skip the outline.Fill color — palette index 0–15, or
CLR_NONE to skip the interior fill.PrimitiveSprite
(sx, sy). Each logical pixel is drawn as a scale × scale block of actual pixels.
Sprite format tokens
| Token | Meaning |
|---|---|
# | Draw one pixel in color |
. | Draw one pixel in CLR_BLACK (index 0) |
$ | Newline — advance y by scale, reset x to sx |
> | Skip one pixel to the right (x += scale) |
0–9 | Digit prefix — repeat count for the next single token or group |
[...] | Group — the contents are treated as a single repeated unit when prefixed with a digit |
! | Terminate parsing immediately |
12# draws 12 pixels). A digit prefix before [...] repeats the whole group. Pixels outside image bounds are silently clipped.
Element slot index of the target image element.
X coordinate of the sprite origin (top-left), in image-local coordinates.
Y coordinate of the sprite origin (top-left), in image-local coordinates.
Foreground color for
# pixels — palette index 0–15.Null-terminated RLE sprite string. Parsing stops at the first
\0 or !.Pixel scale factor. Each logical pixel becomes a
scale × scale block. Use 1 for 1:1 rendering.