Changeset 7995 for code/branches
- Timestamp:
- Feb 28, 2011, 3:47:08 AM (14 years ago)
- Location:
- code/branches/usability/src/libraries/core
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/usability/src/libraries/core/GraphicsManager.cc
r7993 r7995 106 106 , renderWindow_(0) 107 107 , viewport_(0) 108 , lastFrameStartTime_(0.0f) 109 , lastFrameEndTime_(0.0f) 108 110 { 109 111 RegisterObject(GraphicsManager); … … 364 366 @note 365 367 A note about the Ogre::FrameListener: Even though we don't use them, 366 they still get called. However, the delta times are not correct (except 367 for timeSinceLastFrame, which is the most important). A little research 368 as shown that there is probably only one FrameListener that doesn't even 369 need the time. So we shouldn't run into problems. 368 they still get called. 370 369 */ 371 370 void GraphicsManager::postUpdate(const Clock& time) 372 371 { 372 // Time before rendering 373 uint64_t timeBeforeTick = time.getRealMicroseconds(); 374 375 // Ogre's time keeping object 373 376 Ogre::FrameEvent evt; 374 evt.timeSinceLastFrame = time.getDeltaTime(); 375 evt.timeSinceLastEvent = time.getDeltaTime(); // note: same time, but shouldn't matter anyway 376 377 // don't forget to call _fireFrameStarted to OGRE to make sure 378 // everything goes smoothly 377 378 // Translate to Ogre float times before the update 379 float temp = lastFrameStartTime_; 380 lastFrameStartTime_ = (float)(timeBeforeTick / 1000000); 381 evt.timeSinceLastFrame = lastFrameStartTime_ - temp; 382 evt.timeSinceLastEvent = lastFrameStartTime_ - lastFrameEndTime_; 383 384 // Ogre requires the time too 379 385 ogreRoot_->_fireFrameStarted(evt); 380 386 … … 382 388 // This calls the WindowEventListener objects. 383 389 Ogre::WindowEventUtilities::messagePump(); 384 // make sure the window stays active even when not focused390 // Make sure the window stays active even when not focused 385 391 // (probably only necessary on windows) 386 392 this->renderWindow_->setActive(true); 387 388 // Time before rendering389 uint64_t timeBeforeTick = time.getRealMicroseconds();390 393 391 394 // Render frame … … 396 399 Game::getInstance().subtractTickTime((int32_t)(timeAfterTick - timeBeforeTick)); 397 400 398 // again, just to be sure OGRE works fine 399 ogreRoot_->_fireFrameEnded(evt); // note: uses the same time as _fireFrameStarted 401 // Translate to Ogre float times after the update 402 temp = lastFrameEndTime_; 403 lastFrameEndTime_ = (float)(timeAfterTick / 1000000); 404 evt.timeSinceLastFrame = lastFrameEndTime_ - temp; 405 evt.timeSinceLastEvent = lastFrameEndTime_ - lastFrameStartTime_; 406 407 // Ogre also needs the time after the frame finished 408 ogreRoot_->_fireFrameEnded(evt); 400 409 } 401 410 -
code/branches/usability/src/libraries/core/GraphicsManager.h
r7993 r7995 109 109 Ogre::RenderWindow* renderWindow_; //!< the one and only render window 110 110 Ogre::Viewport* viewport_; //!< default full size viewport 111 float lastFrameStartTime_; //!< Time stamp of the beginning of the last frame 112 float lastFrameEndTime_; //!< Time stamp of the end of the last frame 111 113 112 114 // XML files for the resources and the debug overlay
Note: See TracChangeset
for help on using the changeset viewer.