diff --git a/desktop_version/src/Graphics.cpp b/desktop_version/src/Graphics.cpp index dda2eb34..8a1bb266 100644 --- a/desktop_version/src/Graphics.cpp +++ b/desktop_version/src/Graphics.cpp @@ -8,6 +8,7 @@ #include "Entity.h" #include "Exit.h" #include "FileSystemUtils.h" +#include "GraphicsUtil.h" #include "Map.h" #include "Music.h" #include "Screen.h" @@ -3069,6 +3070,32 @@ void Graphics::renderwithscreeneffects(void) } } +void Graphics::renderfixedpre(void) +{ + if (game.screenshake > 0) + { + updatescreenshake(); + } + + if (screenbuffer != NULL && screenbuffer->badSignalEffect) + { + UpdateFilter(); + } +} + +void Graphics::renderfixedpost(void) +{ + /* Screen effects timers */ + if (game.flashlight > 0) + { + --game.flashlight; + } + if (game.screenshake > 0) + { + --game.screenshake; + } +} + void Graphics::bigrprint(int x, int y, std::string& t, int r, int g, int b, bool cen, float sc) { std::vector& font = flipmode ? flipbfont : bfont; diff --git a/desktop_version/src/Graphics.h b/desktop_version/src/Graphics.h index ee901c3f..366857b8 100644 --- a/desktop_version/src/Graphics.h +++ b/desktop_version/src/Graphics.h @@ -156,6 +156,8 @@ public: void render(void); void renderwithscreeneffects(void); + void renderfixedpre(void); + void renderfixedpost(void); bool Hitest(SDL_Surface* surface1, point p1, SDL_Surface* surface2, point p2); diff --git a/desktop_version/src/main.cpp b/desktop_version/src/main.cpp index eec68c0e..faef0503 100644 --- a/desktop_version/src/main.cpp +++ b/desktop_version/src/main.cpp @@ -318,6 +318,9 @@ static enum LoopCode loop_run_active_funcs(void) } } + /* About to switch over to rendering... but call this first. */ + graphics.renderfixedpre(); + return Loop_stop; } @@ -682,6 +685,9 @@ static void inline deltaloop(void) accumulator = SDL_fmodf(accumulator, timesteplimit); + /* We are done rendering. */ + graphics.renderfixedpost(); + fixedloop(); } const float alpha = game.over30mode ? static_cast(accumulator) / timesteplimit : 1.0f; @@ -744,25 +750,11 @@ static void focused_begin(void) static void focused_end(void) { - //Screen effects timers - if (game.flashlight > 0) - { - game.flashlight--; - } - if (game.screenshake > 0) - { - game.screenshake--; - graphics.updatescreenshake(); - } + /* no-op. */ } static enum LoopCode loop_end(void) { - if (graphics.screenbuffer->badSignalEffect) - { - UpdateFilter(); - } - //We did editorinput, now it's safe to turn this off key.linealreadyemptykludge = false;