diff --git a/seika/ska_sdl.c b/seika/ska_sdl.c new file mode 100644 index 0000000..c8be043 --- /dev/null +++ b/seika/ska_sdl.c @@ -0,0 +1,42 @@ +#include "ska_sdl.h" + +#include + +#if SKA_INPUT +#include "input/sdl_input.h" +#endif + +#if SKA_RENDERING +#include "rendering/renderer.h" +#endif + +bool ska_sdl_update() { + bool shouldQuit = false; + SDL_Event event; + while (SDL_PollEvent(&event)) { + switch(event.type) { + case SDL_EVENT_QUIT: { + shouldQuit = true; + break; + } + case SDL_EVENT_WINDOW_RESIZED: { +#if SKA_RENDERING + const Sint32 windowWidth = event.window.data1; + const Sint32 windowHeight = event.window.data2; + ska_renderer_update_window_size(windowWidth, windowHeight); +#endif + break; + } + default: { +#if SKA_INPUT + ska_sdl_process_event(event); +#endif + break; + } + } + } +#if SKA_INPUT + ska_sdl_process_axis_events(); +#endif + return shouldQuit; +} diff --git a/seika/ska_sdl.h b/seika/ska_sdl.h new file mode 100644 index 0000000..adcd2de --- /dev/null +++ b/seika/ska_sdl.h @@ -0,0 +1,5 @@ +#pragma once + +#include "seika/defines.h" + +bool ska_sdl_update(); diff --git a/seika/version_info.h b/seika/version_info.h index e802b82..d81e3ff 100644 --- a/seika/version_info.h +++ b/seika/version_info.h @@ -4,6 +4,6 @@ #define SKA_VERSION_MAJOR 0 #define SKA_VERSION_MINOR 2 -#define SKA_VERSION_PATCH 0 +#define SKA_VERSION_PATCH 1 #define SKA_VERSION (SKA_MACRO_TO_STRING(SKA_VERSION_MAJOR) "." SKA_MACRO_TO_STRING(SKA_VERSION_MINOR) "." SKA_MACRO_TO_STRING(SKA_VERSION_PATCH)) diff --git a/test/game/src/main.c b/test/game/src/main.c index b7b6664..e0fe840 100644 --- a/test/game/src/main.c +++ b/test/game/src/main.c @@ -1,11 +1,10 @@ #include -#include - +#include +#include #include #include #include -#include #include static void game_initialize() { @@ -28,34 +27,12 @@ static void game_finalize() { static void game_run() { while (true) { ska_input_new_frame(); - - bool shouldQuit = false; - SDL_Event event; - while (SDL_PollEvent(&event)) { - switch(event.type) { - case SDL_EVENT_QUIT: { - shouldQuit = true; - break; - } - case SDL_EVENT_WINDOW_RESIZED: { - const Sint32 windowWidth = event.window.data1; - const Sint32 windowHeight = event.window.data2; - ska_renderer_update_window_size(windowWidth, windowHeight); - break; - } - default: { - ska_sdl_process_event(event); - break; - } - } - } - ska_sdl_process_axis_events(); - + const bool shouldQuit = ska_sdl_update(); if (shouldQuit || ska_input_is_key_just_pressed(SkaInputKey_KEYBOARD_ESCAPE, 0)) { break; } ska_window_render(&(SkaColor){ 0.2f, 0.2f, 0.2f, 1.0f }); - SDL_Delay(10); + ska_delay(10); } }