Index: ps/trunk/source/main.cpp =================================================================== --- ps/trunk/source/main.cpp +++ ps/trunk/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: ps/trunk/source/ps/Game.cpp =================================================================== --- ps/trunk/source/ps/Game.cpp +++ ps/trunk/source/ps/Game.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2018 Wildfire Games. +/* Copyright (C) 2019 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -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: ps/trunk/source/ps/GameSetup/GameSetup.h =================================================================== --- ps/trunk/source/ps/GameSetup/GameSetup.h +++ ps/trunk/source/ps/GameSetup/GameSetup.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2018 Wildfire Games. +/* Copyright (C) 2019 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -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: ps/trunk/source/ps/GameSetup/GameSetup.cpp =================================================================== --- ps/trunk/source/ps/GameSetup/GameSetup.cpp +++ ps/trunk/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: ps/trunk/source/tools/atlas/GameInterface/View.cpp =================================================================== --- ps/trunk/source/tools/atlas/GameInterface/View.cpp +++ ps/trunk/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);