Jump to content
  • Advertisement


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


FPS Question...

This topic is 5451 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

i got my FPS displaying onto the screen.. but it keeps changing so fast i really cant tell what it says. is a usleep(someNumber) in order or what would you recommend? thanks!

Share this post

Link to post
Share on other sites
I''d just average the FPS over a certain period of time (e.g. count the number of frames in one second, every second) and output that.

- JQ

Share this post

Link to post
Share on other sites
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;


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


[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;

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

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

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


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;

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



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

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!