[SettingsMenuState] It's now possible to disable VSync.

This commit is contained in:
Quentin Bazin 2020-02-24 23:16:51 +09:00
parent 7c9b72b137
commit 7e38907854
4 changed files with 8 additions and 2 deletions

View File

@ -40,6 +40,7 @@ namespace Config {
extern bool isAmbientOcclusionEnabled;
extern bool isWireframeModeEnabled;
extern bool isFullscreenModeEnabled;
extern bool isVerticalSyncEnabled;
extern float cameraFOV;
extern u16 screenWidth;
extern u16 screenHeight;

View File

@ -56,7 +56,7 @@ void ClientApplication::init() {
gk::GamePad::init(m_keyboardHandler);
createWindow(Config::screenWidth, Config::screenHeight, APP_NAME);
m_window.setVerticalSyncEnabled(true);
m_window.setVerticalSyncEnabled(Config::isVerticalSyncEnabled);
m_window.disableView();
initOpenGL();
@ -86,6 +86,9 @@ void ClientApplication::handleEvents() {
if (Config::screenWidth != m_window.getSize().x || Config::screenHeight != m_window.getSize().y) {
m_window.resize(Config::screenWidth, Config::screenHeight);
}
if (Config::isVerticalSyncEnabled != m_window.isVerticalSyncEnabled())
m_window.setVerticalSyncEnabled(Config::isVerticalSyncEnabled);
}
void ClientApplication::onEvent(const SDL_Event &event) {

View File

@ -36,6 +36,7 @@ bool Config::isSunSmoothLightingEnabled = true;
bool Config::isAmbientOcclusionEnabled = false;
bool Config::isWireframeModeEnabled = false;
bool Config::isFullscreenModeEnabled = false;
bool Config::isVerticalSyncEnabled = true;
float Config::cameraFOV = 70.0f;
u16 Config::screenWidth = 1600;
u16 Config::screenHeight = 1050;
@ -68,6 +69,7 @@ void Config::loadConfigFromFile(const char *file) {
isAmbientOcclusionEnabled = lua["isAmbientOcclusionEnabled"].get_or(isAmbientOcclusionEnabled);
isWireframeModeEnabled = lua["isWireframeModeEnabled"].get_or(isWireframeModeEnabled);
isFullscreenModeEnabled = lua["isFullscreenModeEnabled"].get_or(isFullscreenModeEnabled);
isVerticalSyncEnabled = lua["isVerticalSyncEnabled"].get_or(isVerticalSyncEnabled);
cameraFOV = lua["cameraFOV"].get_or(cameraFOV);
screenWidth = lua["screenWidth"].get_or(screenWidth);
screenHeight = lua["screenHeight"].get_or(screenHeight);

View File

@ -164,7 +164,7 @@ void SettingsMenuState::addGraphicsButtons() {
button.setText("Resolution: " + std::to_string(Config::screenWidth) + "x" + std::to_string(Config::screenHeight));
});
m_menuWidget.addButton("Use VSync: ON", [] (TextButton &) {}).setEnabled(false);
addToggleButton("Use VSync", Config::isVerticalSyncEnabled, false);
}
void SettingsMenuState::addInputButtons() {