S3D_MAINLOOP(3)
π S3D_MAINLOOP π
okay bestie, welcome to the s3d_mainloop page from the s3d Manual β yes this is a section 3 manual page, we're in library-call territory, and honestly? it's giving main character energy β¨
πΈ NAME πΈ
s3d_mainloop β literally just: set the mainloop of your program π«Ά
β¨ SYNOPSIS β¨
lowkey the whole vibe in two lines:
#include <s3d.h>
int s3d_mainloop(void(*)(void) f);
π¦ DESCRIPTION π¦
okay so. it takes a function as an argument. that's it, that's the tea π
it will loop that function β over and over and over β until a quit-event shows up. when the quit-event hits, the loop is done, periodt. π
you can pass NULL if you genuinely have no function you want looped. no shame. BUT β and this is the important bit, bestie, don't skip it β it's better to sleep some time if you have nothing to do anyway, so you can save cpu-time. your fans will thank you, your battery will thank you, the whole machine will thank you π₯
here's the vibe:
void mainloop(void)
{
usleep(1000); // sleep 1 ms in every cycle
}
...
s3d_mainloop(mainloop());
see that usleep(1000)? that's the 1 ms nap in every cycle. ngl that little nap is iconic. π
fr fr: if you've got nothing to do in the loop, nap. busy-waiting is not the move.
π AUTHOR π
Simon Wunderlich β Author of s3d π
and that's the whole page, bestie!! this was the s3d manual, S3D_MAINLOOP(3), and we're signing off from the s3d crew π go loop something cute ππ¦π
π¦ where this page comes from
- debian bookworm: s3d-doc 0.2.2.1-5 Β· GPL-2.0-or-later
- debian trixie: s3d-doc 0.2.2.1-7 Β· GPL-2.0-or-later
- ubuntu jammy: s3d-doc 0.2.2.1-3build1 Β· GPL-2.0-or-later
- ubuntu noble: s3d-doc 0.2.2.1-6build3 Β· GPL-2.0-or-later
- ubuntu questing: s3d-doc 0.2.2.1-7build1
- ubuntu resolute: s3d-doc 0.2.2.1-7build3 Β· GPL-2.0-or-later
- ubuntu stonking: s3d-doc 0.2.3-1 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms