PistonDevelopers / hematite

A simple Minecraft written in Rust with the Piston game engine
http://hematite.piston.rs/
MIT License
1.86k stars 105 forks source link

Default FPS Limit #178

Open toqueteos opened 9 years ago

toqueteos commented 9 years ago

hematite runs, right now, with uncapped FPS which causes it to hog both CPU and GPU.

A default FPS limit would be great for ours fans / hardware, 60 or 120 FPS are pretty good values and anything else above this value is just wasting energy and/or useless work.

I was able to limit FPS with external software which lowered CPU usage from 25% (1 core) to merely 1~3%.

eddyb commented 9 years ago

It used to be capped to 60FPS but I wanted to see what it can do. We should use this occasion to get some proper command-line options via something like docopt.rs.

toqueteos commented 9 years ago

Maybe an ini file is better suited for this, so when we have a GUI later (conrod I supose) we have just to parse that and write to file when done.

eddyb commented 9 years ago

If you want config it should be JSON or Toml.

toqueteos commented 9 years ago

@eddyb Do we really need that much features for something as simple as...

fullscreen:false
maxFps:60

?

EDIT: Example is a fragment of what's contained on Minecraft's options.txt.

fenhl commented 9 years ago

It might not be as simple with future feature additions. +1 for JSON.

toqueteos commented 9 years ago

It seems we are aiming for Vanilla compability, supporting same config format would be a good thing. I always have thought of hematite like a replacement of the MC jar.

Also, no matter what you add to settings, a key:value store should do the work. If you require JSON for game settings then something isn't right.

The Borderlands saga allows a lot of customization with config files and it uses key:value. And a ton more games.

I'm not against JSON but it seems an overkill for this. Some structures are not directly parseable JSON->Rust.

Example:

{
    "key": [
        "something", {
            "meh": true
        }
    ]
}

This is already a pain and it's on the Chat datatype used by vanilla MC. It requires parsing field by field explicitly. Not funny.

bvssvni commented 9 years ago

What about Toml? It looks pretty while still being flexible.

indiv0 commented 9 years ago

I think Toml would be a good choice, but @toqueteos brought up a good point:

How could we be a perfect replacement for the MC jar if we already can't parse some of the config to rust data structures?

bvssvni commented 9 years ago

Then I agree with @toqueteos . Let's go for a perfect replacement!

toqueteos commented 9 years ago

That's what I thought guys, maybe you had another goals for the project. I'm the newest addition right? You can blame me for free.

lily-mara commented 9 years ago

I actually came here to suggest the same thing, I tried running hematite, and it consumed all of my cpu power and hung up my display. Before it crashed my system, the window title said that I was getting over 1200 FPS.

toqueteos commented 9 years ago

@natemara As a temporal fix you can:

  1. Change this line of code https://github.com/PistonDevelopers/hematite/blob/master/src/main.rs#L188 to a more reasonable value.
  2. Or use external software to limit FPS.