[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r3800 - trunk/pingus/src/screen
From: |
plouj at BerliOS |
Subject: |
[Pingus-CVS] r3800 - trunk/pingus/src/screen |
Date: |
Sat, 12 Jul 2008 19:31:49 +0200 |
Author: plouj
Date: 2008-07-12 19:31:49 +0200 (Sat, 12 Jul 2008)
New Revision: 3800
Modified:
trunk/pingus/src/screen/screen_manager.cpp
Log:
make sure to calculate the idle delay based on the current frame time and
nothing else
this fixes a problem introduced in revision 3748
Modified: trunk/pingus/src/screen/screen_manager.cpp
===================================================================
--- trunk/pingus/src/screen/screen_manager.cpp 2008-07-12 17:31:33 UTC (rev
3799)
+++ trunk/pingus/src/screen/screen_manager.cpp 2008-07-12 17:31:49 UTC (rev
3800)
@@ -223,10 +223,13 @@
update(previous_frame_time, events);
// cap the framerate at the desired value
- if (previous_frame_time < 1.0f / desired_fps) {
- Uint32 sleep_time = static_cast<Uint32>(1000 *((1.0f /
desired_fps) - previous_frame_time));
+ // figure out how long this frame took
+ float current_frame_time = float(SDL_GetTicks() - last_ticks) /
1000.0f;
+ // idly delay if this frame didn't last long enough to
+ // achieve <desired_fps> frames per second
+ if (current_frame_time < 1.0f / desired_fps) {
+ Uint32 sleep_time = static_cast<Uint32>(1000 *((1.0f /
desired_fps) - current_frame_time));
// std::cout << "Sleep: " << sleep_time << std::endl;
- // idle delay to make the frame take as long as we want it to
SDL_Delay(sleep_time);
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r3800 - trunk/pingus/src/screen,
plouj at BerliOS <=