Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 25, 2008, 8:29:05 PM (16 years ago)
Author:
rgrieder
Message:
  • added a little text box to the HUD that says how much of the main loop we spend with rendering. (can easily be commented)
  • fixed a bug in KeyBinder.cc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/network/src/orxonox/Orxonox.cc

    r1414 r1422  
    466466    timer_->reset();
    467467
     468    float renderTime = 0.0f;
     469    float frameTime = 0.0f;
     470    clock_t time = 0;
     471
    468472    COUT(3) << "Orxonox: Starting the main loop." << std::endl;
    469473          while (!bAbort_)
     
    480484      evt.timeSinceLastEvent = calculateEventTime(now, eventTimes[0]);
    481485      evt.timeSinceLastFrame = calculateEventTime(now, eventTimes[1]);
     486      frameTime += evt.timeSinceLastFrame;
    482487
    483488      // show the current time in the HUD
    484489      // HUD::getSingleton().setTime(now);
     490      if (frameTime > 0.4f)
     491      {
     492        HUD::getSingleton().setRenderTimeRatio(renderTime / frameTime);
     493        frameTime = 0.0f;
     494        renderTime = 0.0f;
     495      }
    485496
    486497      // Call those objects that need the real time
     498      for (Iterator<TickableReal> it = ObjectList<TickableReal>::start(); it; ++it)
     499        it->tick((float)evt.timeSinceLastFrame);
     500      // Call the scene objects
    487501      for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; ++it)
    488502        it->tick((float)evt.timeSinceLastFrame * this->timefactor_);
    489       // Call the scene objects
    490       for (Iterator<TickableReal> it = ObjectList<TickableReal>::start(); it; ++it)
    491         it->tick((float)evt.timeSinceLastFrame);
    492503      // TODO: currently a hack. Somehow the console doesn't work with OrxonoxClass
    493504      orxonoxConsole_->tick((float)evt.timeSinceLastFrame);
     
    497508      ogreRoot._fireFrameStarted(evt);
    498509
    499       ogreRoot._updateAllRenderTargets(); // only render in non-server mode
    500 
    501510      // get current time
    502511      now = timer_->getMilliseconds();
     512      calculateEventTime(now, eventTimes[2]);
     513
     514      ogreRoot._updateAllRenderTargets(); // only render in non-server mode
     515
     516      // get current time
     517      now = timer_->getMilliseconds();
    503518
    504519      // create an event to pass to the frameEnded method in ogre
    505520      evt.timeSinceLastEvent = calculateEventTime(now, eventTimes[0]);
    506       evt.timeSinceLastFrame = calculateEventTime(now, eventTimes[2]);
     521      renderTime += calculateEventTime(now, eventTimes[2]);
    507522
    508523      // again, just to be sure ogre works fine
Note: See TracChangeset for help on using the changeset viewer.