Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

round get_fps() #784

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

round get_fps() #784

wants to merge 1 commit into from

Conversation

brettchalupa
Copy link

Before the decimal was just being dropped, causing the values of get_fps() to always oscillate between 59 and 60, for example. This isn't very helpful when debugging, and it's due to the decimal being cut off even if it's, let's say, 59.9 due to floating point arithmetic.

Now the value is rounded, which is more helpful when monitoring for massive frame drops.

Alternatively, if desired, we could change this to be a float that includes some number of decimal places and can be rounded/cast as desired by the developer calling the function. We could also keep track of many frames of data and average it out. But at least this is a bit more usable for now.

Before

macroquad.fps.old.mov

notice it rapidly changing

after

macroquad.fps.new.mov

notice it'll occasionally drop a frame (unsure why)

Code

use macroquad::prelude::*;

#[macroquad::main("MyGame")]
async fn main() {
    loop {
        clear_background(DARKGRAY);
        draw_text(
            format!("FPS: {}", get_fps_new()).as_str(),
            20.0,
            40.0,
            30.0,
            WHITE,
        );

        next_frame().await
    }
}

Before the decimal was just being dropped, causing the values of get_fps() to always oscillate between 59 and 60, for example. This isn't very helpful when debugging, and it's due to the decimal being cut off even if it's, let's say, 59.9 due to floating point arithmetic.

Now the value is rounded, which is more helpful when monitoring for massive frame drops.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant