Index: source/main.cpp =================================================================== --- source/main.cpp +++ source/main.cpp @@ -411,7 +411,16 @@ if (g_SoundManager) g_SoundManager->IdleTask(); - Render(); + if (ShouldRender()) + { + Render(); + + { + PROFILE3("swap buffers"); + SDL_GL_SwapWindow(g_VideoMode.GetWindow()); + ogl_WarnIfError(); + } + } g_Profiler.Frame(); Index: source/ps/Game.cpp =================================================================== --- source/ps/Game.cpp +++ source/ps/Game.cpp @@ -409,12 +409,7 @@ } if (doInterpolate) - { m_TurnManager->Interpolate(deltaSimTime, deltaRealTime); - - if ( g_SoundManager ) - g_SoundManager->IdleTask(); - } } void CGame::Interpolate(float simFrameLength, float realFrameLength) Index: source/ps/GameSetup/GameSetup.h =================================================================== --- source/ps/GameSetup/GameSetup.h +++ source/ps/GameSetup/GameSetup.h @@ -27,6 +27,8 @@ extern void Render(); +extern bool ShouldRender(); + /** * initialize global modules that are be needed before Init. * must be called from the very beginning of main. Index: source/ps/GameSetup/GameSetup.cpp =================================================================== --- source/ps/GameSetup/GameSetup.cpp +++ source/ps/GameSetup/GameSetup.cpp @@ -198,18 +198,17 @@ g_GUI->GetActiveGUI()->SendEventToAll("GameLoadProgress", paramData); } -void SwapBuffers() +bool ShouldRender() { - PROFILE3("swap buffers"); - SDL_GL_SwapWindow(g_VideoMode.GetWindow()); - ogl_WarnIfError(); + return !g_app_minimized && (g_app_has_focus || !g_VideoMode.IsInFullscreen()); } + void Render() { // Do not render if not focused while in fullscreen or minimised, // as that triggers a difficult-to-reproduce crash on some graphic cards. - if (g_app_minimized || (!g_app_has_focus && g_VideoMode.IsInFullscreen())) + if (!ShouldRender()) return; PROFILE3("render"); @@ -347,8 +346,6 @@ g_Profiler2.RecordGPUFrameEnd(); ogl_WarnIfError(); - - SwapBuffers(); } ErrorReactionInternal psDisplayError(const wchar_t* UNUSED(text), size_t UNUSED(flags)) Index: source/tools/atlas/GameInterface/View.cpp =================================================================== --- source/tools/atlas/GameInterface/View.cpp +++ source/tools/atlas/GameInterface/View.cpp @@ -40,6 +40,7 @@ #include "simulation2/components/ICmpObstructionManager.h" #include "simulation2/components/ICmpParticleManager.h" #include "simulation2/components/ICmpPathfinder.h" +#include "soundmanager/ISoundManager.h" extern void (*Atlas_GLSwapBuffers)(void* context); @@ -211,6 +212,10 @@ g_Game->Interpolate(actualFrameLength, realFrameLength); } + // Run sound idle tasks every frame. + if (g_SoundManager) + g_SoundManager->IdleTask(); + // Cinematic motion should be independent of simulation update, so we can // preview the cinematics by themselves g_Game->GetView()->GetCinema()->Update(realFrameLength);