Merge pull request #1010 from devnexen/vsync_submenu

Add v-sync option to the graphics settings tab
This commit is contained in:
yvt 2022-06-19 21:59:36 +09:00 committed by GitHub
commit 7bcfa32b29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 1 deletions

View File

@ -131,6 +131,12 @@ namespace spades {
_Tr("StartupScreen",
"Uses a number representation which allows wider dynamic range during rendering process. " "Additionally, this allows color calculation whose value is in linear correspondence with actual energy, " "that is, physically accurate blending can be achieved.")));
cfg.AddRow(StartupScreenConfigCheckItemEditor(
ui, StartupScreenConfig(ui, "r_vsync"), "0", "1",
_Tr("StartupScreen", "V-Sync"),
_Tr("StartupScreen",
"Enables frame rate synchronization.")));
{
StartupScreenComplexConfig cplx;
cplx.AddEditor(StartupScreenConfigCheckItemEditor(

View File

@ -382,6 +382,14 @@ namespace spades {
void Settings::ItemHandle::operator=(const std::string &value) { item->Set(value); }
void Settings::ItemHandle::operator=(int value) { item->Set(value); }
void Settings::ItemHandle::operator=(float value) { item->Set(value); }
bool Settings::ItemHandle::operator==(int value) {
item->Load();
return item->intValue == value;
}
bool Settings::ItemHandle::operator!=(int value) {
item->Load();
return item->intValue != value;
}
Settings::ItemHandle::operator std::string() {
item->Load();
return item->string;

View File

@ -102,6 +102,8 @@ namespace spades {
void operator=(const std::string &);
void operator=(int);
void operator=(float);
bool operator==(int);
bool operator!=(int);
operator std::string();
operator float();
operator int();

View File

@ -521,7 +521,7 @@ namespace spades {
#ifndef __sun
if (rtype == RendererType::GL) {
if (SDL_GL_SetSwapInterval(r_vsync) != 0) {
if (r_vsync != 0 && SDL_GL_SetSwapInterval(r_vsync) != 0) {
SPRaise("SDL_GL_SetSwapInterval failed: %s", SDL_GetError());
}
}