Mail Archives: djgpp/1997/04/23/23:09:01
In article <335DADA6 DOT 41A0 AT canvaslink DOT com>, Tom Grandgent
<tgrand AT canvaslink DOT com> writes
>I need some way to accurately measure the number of frames per second
>(or milliseconds per frame or something?) more often than once per
>second. If anyone knows how I might be able to do this, I would be
>very appreciative.
>
>BTW, the formula I am using to calculate the corrected player speed is:
>effective_speed = logical_speed * (1 / fps / TARGET_FPS);
This is a pseudo c source showing how I measure the time for each frame.
#include <time.h>
main(){
char txt[50];
int frame_time;
Your other stuff here before the main loop.
for (d=0 ; d<1000 ; d++){
frame_time = uclock();
/*
Some out of this world functions moving your sprites and drawing your
Quake beating 3D world go here.
*/
sprintf(txt ,"Time = %d" ,uclock()-frame_time);
textout(buffer ,font ,txt ,0,0,1); /* Or some other method of
printing "txt" to the screen */
}
}
I think the uclock() is accurate to 10,000 ticks per second.
--
http://www.jenkinsdavid.demon.co.uk for Newbie C programmers and a larf. ;-)
David Jenkins
- Raw text -