Fix for benchmark

This commit is contained in:
Attila Uygun 2023-06-05 23:40:45 +02:00
parent 5c6e414a15
commit 3bc8785469
2 changed files with 11 additions and 3 deletions

View File

@ -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) {

View File

@ -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;