Hello
i'm build a simple emulator, it works, but very slow. I use C# with SDL. net.
i know that the emulator must run to 60 fps, but i like wirte a function that calculate the fps. Any Help in C/C++ that guide to me?
thanks,
bye
Function for calculate FPS
Moderator: ZSNES Mods
-
- ZSNES Developer
- Posts: 3904
- Joined: Tue Jul 27, 2004 10:54 pm
- Location: Solar powered park bench
- Contact:
Take the system time each time you render a frame, see much how much you're averaging rendering per second.
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
_____________
Insane Coding
The following is used in Regen/GTK+:
Just make a counter to count the number of frames rendered so far and pass it to this function.
You will need to convert it to C# yourself.
Code: Select all
int do_fps = 0;
static void display_fps(int frames_rendered)
{
static time_t fpstimer;
static unsigned int previous_frames;
static time_t temptime;
static double fps;
static char fpsstring[8];
static struct tms tm;
if(do_fps < frames_rendered)
{
temptime = times(&tm);
fps = (double)(frames_rendered - previous_frames) * 100 / (temptime - fpstimer);
snprintf(fpsstring, 7, "%2.2lf", fps);
fpstimer = temptime;
previous_frames = frames_rendered;
do_fps = frames_rendered + 30;
}
// Display fpsstring here
}
You will need to convert it to C# yourself.