Changeset 1674 for code/branches/gui/src/orxonox/gamestates/GSGraphics.cc
- Timestamp:
- Aug 28, 2008, 8:30:25 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/gui/src/orxonox/gamestates/GSGraphics.cc
r1673 r1674 32 32 #include <OgreFrameListener.h> 33 33 #include <OgreRoot.h> 34 #include <OgreTimer.h>35 34 #include <OgreWindowEventUtilities.h> 36 35 #include <OgreRenderWindow.h> … … 39 38 #include "core/ConfigValueIncludes.h" 40 39 #include "core/input/InputManager.h" 41 //#include "core/Core.h"42 40 #include "overlays/console/InGameConsole.h" 43 41 #include "gui/GUIManager.h" … … 48 46 GSGraphics::GSGraphics() 49 47 : GameState("graphics") 50 , debugRefreshTime_(0.0f) 48 , ogreRoot_(0) 49 , graphicsEngine_(0) 51 50 , inputManager_(0) 52 51 , console_(0) 53 52 , guiManager_(0) 54 53 , frameCount_(0) 54 , statisticsRefreshCycle_(0) 55 , statisticsStartTime_(0) 56 , statisticsStartCount_(0) 57 , tickTime_(0) 55 58 { 56 59 } … … 62 65 void GSGraphics::setConfigValues() 63 66 { 64 SetConfigValue( debugRefreshTime_, 0.2).description("Sets the timeinterval at which average fps, etc. get updated.");67 SetConfigValue(statisticsRefreshCycle_, 200000).description("Sets the time in microseconds interval at which average fps, etc. get updated."); 65 68 } 66 69 67 70 void GSGraphics::enter() 68 71 { 72 setConfigValues(); 73 69 74 this->ogreRoot_ = Ogre::Root::getSingletonPtr(); 70 75 this->graphicsEngine_ = GraphicsEngine::getInstancePtr(); … … 88 93 guiManager_ = new GUIManager(); 89 94 guiManager_->initialise(); 95 96 // reset frame counter 97 this->frameCount_ = 0; 98 this->tickTime_ = 0; 99 statisticsStartTime_ = 0; 100 statisticsStartCount_ = 0; 90 101 } 91 102 … … 117 128 need the time. So we shouldn't run into problems. 118 129 */ 119 void GSGraphics::ticked( float dt, uint64_ttime)130 void GSGraphics::ticked(const Clock& time) 120 131 { 132 uint64_t timeBeforeTick = time.getRealMicroseconds(); 133 float dt = time.getDeltaTime(); 134 121 135 this->inputManager_->tick(dt); 122 123 this->tickChild(dt, time);124 125 136 // tick console 126 137 this->console_->tick(dt); 138 this->tickChild(time); 139 140 uint64_t timeAfterTick = time.getRealMicroseconds(); 127 141 128 //// get current time once again 129 //timeAfterTick = timer_->getMicroseconds(); 142 tickTime_ += (unsigned int)(timeAfterTick - timeBeforeTick); 143 if (timeAfterTick > statisticsStartTime_ + statisticsRefreshCycle_) 144 { 145 GraphicsEngine::getInstance().setAverageTickTime( 146 (float)tickTime_ * 0.001f / (frameCount_ - statisticsStartCount_)); 147 float avgFPS = (float)(frameCount_ - statisticsStartCount_) 148 / (timeAfterTick - statisticsStartTime_) * 1000000.0; 149 GraphicsEngine::getInstance().setAverageFramesPerSecond(avgFPS); 130 150 131 //tickTime += timeAfterTick - timeBeforeTick; 132 //if (timeAfterTick > refreshStartTime + refreshTime) 133 //{ 134 // GraphicsEngine::getInstance().setAverageTickTime( 135 // (float)tickTime * 0.001 / (frameCount - oldFrameCount)); 136 // float avgFPS = (float)(frameCount - oldFrameCount) / (timeAfterTick - refreshStartTime) * 1000000.0; 137 // GraphicsEngine::getInstance().setAverageFramesPerSecond(avgFPS); 138 139 // oldFrameCount = frameCount; 140 // tickTime = 0; 141 // refreshStartTime = timeAfterTick; 142 //} 151 tickTime_ = 0; 152 statisticsStartCount_ = frameCount_; 153 statisticsStartTime_ = timeAfterTick; 154 } 143 155 144 156 // don't forget to call _fireFrameStarted in ogre to make sure … … 163 175 164 176 ++frameCount_; 165 166 //}167 //catch (std::exception& ex)168 //{169 // // something went wrong.170 // COUT(1) << ex.what() << std::endl;171 // COUT(1) << "Main loop was stopped by an unhandled exception. Shutting down." << std::endl;172 //}173 177 } 174 178 }
Note: See TracChangeset
for help on using the changeset viewer.