Added V-Sync Cvar toggle

This commit is contained in:
Collin Smith 2019-03-01 23:03:59 -08:00
parent 70c5a5ecb5
commit 1bbfd0b02e
2 changed files with 15 additions and 0 deletions

View File

@ -503,6 +503,13 @@ public class Client extends Game {
}
});
Cvars.Client.Display.VSync.addStateListener(new CvarStateAdapter<Boolean>() {
@Override
public void onChanged(Cvar<Boolean> cvar, Boolean from, Boolean to) {
Gdx.graphics.setVSync(to);
}
});
Cvars.Client.Realm.addStateListener(new CvarStateAdapter<String>() {
@Override
public void onChanged(Cvar<String> cvar, String from, String to) {

View File

@ -167,6 +167,14 @@ public class Cvars {
.defaultValue(1.0f)
.validator(NumberRangeValidator.of(Float.class, 0.5f, 4.0f))
.build();
Cvar<Boolean> VSync = Cvar.builder(Boolean.class)
.alias("Client.Display.VSync")
.description(
"Whether or not wait for vertical refresh is enabled.")
.defaultValue(Boolean.FALSE)
.validator(Validator.ACCEPT_NON_NULL)
.build();
}
interface Input {