Workaround for too fast calling of m_app->Render
parent
92591c23b6
commit
02b76e5aba
|
@ -136,6 +136,9 @@ CApplication::CApplication(CSystemUtils* systemUtils)
|
|||
m_curTimeStamp = m_systemUtils->CreateTimeStamp();
|
||||
m_lastTimeStamp = m_systemUtils->CreateTimeStamp();
|
||||
|
||||
m_manualFrameLast = m_systemUtils->CreateTimeStamp();
|
||||
m_manualFrameTime = m_systemUtils->CreateTimeStamp();
|
||||
|
||||
for (int i = 0; i < PCNT_MAX; ++i)
|
||||
{
|
||||
m_performanceCounters[i][0] = m_systemUtils->CreateTimeStamp();
|
||||
|
@ -166,6 +169,9 @@ CApplication::~CApplication()
|
|||
m_systemUtils->DestroyTimeStamp(m_curTimeStamp);
|
||||
m_systemUtils->DestroyTimeStamp(m_lastTimeStamp);
|
||||
|
||||
m_systemUtils->DestroyTimeStamp(m_manualFrameLast);
|
||||
m_systemUtils->DestroyTimeStamp(m_manualFrameTime);
|
||||
|
||||
for (int i = 0; i < PCNT_MAX; ++i)
|
||||
{
|
||||
m_systemUtils->DestroyTimeStamp(m_performanceCounters[i][0]);
|
||||
|
@ -1316,6 +1322,19 @@ void CApplication::Render()
|
|||
StopPerformanceCounter(PCNT_SWAP_BUFFERS);
|
||||
}
|
||||
|
||||
void CApplication::RenderIfNeeded(int updateRate)
|
||||
{
|
||||
m_systemUtils->GetCurrentTimeStamp(m_manualFrameTime);
|
||||
long long diff = m_systemUtils->TimeStampExactDiff(m_manualFrameLast, m_manualFrameTime);
|
||||
if (diff < 1e9f / updateRate)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_systemUtils->CopyTimeStamp(m_manualFrameLast, m_manualFrameTime);
|
||||
|
||||
Render();
|
||||
}
|
||||
|
||||
void CApplication::SuspendSimulation()
|
||||
{
|
||||
m_simulationSuspended = true;
|
||||
|
|
|
@ -329,6 +329,9 @@ public:
|
|||
//! Renders the image in window
|
||||
void Render();
|
||||
|
||||
//! Renders the image in window if needed
|
||||
void RenderIfNeeded(int updateRate);
|
||||
|
||||
protected:
|
||||
//! Creates the window's SDL_Surface
|
||||
bool CreateVideoSurface();
|
||||
|
@ -421,6 +424,9 @@ protected:
|
|||
bool m_simulationSuspended;
|
||||
//@}
|
||||
|
||||
SystemTimeStamp* m_manualFrameLast;
|
||||
SystemTimeStamp* m_manualFrameTime;
|
||||
|
||||
//! Graphics device to use
|
||||
std::string m_graphics;
|
||||
|
||||
|
|
|
@ -3778,6 +3778,13 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
|
|||
CompileScript(soluce); // compiles all scripts
|
||||
|
||||
m_ui->GetLoadingScreen()->SetProgress(1.0f, RT_LOADING_FINISHED);
|
||||
if (m_ui->GetLoadingScreen()->IsVisible())
|
||||
{
|
||||
// Force render of the "Loading finished" screen
|
||||
// TODO: For some reason, rendering of the first frame after the simulation starts is very slow
|
||||
// We're doing this because it looks weird when the progress bar is finished but it still says "Loading programs"
|
||||
m_app->Render();
|
||||
}
|
||||
|
||||
if (!resetObject)
|
||||
{
|
||||
|
|
|
@ -154,7 +154,7 @@ void CScreenLoading::SetProgress(float progress, const std::string& text, const
|
|||
{
|
||||
SetBackground("textures/interface/interface.png");
|
||||
m_engine->SetBackForce(true);
|
||||
m_app->Render();
|
||||
m_app->RenderIfNeeded(60);
|
||||
}
|
||||
|
||||
m_lastProgress = progress;
|
||||
|
|
Loading…
Reference in New Issue