I’ve made a simple frame counter but it’s only showing 1FPS and i’m absolutely sure I’va got more than that:-)
Code:
…
drawing
…
framecount++;
time+=glutGet(GLUT_ELAPSED_TIME);glutSwapBuffers();
if(time>=1000)
{
itoa(framecount,number,10);
strcpy(fps,number);
strcat(fps," FPS");
glutSetWindowTitle(fps);
framecount=0;
time=0;
}
Hi !
Hmmm, as you set framecount=0 at the end of the drawing code (if elapsed time >= 1000 ? is this ms or what ?)
Mikael
[This message has been edited by mikael_aronsson (edited 06-04-2003).]
[This message has been edited by mikael_aronsson (edited 06-04-2003).]
GLUT ELAPSED TIME Number of milliseconds since glutInit called (or first call to
glutGet(GLUT ELAPSED TIME)).
Time is soon always over 1000.
So you get 1 fps all the time.
Hope it helps.
Claude
but i do swap buffer more than once per second(1000 miliseconds)and when i do first glutGet(GLUT_ELAPSED_TIME)and next
glutGet(GLUT_ELAPSED_TIME) should give the difference between these two calls? how should it be done correctly ?
It says:
since FIRST call to glutGet.
So at the 1000th call,you get:
time of the 1000th call - time of first call .
This is basically the time since you started
your program.
Do you see why it doesn’t work?
Go to http://www.gametutorials.com/
they have a fps tutorial.
Bye
Claude