diff --git a/main.cpp b/main.cpp index ba45d45..a23c96c 100644 --- a/main.cpp +++ b/main.cpp @@ -109,17 +109,22 @@ int main() { } SDL_UnlockSurface(window_surface); - const auto start_time = clock::now(); auto next_poll_events_time = start_time; auto frame_start = start_time; clock::duration frame_time; for (bool continu = true; continu;) { - { - // measure frame_time - auto now = clock::now(); - frame_time = now - frame_start; - frame_start = now; + // measure frame_time + const auto now = clock::now(); + frame_time = now - frame_start; + frame_start = now; + + if (now >= next_poll_events_time) { + next_poll_events_time = now + std::chrono::milliseconds{200}; + poll_events(continu); + std::println( + "last frame_time={} batchsize={}", frame_time, batchsize + ); } SDL_LockSurface(window_surface); @@ -134,17 +139,7 @@ int main() { )[pos.x + pos.y * window_surface->w] = walk_color; } SDL_UnlockSurface(window_surface); - SDL_UpdateWindowSurface(window); - - const auto now = clock::now(); - if (now >= next_poll_events_time) { - next_poll_events_time = now + std::chrono::milliseconds{200}; - poll_events(continu); - std::println( - "last frame_time={} batchsize={}", frame_time, batchsize - ); - } } // leaking memory, nothing I can do