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 πŸŽ€πŸ¦‹πŸ’