diff --git a/include/window.h b/include/window.h index b2a3003..6a72cca 100644 --- a/include/window.h +++ b/include/window.h @@ -39,7 +39,6 @@ window_t* window_create(int width, int height, const char* title); void window_destroy(window_t* s); bool window_pollevent(window_t* s); void window_blit(window_t* s, const uint32_t* framebuffer); -void window_limit_framerate(window_t* s, int target_fps); bool window_is_key_down(window_t* s, int key_scancode); bool window_is_mouse_button_down(window_t* s, int button_index); void window_get_mouse_position(window_t* s, int* x, int* y); diff --git a/src/main.cpp b/src/main.cpp index 76daab0..e20dcc2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -591,7 +591,7 @@ int main() { compositor_mark_content_dirty(compositor, name_id); compositor_mark_content_dirty(compositor, dialogue_id); - // NEW: Update animation tracker + // Update animation tracker anim_tracker.update(delta_time_sec); static bool mouse_was_down = false; diff --git a/src/window.cpp b/src/window.cpp index 6a7eea0..9e72fa8 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -131,34 +131,4 @@ void window_blit(window_t* s, const uint32_t* framebuffer) { SDL_RenderCopy(s->renderer, s->texture, nullptr, nullptr); SDL_RenderPresent(s->renderer); } - -void window_limit_framerate(window_t* s, int target_fps) { - if (target_fps <= 0) { - // No capping or division by zero prevention - s->last_tick_time = SDL_GetTicks(); - return; - } - - // Desired time (in ms) for one frame - const uint32_t frame_delay_ms = 1000 / target_fps; - - // Current time - const uint32_t current_tick_time = SDL_GetTicks(); - - // Time elapsed since the last call to this function - const uint32_t elapsed_time = current_tick_time - s->last_tick_time; - - // If the elapsed time is less than the desired frame time, delay execution. - if (elapsed_time < frame_delay_ms) { - // Calculate the time to wait - uint32_t time_to_wait = frame_delay_ms - elapsed_time; - SDL_Delay(time_to_wait); - - // Update the last_tick_time *after* the delay - s->last_tick_time = current_tick_time + time_to_wait; - } else { - // No delay needed (running slow or exactly on time), just update the start time - s->last_tick_time = current_tick_time; - } -} }