void run(){ static ButtonHandle mem = gui["mem"]; static ButtonHandle add = gui["add"]; static DrawHandle3D draw = gui["draw"]; static FPSLimiter fpslimit(10,10); fpslimit.setMaxFPS(parse<int>(gui["maxFPS"].as<std::string>())); paper->setTextureVisible(gui["showTexture"]); paper->setCubesVisible(gui["showCubes"]); paper->setShowAllConstraints(gui["showLinks"]); static float lastMargin = -1; float currMargin = gui["cm"]; if(lastMargin != currMargin){ paper->getSoftBody()->getCollisionShape()->setMargin(icl2bullet(currMargin)); lastMargin = currMargin; } if(mem.wasTriggered()){ paper->memorizeDeformation(); } static bool first = true; if(add.wasTriggered() || (first && pa("-a"))){ first = false; add_clutter(&scene,&scene,30); //TODO CHECK THIS OUT add_clutter(&scene, &world, 1, 5, false); } remove_fallen_objects(&scene, &scene); static Time lastTime = Time::now(); Time now = Time::now(); double dt = (now-lastTime).toSecondsDouble(); lastTime = now; if(gui["run"]){ paper->applyAllForces(gui["attractorStreangth"],gui["vertexMoveFactor"]); scene.Scene::lock(); paper->lock(); scene.step( dt * 5, 1); paper->unlock(); scene.Scene::unlock(); } foldLine.visualize(**draw); draw.render(); gui["fps"].render(); if(capturer){ capturer->capture(); } fpslimit.wait(); }
void IMainGame::run() { if (!init()) return; FPSLimiter limiter; limiter.setMaxFPS(60.0f); m_isRunning = true; while (m_isRunning) { limiter.begin(); inputManager.update(); update(); if (m_isRunning) { draw(); m_fps = limiter.end(); m_window.swapBuffer(); } } }
void App::run() { FPSLimiter fps; fps.setMaxFPS(60.0f); while (state == State::PLAY) { fps.begin(); long rightNowTick = SDL_GetTicks(); _step = (_now == 0 ? 0 : rightNowTick - _now); _now = rightNowTick; processInput(); update(); draw(); SDL_GL_SwapWindow(_window); _fps = fps.end(); } }