bool Tick() { bool DoNextTick = true; DoNextTick = TickSim(); TickRender(); SwitchToThread(); return DoNextTick; }
bool Launch( SimpleString& CommandLine ) { if( g_NumWarnings > 0 ) { AddStatus( SimpleString::PrintF( "\nContentSyncer finished with %d warnings.\n\nPress Enter to continue.", g_NumWarnings ), g_StatusColor ); // Mini loop in here, ugh! for(;;) { g_Keyboard->Tick( 0.0f ); if( GetForegroundWindow() == GetConsoleWindow() ) { if( g_Keyboard->OnRise( Keyboard::EB_Enter ) ) { break; } } TickRender(); SwitchToThread(); } } STARTUPINFO StartupInfo; PROCESS_INFORMATION ProcessInfo; ZeroMemory( &StartupInfo, sizeof( StartupInfo ) ); StartupInfo.cb = sizeof( StartupInfo ); ZeroMemory( &ProcessInfo, sizeof( ProcessInfo ) ); // See Process Creation Flags DWORD Flags = CREATE_DEFAULT_ERROR_MODE | // Don't inherit error mode CREATE_NEW_CONSOLE; // Create new console (DETACHED_PROCESS also means this console isn't inherited; but a new console must be created with AllocConsole) BOOL Result = CreateProcess( NULL, // Application name (optional--use the first argument from command line if NULL) CommandLine.MutableCStr(), // Command line (optional, includes application name) NULL, // Process attributes (optional pointer to a SECURITY_ATTRIBUTES) NULL, // Thread attributes (optional pointer to a SECURITY_ATTRIBUTES) FALSE, // Inherit handles Flags, // Creation flags (see Process Creation Flags) NULL, // Environment block (optional void*) NULL, // Current directory (optional string) &StartupInfo, // Startup info &ProcessInfo // Process info ); return Result == TRUE; }
/*virtual*/ bool Framework3D::Tick() { XTRACE_FUNCTION; PROFILE_FUNCTION; bool DoNextTick = true; if( HasRequestedExit() ) { DoNextTick = false; } m_HasFocus = m_Window->HasFocus(); StringManager::FlushStrings( StringManager::ESL_Transient ); m_Clock->Tick( m_UIManager->GetUIStack()->PausesGame(), false ); m_EventManager->Tick(); if( m_DoVideoCapture ) { // One sim tick, one render tick DoNextTick &= TickSim( m_VideoCaptureFixedFrameTime ); TickRender(); } else if( m_UseFixedFrameTime ) { m_FrameTimeAccumulator += m_Clock->GetMachineDeltaTime(); if( m_FrameTimeAccumulator > m_FrameTimeLimit ) { // We've hit a very long frame, maybe we were sitting in the debugger. // Don't bother simming for this duration, it will just cause more hitches. m_FrameTimeAccumulator = 0.0f; } const int NumSimTicks = static_cast<int>( m_FrameTimeAccumulator / m_FixedFrameTime ); const int LastSimTick = NumSimTicks - 1; for( int SimTickIndex = 0; SimTickIndex <= LastSimTick && DoNextTick; ++SimTickIndex ) { ASSERT( m_FrameTimeAccumulator >= m_FixedFrameTime ); m_FrameTimeAccumulator -= m_FixedFrameTime; DoNextTick &= TickSim( m_FixedFrameTime ); if( SimTickIndex == LastSimTick ) { TickRender(); } else { DropRender(); } } } else { // One sim tick, one render tick DoNextTick &= TickSim( m_Clock->GetMachineDeltaTime() ); TickRender(); } #if BUILD_WINDOWS_NO_SDL { XTRACE_NAMED( SwitchToThread ); // Crashing within this trace name would typically indicate a crash in another thread. const BOOL SwitchedToThread = SwitchToThread(); if( 0 == SwitchedToThread ) { // Prevent hogging the CPU, maybe? Sleep( 0 ); } } #endif #if BUILD_SDL { SDL_Delay( 0 ); } #endif return DoNextTick; }