LWXGL includes a lightweight task queue that is processed on every iteration ofDocumentation 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.
MainWindowLoop. Tasks run on the main thread after event handling and rendering, which makes it safe to call any LWXGL function — update a label, spawn a modal, modify an image canvas — without locks or cross-thread coordination. This is the recommended way to run deferred or periodic work inside an LWXGL application.
Scheduling a Task
| Parameter | Description |
|---|---|
type | TASK_RUN_AFTER (one-shot) or TASK_RUN_EVERY (repeating). See the table below. |
delay_seconds | A double representing the delay in seconds, measured against GetElapsedTime(). |
task | A void callback(void) with no parameters, called when the task fires. |
Task Types
| Constant | Value | Behavior |
|---|---|---|
TASK_RUN_AFTER | 0 | Fires once after delay_seconds of elapsed time has passed. The task is then removed from the queue. |
TASK_RUN_EVERY | 1 | Fires repeatedly on each interval boundary separated by delay_seconds. The task remains in the queue indefinitely. |
Elapsed Time
MainWindowLoop started, as a double. The value increments each frame based on the real wall-clock time between frames. Tasks are checked against this value once per frame, immediately after on_every returns.
A TASK_RUN_AFTER task scheduled at elapsed time T with delay_seconds = D will fire on the first frame where elapsed_time >= T + D.
Cancellation
There is no explicit API to cancel a queued task. To prevent a repeating task from doing work, design its callback to check a shared flag and return early. The task remains in the queue and continues to fire, but its body is a no-op:Interval Alignment for TASK_RUN_EVERY
When aTASK_RUN_EVERY task is registered, LWXGL computes its first fire time as:
interval from program start, not from the moment of registration. As a result, a task registered with delay_seconds = 0.5 at elapsed time 1.3 will first fire at 1.5, then at 2.0, 2.5, and so on — regardless of when it was added.
Tasks scheduled with
TASK_RUN_EVERY use ceil-aligned start times relative to elapsed time, so they fire at even intervals from program start rather than from the moment they were registered.