Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Framerate capping

Name: Anonymous 2010-02-08 16:35

This is my broken attempt at a FPS limitor
but it keeps going back and forth, it does slow it down but after another 5000 it goes back to uncapped and then again capped after another 5000 again and again

unsigned int maxfps = 60, framesrendered = 0;
unsigned int lasttime = 0, thistime = 0;
unsigned int fpsdelay = 0, updatelapse = 5000;
float msperframe = 0;

void fpscap(void) { //    FIX ME!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    if (thistime - lasttime > updatelapse) {
        fpsdelay = 0;
        msperframe = 1000 / (framesrendered / (updatelapse / 1000));
        fprintf(stdout, "%f ms\n", msperframe);
        fprintf(stdout, "%i FPS\n", framesrendered / (updatelapse / 1000));
        fflush(stdout);
        fpsdelay = (1000 / maxfps) - msperframe;
        framesrendered = 0;
        lasttime = thistime;
        msperframe = 0;
    } else {
        thistime = SDL_GetTicks();
        framesrendered++;
        SDL_Delay(fpsdelay);
    }
}

Name: Anonymous 2010-02-08 16:39

60 fps are not enough unless you have some kind of physical disability.

Name: Anonymous 2010-02-08 16:45

>>2
wat

Name: Anonymous 2010-02-08 16:56

1000 / (framesrendered / (updatelapse / 1000))
Wut.

Do it like this:
http://dev.koonsolo.com/7/dewitters-gameloop/

Name: Anonymous 2010-02-08 17:22

thanks anon its closer to what i want

Name: Anonymous 2010-02-08 18:01

>>2
My monitor doesn't even go above 60 fps.

Name: Anonymous 2010-02-08 18:30

MY ANUS doesn't even go about 60 fps1

1. Farts per second

Name: Anonymous 2010-02-08 18:49

>>4
This guy's pretty much right, except I don't really agree with the prediction/interpolation and running the game at 25 FPS. That's crazy. He argues that movies run at 24 FPS; but games revolve around precision timing. You need a very high internal update rate. For instance most fighting games, e.g. Street Fighter, run internally at a fixed 60 FPS.

Most FPS games also don't work this way AFAIK. What they do is separate out input, so that it happens at the same rate as display_game(). This way having a framerate of 120 FPS versus 60 FPS makes a big difference; you don't see it of course, but you feel it in the controls. Fighting games don't do this however because event timing needs to be extremely consistent.

In his defense he says he works on mobile games. I've also worked on mobile games, and yeah it's pretty much like he said without the interpolation; just fixed-tickrate frameskip at 20 FPS.

Name: Anonymous 2010-02-08 19:05

>>4
Koen Witters
Did Xarn give up his last name to his husband when he got married?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List