G
Gareth
I am trying to use DateTime.Now to apply a frame limit to my 3d
application. Below is the code involved. In this example I have hard
coded it for 60 frames per second (1000 milliseconds / 60 fps).
public void Execute()
{
while(!_close)
{
DateTime n=DateTime.Now;
TimeSpan t=n.Subtract(_lastRender);
if(t.TotalMilliseconds>=1000.0d/60.0d)
{
_lastRender=n;
_render();
}
}
}
The problem is I always get 33 frames per second. If I remove the
frame limiter I get 2000+ frames per second. If I log the value of
t.TotalMilliseconds to a text file every iteration I get the
following:
Notice that TotalMilliseconds doesn't change at all for several
iterations, then suddenly doubles...
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 31.2558
20/09/2007 09:50:11: 0
20/09/2007 09:50:11: 0
20/09/2007 09:50:11: 0
20/09/2007 09:50:11: 0
application. Below is the code involved. In this example I have hard
coded it for 60 frames per second (1000 milliseconds / 60 fps).
public void Execute()
{
while(!_close)
{
DateTime n=DateTime.Now;
TimeSpan t=n.Subtract(_lastRender);
if(t.TotalMilliseconds>=1000.0d/60.0d)
{
_lastRender=n;
_render();
}
}
}
The problem is I always get 33 frames per second. If I remove the
frame limiter I get 2000+ frames per second. If I log the value of
t.TotalMilliseconds to a text file every iteration I get the
following:
Notice that TotalMilliseconds doesn't change at all for several
iterations, then suddenly doubles...
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 15.6279
20/09/2007 09:50:11: 31.2558
20/09/2007 09:50:11: 0
20/09/2007 09:50:11: 0
20/09/2007 09:50:11: 0
20/09/2007 09:50:11: 0