Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » FPS locking is easy - not taking 100% CPU is hard

This thread is locked; no one can reply to it. rss feed Print
 1   2 
FPS locking is easy - not taking 100% CPU is hard
Thomas Fjellstrom
Member #476
June 2000
avatar

Also, sleep != Sleep. One is a libc function, the other is a win32 function.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Evert
Member #794
November 2000
avatar

Quote:

Well then why when I ctrl alt delete does my game crash when I call rest, but when I call sleep it works flawlessly?

You screwed up somewhere? Just look at the source I posted above; if you don't have a callback, rest() calls Sleep() directly.

Matthew Dalrymple
Member #7,922
October 2006
avatar

Doesn't crash after ctrl alt delete

     while(!key[KEY_ESC])
     {
          FpsCounter::NewFrameStarted();
          deltaTime = FpsCounter::GetDeltaTime();

          firstmap.Draw(0, 0, 1);

          Canvas::Refresh();
          
          Sleep(1);
     }

Crashes after ctrl alt delete

     while(!key[KEY_ESC])
     {
          FpsCounter::NewFrameStarted();
          deltaTime = FpsCounter::GetDeltaTime();

          firstmap.Draw(0, 0, 1);

          Canvas::Refresh();
          
          rest(1);
     }

edit:
nm
rest(0); crashes.

=-----===-----===-----=
I like signatures that only the signer would understand. Inside jokes are always the best, because they exclude everyone else.

Matthew Leverton
Supreme Loser
January 1999
avatar

You'll need to post your entire project to determine what's wrong. rest(1) under windows ends up calling Sleep(1) after two or three regular function calls.

Matthew Dalrymple
Member #7,922
October 2006
avatar

http://www.allegro.cc/forums/thread/589424

It's attached to that thread.

=-----===-----===-----=
I like signatures that only the signer would understand. Inside jokes are always the best, because they exclude everyone else.

Andrei Ellman
Member #3,434
April 2003

Matthew Dalrymple said:

Well then why when I ctrl alt delete does my game crash when I call rest, but when I call sleep it works flawlessly?

What version of Allegro are you using? In the Windows version of 4.2.0, there's a bug that causes the program to crash when CTRL+ALT+DEL is pressed. This has been fixed in 4.2.1

AE.

--
Don't let the illegitimates turn you into carbon.

 1   2 


Go to: