| 58 | } |
| 59 | |
| 60 | void RenderFrame(float deltaT, bool enableDraw) |
| 61 | { |
| 62 | if (Glob.exit) |
| 63 | { |
| 64 | GApp->m_closeRequest = true; |
| 65 | } |
| 66 | if (!GWorld) |
| 67 | { |
| 68 | return; |
| 69 | } |
| 70 | |
| 71 | int startTime = Poseidon::Foundation::GlobalTickCount(); |
| 72 | GDebugger.NextAliveExpected(10000); |
| 73 | |
| 74 | GWorld->SetSimulationFocus(enableDraw); |
| 75 | GWorld->Simulate(deltaT, enableDraw); |
| 76 | |
| 77 | GApp->m_forceRender = false; |
| 78 | |
| 79 | #if _ENABLE_CHEATS |
| 80 | static int limitFpsCoef = 0; |
| 81 | #define limitFps (limitFpsCoef > 0 ? 40 / limitFpsCoef : 0) |
| 82 | auto& renderInput = InputSubsystem::Instance(); |
| 83 | if (renderInput.GetCheat2ToDo(SDL_SCANCODE_S)) |
| 84 | { |
| 85 | limitFpsCoef++; |
| 86 | if (limitFpsCoef > 4) |
| 87 | limitFpsCoef = 0; |
| 88 | GlobalShowMessage(500, "Limit FPS %d", limitFps); |
| 89 | } |
| 90 | #else |
| 91 | const bool limitFps = false; |
| 92 | auto& renderInput = InputSubsystem::Instance(); |
| 93 | #endif |
| 94 | |
| 95 | // PAUSE key toggles HW T&L. All F-keys are taken (F1=help, |
| 96 | // F2-F11 = units / lang via DisplayMain, F12 = language cycle |
| 97 | // via displayUI.hpp:1040), and modifier-prefixed keys don't pass |
| 98 | // through ConsumeKeyPress; PAUSE has no other handler. |
| 99 | extern bool EnableHWTLState; |
| 100 | if (renderInput.ConsumeKeyPress(SDL_SCANCODE_PAUSE)) |
| 101 | { |
| 102 | EnableHWTLState = !EnableHWTLState; |
| 103 | GlobalShowMessage(500, "DX T&L %s", EnableHWTLState ? "On" : "Off"); |
| 104 | LOG_INFO(Graphics, "DX T&L toggled to {} (PAUSE)", EnableHWTLState ? "On" : "Off"); |
| 105 | } |
| 106 | |
| 107 | if (!enableDraw || GWorld->GetRenderingDisabled() || limitFps) |
| 108 | { |
| 109 | #if _ENABLE_CHEATS |
| 110 | int maxFps = limitFpsCoef ? limitFps : 50; |
| 111 | #else |
| 112 | const int maxFps = 50; |
| 113 | #endif |
| 114 | const int minMsPerFrame = 1000 / maxFps; |
| 115 | |
| 116 | int durationMs = Poseidon::Foundation::GlobalTickCount() - startTime; |
| 117 | int sleepMillis = minMsPerFrame - durationMs; |
no test coverage detected