void Game::DoTick( U32 _currentTime ) { GPUDevice* device = GPUDevice::Instance(); { //GRINLIZ_PERFTRACK PROFILE_FUNC(); currentTime = _currentTime; if ( previousTime == 0 ) { previousTime = currentTime-1; } U32 deltaTime = currentTime - previousTime; if ( markFrameTime == 0 ) { markFrameTime = currentTime; frameCountsSinceMark = 0; framesPerSecond = 0.0f; } else { ++frameCountsSinceMark; if ( currentTime - markFrameTime > 500 ) { framesPerSecond = 1000.0f*(float)(frameCountsSinceMark) / ((float)(currentTime - markFrameTime)); // actually K-tris/second markFrameTime = currentTime; frameCountsSinceMark = 0; } } // Limit so we don't ever get big jumps: if ( deltaTime > 100 ) deltaTime = 100; device->ResetState(); Scene* scene = sceneStack.Top()->scene; Color4F cc = scene->ClearColor(); device->Clear( cc.x, cc.y, cc.z, cc.w ); scene->DoTick( deltaTime ); { //GRINLIZ_PERFTRACK_NAME( "Game::DoTick 3D" ); PROFILE_BLOCK( DoTick3D ); screenport.SetPerspective(); scene->Draw3D( deltaTime ); } { //GRINLIZ_PERFTRACK_NAME( "Game::DoTick UI" ); PROFILE_BLOCK( DoTickUI ); GLASSERT( scene ); // UI Pass screenport.SetUI(); if ( renderUI ) { screenport.SetUI(); scene->RenderGamui2D(); } } } int Y = 0; int space = 16; #ifndef GRINLIZ_DEBUG_MEM // const int memNewCount = 0; #endif #if 1 UFOText* ufoText = UFOText::Instance(); if (SettingsManager::Instance()->DebugFPS()) { ufoText->Draw(0, Y, "%s %5.1ffps %4.1fK/f %3ddc/f fver=%d", VERSION, framesPerSecond, (float)device->TrianglesDrawn() / 1000.0f, device->DrawCalls(), CURRENT_FILE_VERSION); } if ( debugText ) { sceneStack.Top()->scene->DrawDebugText(); } Y += space; #endif #ifdef EL_SHOW_MODELS int k=0; while ( k < nModelResource ) { int total = 0; for( unsigned i=0; i<modelResource[k].nGroups; ++i ) { total += modelResource[k].atom[i].trisRendered; } UFODrawText( 0, 12+12*k, "%16s %5d K", modelResource[k].name, total ); ++k; } #endif #ifdef GRINLIZ_PROFILE PROFILE_UPDATE(); if ( perfText ) { PrintPerf(); } #endif screenport.SetUI(); UFOText::Instance()->FinalDraw(); device->ResetTriCount(); previousTime = currentTime; PushPopScene(); }