Changeset View
Changeset View
Standalone View
Standalone View
source/main.cpp
Show First 20 Lines • Show All 354 Lines • ▼ Show 20 Lines | |||||||||
static void Frame() | static void Frame() | ||||||||
{ | { | ||||||||
g_Profiler2.RecordFrameStart(); | g_Profiler2.RecordFrameStart(); | ||||||||
PROFILE2("frame"); | PROFILE2("frame"); | ||||||||
g_Profiler2.IncrementFrameNumber(); | g_Profiler2.IncrementFrameNumber(); | ||||||||
PROFILE2_ATTR("%d", g_Profiler2.GetFrameNumber()); | PROFILE2_ATTR("%d", g_Profiler2.GetFrameNumber()); | ||||||||
bool takeScreenshots; | |||||||||
float screenshotsFPS; | |||||||||
int screenshotsStartTime; | |||||||||
CFG_GET_VAL("videorendering.enabled", takeScreenshots); | |||||||||
CFG_GET_VAL("videorendering.fps", screenshotsFPS); | |||||||||
Stan: Stuff should probably be out. | |||||||||
CFG_GET_VAL("videorendering.start", screenshotsStartTime); | |||||||||
bool doScreenshot = takeScreenshots && g_Game && | |||||||||
g_Game->IsGameStarted() && g_Game->SimTime() >= screenshotsStartTime * 1000; | |||||||||
// get elapsed time | // get elapsed time | ||||||||
const double time = timer_Time(); | const double time = timer_Time(); | ||||||||
g_frequencyFilter->Update(time); | g_frequencyFilter->Update(time); | ||||||||
// .. old method - "exact" but contains jumps | // .. old method - "exact" but contains jumps | ||||||||
#if 0 | #if 0 | ||||||||
static double last_time; | static double last_time; | ||||||||
const double time = timer_Time(); | const double time = timer_Time(); | ||||||||
const float TimeSinceLastFrame = (float)(time-last_time); | const float TimeSinceLastFrame = (float)(time-last_time); | ||||||||
last_time = time; | last_time = time; | ||||||||
ONCE(return); // first call: set last_time and return | ONCE(return); // first call: set last_time and return | ||||||||
// .. new method - filtered and more smooth, but errors may accumulate | // .. new method - filtered and more smooth, but errors may accumulate | ||||||||
#else | #else | ||||||||
const float realTimeSinceLastFrame = 1.0 / g_frequencyFilter->SmoothedFrequency(); | const float realTimeSinceLastFrame = 1.0f / (doScreenshot ? screenshotsFPS : g_frequencyFilter->SmoothedFrequency()); | ||||||||
#endif | #endif | ||||||||
ENSURE(realTimeSinceLastFrame > 0.0f); | ENSURE(realTimeSinceLastFrame > 0.0f); | ||||||||
Not Done Inline Actions
Stan: | |||||||||
// Decide if update is necessary | // Decide if update is necessary | ||||||||
bool need_update = true; | bool need_update = true; | ||||||||
// Don't pause renderer nor GameView Update on focus loss | |||||||||
g_app_has_focus = g_app_has_focus || doScreenshot; | |||||||||
// If we are not running a multiplayer game, disable updates when the game is | // If we are not running a multiplayer game, disable updates when the game is | ||||||||
// minimized or out of focus and relinquish the CPU a bit, in order to make | // minimized or out of focus and relinquish the CPU a bit, in order to make | ||||||||
// debugging easier. | // debugging easier. | ||||||||
if (g_PauseOnFocusLoss && !g_NetClient && !g_app_has_focus) | if (g_PauseOnFocusLoss && !g_NetClient && !g_app_has_focus) | ||||||||
{ | { | ||||||||
PROFILE3("non-focus delay"); | PROFILE3("non-focus delay"); | ||||||||
need_update = false; | need_update = false; | ||||||||
// don't use SDL_WaitEvent: don't want the main loop to freeze until app focus is restored | // don't use SDL_WaitEvent: don't want the main loop to freeze until app focus is restored | ||||||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | #endif | ||||||||
g_Console->Update(realTimeSinceLastFrame); | g_Console->Update(realTimeSinceLastFrame); | ||||||||
if (g_SoundManager) | if (g_SoundManager) | ||||||||
g_SoundManager->IdleTask(); | g_SoundManager->IdleTask(); | ||||||||
g_Renderer.RenderFrame(true); | g_Renderer.RenderFrame(true); | ||||||||
if (doScreenshot) | |||||||||
g_Renderer.MakeScreenShotOnNextFrame(CRenderer::ScreenShotType::DEFAULT); | |||||||||
g_Profiler.Frame(); | g_Profiler.Frame(); | ||||||||
LimitFPS(); | LimitFPS(); | ||||||||
} | } | ||||||||
static void NonVisualFrame() | static void NonVisualFrame() | ||||||||
{ | { | ||||||||
g_Profiler2.RecordFrameStart(); | g_Profiler2.RecordFrameStart(); | ||||||||
▲ Show 20 Lines • Show All 293 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Stuff should probably be out.