www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/04/23/23:09:01

From: David Jenkins <me AT jenkinsdavid DOT demon DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Measuring frame rate more often
Date: Wed, 23 Apr 1997 14:53:36 +0100
Organization: None
Distribution: world
Message-ID: <uJW0LNAgRhXzEw5N@jenkinsdavid.demon.co.uk>
References: <335DADA6 DOT 41A0 AT canvaslink DOT com>
NNTP-Posting-Host: jenkinsdavid.demon.co.uk
MIME-Version: 1.0
Lines: 48
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019