diff --git a/libultraship/libultraship/Lib/Fast3D/gfx_glx.cpp b/libultraship/libultraship/Lib/Fast3D/gfx_glx.cpp index d450558b2..957f1c7c8 100644 --- a/libultraship/libultraship/Lib/Fast3D/gfx_glx.cpp +++ b/libultraship/libultraship/Lib/Fast3D/gfx_glx.cpp @@ -156,6 +156,7 @@ static struct { Atom atom_wm_delete_window; bool is_fullscreen; + bool is_running = true; void (*on_fullscreen_changed)(bool is_now_fullscreen); int keymap[256]; @@ -399,7 +400,7 @@ static void gfx_glx_set_keyboard_callbacks(bool (*on_key_down)(int scancode), bo } static void gfx_glx_main_loop(void (*run_one_game_iter)(void)) { - while (1) { + while (glx.is_running) { run_one_game_iter(); } } @@ -440,7 +441,7 @@ static void gfx_glx_handle_events(void) { } } if (xev.type == ClientMessage && (Atom)xev.xclient.data.l[0] == glx.atom_wm_delete_window) { - exit(0); + glx.is_running = false; } } } diff --git a/libultraship/libultraship/Lib/Fast3D/gfx_sdl2.cpp b/libultraship/libultraship/Lib/Fast3D/gfx_sdl2.cpp index e80097c81..81a5b38e9 100644 --- a/libultraship/libultraship/Lib/Fast3D/gfx_sdl2.cpp +++ b/libultraship/libultraship/Lib/Fast3D/gfx_sdl2.cpp @@ -37,6 +37,7 @@ static int vsync_enabled = 0; static unsigned int window_width = DESIRED_SCREEN_WIDTH; static unsigned int window_height = DESIRED_SCREEN_HEIGHT; static bool fullscreen_state; +static bool is_running = true; static void (*on_fullscreen_changed_callback)(bool is_now_fullscreen); static bool (*on_key_down_callback)(int scancode); static bool (*on_key_up_callback)(int scancode); @@ -135,7 +136,7 @@ static void gfx_sdl_init(const char *game_name, bool start_in_fullscreen) { SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); -#ifndef __linux +#ifndef __linux__ timer = CreateWaitableTimer(nullptr, false, nullptr); #endif @@ -194,14 +195,13 @@ static void gfx_sdl_set_keyboard_callbacks(bool (*on_key_down)(int scancode), bo } static void gfx_sdl_main_loop(void (*run_one_game_iter)(void)) { - while (1) - { + while(is_running) { run_one_game_iter(); } } static void gfx_sdl_get_dimensions(uint32_t *width, uint32_t *height) { - *width = window_width; + *width = window_width; *height = window_height; } @@ -250,7 +250,7 @@ static void gfx_sdl_handle_events(void) { } break; case SDL_QUIT: - exit(0); + is_running = false; } } }