Skip to content

Commit

Permalink
Minimized/hidden runs at 10fps to save CPU/GPU
Browse files Browse the repository at this point in the history
  • Loading branch information
aardappel committed May 6, 2023
1 parent 13d2b6f commit 549dff8
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion dev/src/sdlsystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ vector<float> &SDLGetFrameTimeLog() { return frametimelog; }

bool SDLFrame() {
if (minimized) {
SDL_Delay(10); // save CPU/battery
SDL_Delay(100); // save CPU/battery
} else {
#ifndef __EMSCRIPTEN__
SDL_GL_SwapWindow(_sdl_window);
Expand Down Expand Up @@ -648,6 +648,16 @@ bool SDLFrame() {
// reload and bind shaders/textures here
break;
}
case SDL_WINDOWEVENT_MINIMIZED:
case SDL_WINDOWEVENT_HIDDEN:
minimized = true;
break;
case SDL_WINDOWEVENT_MAXIMIZED:
case SDL_WINDOWEVENT_RESTORED:
case SDL_WINDOWEVENT_SHOWN:
case SDL_WINDOWEVENT_EXPOSED:
minimized = false;
break;
case SDL_WINDOWEVENT_LEAVE:
// never gets hit?
/*
Expand Down

0 comments on commit 549dff8

Please sign in to comment.