Archived

This topic is now archived and is closed to further replies.

FPS Question...

This topic is 5146 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

yeah, generally you average over 0.5seconds or over 1 second. i prefer the former. if you're just spitting up FPS every frame you can get widely varied values that as you've discovered make it impossible to read.

my FPS code is as follows:


//dT is passed in seconds

void E_Engine::updateFPS(float dT) {
static int FPhalfS = 0;
static float timeCount = 0.0f;

++FPhalfS;

if ((timeCount += dT) > 0.500) {
FPS = FPhalfS / timeCount;
FPhalfS = 0;
timeCount = 0.0f;
}
}


-me

[edited by - Palidine on November 12, 2003 4:38:05 PM]

Share this post


Link to post
Share on other sites
this is what i have so far...(i am using WinXP)

int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing
{
static int lasttime;
int dt;
dt=glutGet(GLUT_ELAPSED_TIME)-lasttime;
lasttime=glutGet(GLUT_ELAPSED_TIME);

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

printSetup2D(frames(dt)); //prints 2D Font
glutGet(GLUT_ELAPSED_TIME);

// Reset The Current Modelview Matrix
glTranslatef(0.0, 0.0, -5.0);
glRotatef(-90, 0, 0, 1);
glRotatef(rot, 1, 0, 0);

glColor3f(0,0,1);

drawData();
etc etc

}

float frames(int LastFrameTime)
{
static int LastTimes[10]={0,0,0,0,0,0,0,0,0,0};
static int c=0;
int i;
float average=0;
c=(c+1)%10;
LastTimes[c]=LastFrameTime;

for(i=0;i<10;i++)
average+=LastTimes;
return 1000.0/(average/10.0);
}


i am getting the average here but it is still too fast. as far as i can tell i am getting 760 FPS, or something like that...

[edited by - opengl_guru on November 12, 2003 5:03:10 PM]

Share this post


Link to post
Share on other sites
I use an other fps counter:


long sec1 = timeGetTime();
long sec2;
int fpsnow = 0;
int fps = 0;


as global variable

and


sec2=timeGetTime();
fps++;
if(sec2-sec1>1000){
fpsnow=fps;
sec1=sec2;
fps=0;
}


every frame

it refresses the fpsnow each second

to use timeGetTime() include stdio.h and lib winmm.lib

Share this post


Link to post
Share on other sites
hey thanks a lot! that works better actually that what i have. im trying to slide this into my function called inside a header file but it keeps giving me a FPS amount of 0, despite the global variables being in the main.cpp. hmmmm. anyway thanks so much!

Share this post


Link to post
Share on other sites