ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libgender/util.C
(Generate patch)

Comparing libgender/util.C (file contents):
Revision 1.22 by root, Sat Oct 9 16:36:31 2004 UTC vs.
Revision 1.23 by root, Sat Oct 9 21:25:18 2004 UTC

190 190
191struct timer timer; 191struct timer timer;
192static double base; 192static double base;
193double timer::now = 0.; 193double timer::now = 0.;
194double timer::diff; 194double timer::diff;
195double min_frame = 1. / 60.;
195 196
196void timer::frame () 197void timer::frame ()
197{ 198{
198 struct timeval tv; 199 struct timeval tv;
200 double next;
201
202 for (;;)
203 {
199 gettimeofday (&tv, 0); 204 gettimeofday (&tv, 0);
200 205
201 double next = tv.tv_sec - base + tv.tv_usec / 1.e6; 206 next = tv.tv_sec - base + tv.tv_usec / 1.e6;
202
203 diff = next - now; 207 diff = next - now;
208
209 if (diff >= min_frame)
210 break;
211
212 SDL_Delay ((unsigned int)((min_frame - diff) * 1000.));
213 }
214
204 now = next; 215 now = next;
205} 216}
206 217
207timer::timer () 218timer::timer ()
208{ 219{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines