From 3bc87854697b14731bb2ef86836db77562d9088b Mon Sep 17 00:00:00 2001 From: Attila Uygun Date: Mon, 5 Jun 2023 23:40:45 +0200 Subject: [PATCH] Fix for benchmark --- src/demo/demo.cc | 12 ++++++++++-- src/demo/demo.h | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/demo/demo.cc b/src/demo/demo.cc index 7713f48..ac66525 100644 --- a/src/demo/demo.cc +++ b/src/demo/demo.cc @@ -130,11 +130,11 @@ void Demo::Update(float delta_time) { if (do_benchmark_) { benchmark_time_ += delta_time; - if (benchmark_time_ > 1) { + if (benchmark_time_ > 3) { avarage_fps_ += Engine::Get().fps(); ++num_benchmark_samples_; } - if (benchmark_time_ > 6) { + if (benchmark_time_ > 5) { avarage_fps_ /= num_benchmark_samples_; do_benchmark_ = false; BenchmarkResult(avarage_fps_); @@ -166,6 +166,14 @@ void Demo::Update(float delta_time) { UpdateGameState(delta_time); } +void Demo::ContextLost() { + if (do_benchmark_) { + benchmark_time_ = 0; + num_benchmark_samples_ = 0; + avarage_fps_ = 0; + } +} + void Demo::LostFocus() {} void Demo::GainedFocus(bool from_interstitial_ad) { diff --git a/src/demo/demo.h b/src/demo/demo.h index 5016861..b3ec1ed 100644 --- a/src/demo/demo.h +++ b/src/demo/demo.h @@ -27,7 +27,7 @@ class Demo final : public eng::Game { void Update(float delta_time) final; - void ContextLost() final {} + void ContextLost() final; void LostFocus() final;