Add restart and handle quitting with callback
This commit is contained in:
12
main.c
12
main.c
@@ -8,6 +8,13 @@
|
||||
|
||||
#define MAX(a, b) ((a) < (b) ? (b) : (a))
|
||||
|
||||
static bool run;
|
||||
|
||||
static void quit()
|
||||
{
|
||||
run = false;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
const int input_fd = input_init();
|
||||
@@ -15,6 +22,8 @@ int main()
|
||||
rng_init();
|
||||
game_init(renderer_params.aspect);
|
||||
|
||||
input_on_quit(quit);
|
||||
|
||||
renderer_clear();
|
||||
renderer_swap();
|
||||
|
||||
@@ -22,7 +31,8 @@ int main()
|
||||
const int max_fd = MAX(input_fd, drm_fd);
|
||||
fd_set set;
|
||||
|
||||
while (!input.quit) {
|
||||
run = true;
|
||||
while (run) {
|
||||
FD_ZERO(&set);
|
||||
FD_SET(input_fd, &set);
|
||||
FD_SET(drm_fd, &set);
|
||||
|
||||
Reference in New Issue
Block a user