extracting frame rate

Hello guys,
I havent experimented anytime before on extracting the frame rate while working in OpenGL. I have a little idea of how to get frame rate in windows environment using Microsoft Visual C++, but no idea of how to get it in unix/Linux/Irix environment. Can anyone give me a snippet of code and the header files I need to include to get the frame rate. Any help is deeply appreciated. I use C programming language

Thanks,
Vijay.

Here is code I’m using in my projects:

#include <sys/time.h>

#define FPS_SAMPLE_TIME 0.1 // sampling time in seconds

int frames_count = 0; // frame counter
float fps = 0; // current FPS

#define timediff(t1, t0) (double) ((t1)->tv_sec - (t0)->tv_sec) + ((t1)->tv_usec - (t0)->tv_usec) / (float)1000000
void myFPS(void)
{
static struct timeval last;
static struct timeval now;
float delta;

frames_count++;
gettimeofday(&now, NULL);
delta = timediff(&now, &last);
if (delta > FPS_SAMPLE_TIME) {
last = now;
fps = frames_count / delta;
frames_count = 0;
}
}

somewhere in render function place myFPS()
use fps variable to display actual FPS
if you have “main timer” for synchronization etc., you can use this timer insteed of calling gettimeofday

[This message has been edited by reggae (edited 03-25-2003).]

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.