home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-06-08 | 1.9 KB | 64 lines | [TEXT/CWIE] |
- ///--------------------------------------------------------------------------------------
- // SWFPSReport.c
- //
- // Requires ALRT and DITL resource ID 200 to be copied from SpriteTest and put in
- // your project. Remember to include the SWFPSReport.h file as well. It will
- // call SysBeep if for some reason it can't display the alert.
- //
- // Make sure to set the Sprite's move time and the MaxFPS rate to 0; otherwise
- // the fps report will be innaccurate. (It still isn't terribly accurate, but should
- // give you a pretty good idea of how fast the animation is going.)
- ///--------------------------------------------------------------------------------------
-
-
- #include "SWFPSReport.h"
-
- #define kNoteAlertID 200
-
-
- long gOldTicks;
-
-
- ///--------------------------------------------------------------------------------------
- // Call StartTimer right before you start the animation
- ///--------------------------------------------------------------------------------------
-
- void StartTimer( void )
- {
- // Wait for ticks to roll over before starting
- gOldTicks = TickCount();
- while (gOldTicks == TickCount())
- NULL;
-
- gOldTicks = TickCount();
- }
-
-
- ///--------------------------------------------------------------------------------------
- // Call ShowResults as soon as your animation is done and pass to it the number of
- // frames that have occured in the animation.
- ///--------------------------------------------------------------------------------------
-
- void ShowResults( long frames )
- {
- Str255 framesString, secondsString, fpsString;
- long fps;
- double seconds;
-
- seconds = ((TickCount() - gOldTicks - 1) / 60.5);
- fps = (double)frames / seconds;
-
- NumToString(frames, framesString);
- NumToString(seconds, secondsString);
- NumToString(fps, fpsString);
-
- ParamText(framesString, secondsString, fpsString, "\p");
-
- SetCursor(&qd.arrow);
- ShowCursor();
-
- if (NoteAlert(kNoteAlertID, NULL) == -1)
- SysBeep(10);
- }
-
-