| 1892 | } |
| 1893 | |
| 1894 | static void StepFrame(HEngine engine, float dt) |
| 1895 | { |
| 1896 | uint64_t frame_start = dmTime::GetMonotonicTime(); |
| 1897 | |
| 1898 | dmProfiler::SetUpdateFrequency((uint32_t)(1.0f / dt)); |
| 1899 | |
| 1900 | if (dmGraphics::GetWindowStateParam(engine->m_GraphicsContext, WINDOW_STATE_ICONIFIED) |
| 1901 | && !dmRender::IsRenderPaused(engine->m_RenderContext)) |
| 1902 | { |
| 1903 | if (!engine->m_WasIconified) |
| 1904 | { |
| 1905 | engine->m_WasIconified = true; |
| 1906 | |
| 1907 | if (!engine->m_RunWhileIconified) |
| 1908 | { |
| 1909 | dmSound::Pause(true); |
| 1910 | } |
| 1911 | } |
| 1912 | |
| 1913 | if (!engine->m_RunWhileIconified) { |
| 1914 | // NOTE: Polling the event queue is crucial on iOS for life-cycle management |
| 1915 | // NOTE: Also running graphics on iOS while transitioning is not permitted and will crash the application |
| 1916 | dmHID::Update(engine->m_HidContext); |
| 1917 | dmTime::Sleep(1000 * 100); |
| 1918 | return; |
| 1919 | } |
| 1920 | } |
| 1921 | else |
| 1922 | { |
| 1923 | if (engine->m_WasIconified) |
| 1924 | { |
| 1925 | engine->m_WasIconified = false; |
| 1926 | |
| 1927 | dmSound::Pause(false); |
| 1928 | } |
| 1929 | } |
| 1930 | |
| 1931 | HProfile profile = ProfileFrameBegin(); |
| 1932 | { |
| 1933 | DM_PROFILE("Frame"); |
| 1934 | |
| 1935 | bool do_render = g_EngineRenderEnabled && !dmRender::IsRenderPaused(engine->m_RenderContext); |
| 1936 | |
| 1937 | { |
| 1938 | DM_PROFILE("Sim"); |
| 1939 | |
| 1940 | bool has_input = false; |
| 1941 | { |
| 1942 | DM_PROFILE("Hid"); |
| 1943 | has_input = dmHID::Update(engine->m_HidContext); |
| 1944 | } |
| 1945 | |
| 1946 | // Check if we should skip this frame |
| 1947 | if (UpdateFrameThrottle(engine, dt, has_input)) |
| 1948 | { |
| 1949 | ProfileFrameEnd(profile); |
| 1950 | return; |
| 1951 | } |
no test coverage detected