void SFMLApplication::run() { LOG("Entering main loop..."); sf::Clock clock; isRunning_ = true; while(isRunning_) { processEvents_(); demo_scene_->update(clock.GetElapsedTime()/1000.0f); clock.Reset(); render_(); } LOG("Exiting main loop..."); }
void GUITests::runSpaceSimulation() { MotionManager motionManager( MotionManager::Integration::RK4, MotionManager::Technique::functor ); sf::Clock clock; sf::Time totalTime; CommandQueue commandQueue; // Not used sf::Time timeSinceLastUpdate = sf::Time::Zero; while( mainWindow_.isOpen() ) { sf::Time elapsedAbsoluteTime = clock.restart(); timeSinceLastUpdate += elapsedAbsoluteTime * timeScale_; while( timeSinceLastUpdate >= dt_ ) { motionManager.computeLinearDynamics( dt_.asSeconds(), physicalObjects_ ); sceneGraph_.update( dt_, commandQueue ); timeSinceLastUpdate -= dt_; totalTime += dt_; } sf::Event event; while( mainWindow_.pollEvent( event ) ) { switch( event.type ) { case sf::Event::Closed: { mainWindow_.close(); break; } } } //sceneGraph_.update( dt_, commandQueue ); // Debug updateFPSStats_( elapsedAbsoluteTime ); view_.setCenter( csHandler_.convertToDisplayCS( physicalObjects_[2]->getPosition() ) ); render_(); } }
void GUITests::runCollisionSimulation() { MotionManager motionManager( MotionManager::Integration::RK4, MotionManager::Technique::functor ); sf::Clock clock; sf::Time totalTime; CommandQueue commandQueue; // Not used sf::Time timeSinceLastUpdate = sf::Time::Zero; while( mainWindow_.isOpen() ) { sf::Time elapsedAbsoluteTime = clock.restart(); timeSinceLastUpdate += elapsedAbsoluteTime * timeScale_; while( timeSinceLastUpdate >= dt_ ) { motionManager.computeLinearKinematics( dt_.asSeconds(), physicalObjects_ ); sceneGraph_.update( dt_, commandQueue ); //CollisionControl::handleCollisionsBalls( sceneGraph_ ); CollisionControl::handleCollisions( balls_ ); timeSinceLastUpdate -= dt_; totalTime += dt_; } sf::Event event; while( mainWindow_.pollEvent( event ) ) { switch( event.type ) { case sf::Event::Closed: { mainWindow_.close(); break; } } } // Debug updateFPSStats_( elapsedAbsoluteTime ); render_(); } }
void freeglut_application::display_() { render_(); glutSwapBuffers(); }
void ApplicationLoop::timerEvent (QTimerEvent *e) { get_input_ (); render_ (); }