Changeset 7159 in orxonox.OLD for trunk/src/subprojects/framework.cc
- Timestamp:
- Feb 18, 2006, 1:50:59 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/subprojects/framework.cc
r7158 r7159 66 66 { 67 67 Framework* framework = Framework::getInstance(); 68 69 // initialize Timing 70 framework->cycle = 0; 71 for (unsigned int i = 0; i < TICK_SMOOTH_VALUE; i++) 72 framework->frameTimes[i] = 100; 73 framework->dtS = 0.0f; 74 framework->lastFrame = SDL_GetTicks (); 75 76 68 77 while(!framework->isFinished) 69 78 { … … 103 112 float Framework::tick() 104 113 { 105 currFrame = SDL_GetTicks(); 106 float dt = (float)(currFrame - lastFrame) / 1000.0; 107 lastFrame = currFrame; 108 this->camera->tick(dt); 109 110 this->moduleTick(dt); 111 112 return dt; 114 // CALCULATE FRAMERATE 115 Uint32 frameTimesIndex; 116 Uint32 getTicks; 117 Uint32 i; 118 119 frameTimesIndex = this->cycle % TICK_SMOOTH_VALUE; 120 getTicks = SDL_GetTicks(); 121 this->frameTimes[frameTimesIndex] = getTicks - this->lastFrame; 122 this->lastFrame = getTicks; 123 ++this->cycle; 124 this->dtS = 0; 125 for (i = 0; i < TICK_SMOOTH_VALUE; i++) 126 this->dtS += this->frameTimes[i]; 127 this->dtS = this->dtS / TICK_SMOOTH_VALUE / 1000.0f * speed; 128 129 this->camera->tick(dtS); 130 131 this->moduleTick(dtS); 132 133 return dtS; 113 134 } 114 135
Note: See TracChangeset
for help on using the changeset viewer.