do_sync¶
MiniLibX: mlx_do_sync
Shows everything drawn so far on screen right away, without waiting for the
next frame of loop.
Parameters¶
| Name | Type | Description |
|---|---|---|
mlx |
Mlx |
The connection from init |
Returns¶
None.
Raises¶
| Exception | When |
|---|---|
RuntimeError |
The window system failed to show a window (rare) |
Notes¶
- Every open window is shown, just as one frame of
loopwould show it. Like a frame, it can wait a moment to stay within 60 fps. - Input that arrives during
do_syncisn't lost. It's kept, and the event hooks get it at the loop's next event step. No hooks run insidedo_sync. - Windows the user closed are removed, and their DestroyNotify (event 17) is delivered by the loop, as usual.
- Inside
loopyou rarely need it, because every frame is shown anyway. It's useful beforeloop, for example to show a loading screen during slow setup.
Example¶
malibx.string_put(mlx, win, 20, 30, 0xFFFFFF, "loading…")
malibx.do_sync(mlx) # visible now, before the slow part
world = build_world() # takes a few seconds
malibx.loop_hook(mlx, frame, world)
malibx.loop(mlx)