Page 1 of 1

Trying to get the FPS limit

Posted: August 24th, 2019, 4:02 am
by MihaiGamerXD
Hi PSXDev!
I'm trying to get the FPS limit, and I can't find out in "LIBREF46.PDF".
Just use something like this: "FntPrint("%s",getFPS())".
Is it possible?

Re: Trying to get the FPS limit

Posted: August 24th, 2019, 8:20 am
by MihaiGamerXD
Found out for myself how to get.

Code: Select all

"FntPrint(~c666%d",VSync(0));
And it gives me 14 FPS?! :shock: How can I set it back to 60 FPS?

Re: Trying to get the FPS limit

Posted: August 24th, 2019, 12:33 pm
by LameGuy64
You need to install a VSync callback which will run a counter, and update a variable that will be your FPS from a variable that is updated constantly on every screen update.

Code: Select all

volatile int fps;
volatile int fps_counter;
volatile int fps_measure;

void vsync_cb(void) {

    fps_counter++;
    if( fps_counter > 60 ) {
        fps = fps_measure;
        fps_measure = 0;
        fps_counter = 0;
    }

}

int main() {

    ...
    
    VSyncCallback(vsync_cb);

    while(1) {

        ...

        < your display update code >

        fps_measure++;

        ...

    }
    ...
}

fps will contain the frames per second your application is running at, updated every second.

Re: Trying to get the FPS limit

Posted: August 24th, 2019, 10:56 pm
by MihaiGamerXD
LameGuy64 wrote: August 24th, 2019, 12:33 pm You need to install a VSync callback which will run a counter, and update a variable that will be your FPS from a variable that is updated constantly on every screen update.

Code: Select all

volatile int fps;
volatile int fps_counter;
volatile int fps_measure;

void vsync_cb(void) {

    fps_counter++;
    if( fps_counter > 60 ) {
        fps = fps_measure;
        fps_measure = 0;
        fps_counter = 0;
    }

}

int main() {

    ...
    
    VSyncCallback(vsync_cb);

    while(1) {

        ...

        < your display update code >

        fps_measure++;

        ...

    }
    ...
}

fps will contain the frames per second your application is running at, updated every second.
Thanks Lameguy64! It worked, but It works at max 61 FPS, So you'll have to do is to change:

Code: Select all

if( fps_counter > 60 ) {
to:

Code: Select all

if( fps_counter >= 60 ) {
So It will work exactly to 60 FPS. Anyway, thanks.