Ejemplo n.º 1
0
        //----------------------------------------------------
        //----------------------------------------------------
		void Application::Update(f32 in_deltaTime, TimeIntervalSecs in_timestamp)
		{
            if(m_shouldNotifyConnectionsResumeEvent == true)
			{
				m_shouldNotifyConnectionsResumeEvent = false;
				OnResume();
			}
            
            if(m_shouldNotifyConnectionsForegroundEvent == true)
			{
				m_shouldNotifyConnectionsForegroundEvent = false;
				OnForeground();
			}
            
            if(m_isSuspending)
            {
                // Updating after told to suspend so early out
                return;
            }
            
#if CS_ENABLE_DEBUG
            //When debugging we may have breakpoints so restrict the time between
            //updates to something feasible.
            in_deltaTime = std::min(in_deltaTime, 0.5f);
#endif
            
			//Update the app time since start
			m_currentAppTime = in_timestamp;
            
			m_taskScheduler->ExecuteMainThreadTasks();
            
            //We do not need to render as often as we update so this callback will be triggered
            //less freqenctly than the update frequency suggests. We must work out how many times to update based on the time since last frame
            //and our actual update frequency. We carry the remainder to the next frame until we have a full update cycle
            m_updateIntervalRemainder = std::min(m_updateIntervalRemainder + in_deltaTime, GetUpdateIntervalMax());
            
			//process any queued input received by the pointer system.
			if(m_pointerSystem != nullptr)
			{
				m_pointerSystem->ProcessQueuedInput();
			}
            
            while((m_updateIntervalRemainder >= GetUpdateInterval()) || m_isFirstFrame)
            {
                m_updateIntervalRemainder -=  GetUpdateInterval();
                
                //update all of the application systems
                for (const AppSystemUPtr& system : m_systems)
                {
                    system->OnFixedUpdate(GetUpdateInterval());
                }
                
                m_stateManager->FixedUpdateStates(GetUpdateInterval());
                
                m_isFirstFrame = false;
            }
            
            //Tell the state manager to update the active state
            OnUpdate(in_deltaTime);
		}
Ejemplo n.º 2
0
 //-----------------------------------------
 //-----------------------------------------
 void State::Foreground()
 {
     u32 numSystems = m_systems.size();
     for(u32 i=0; i<numSystems; ++i)
     {
         m_systems[i]->OnForeground();
     }
     
     m_scene->ForegroundEntities();
     
     OnForeground();
 }