From b278b3881edd2c3fe259413f776f89466844eb81 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Tue, 23 Mar 2021 00:01:09 -0500 Subject: [PATCH] [nostalgia/core/sdl] Put vsync options in config.hpp --- src/nostalgia/core/config.hpp | 7 +++++++ src/nostalgia/core/sdl/core.cpp | 5 +++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/nostalgia/core/config.hpp b/src/nostalgia/core/config.hpp index 6beba067..ab1cd1be 100644 --- a/src/nostalgia/core/config.hpp +++ b/src/nostalgia/core/config.hpp @@ -14,9 +14,16 @@ namespace nostalgia::core { namespace config { +enum class SdlVsync { + Adaptive = -1, + Off = 0, + On = 1, +}; + constexpr auto GbaSpriteBufferLen = 128; constexpr auto GbaEventLoopTimerBased = false; constexpr auto UserlandFpsPrint = false; +constexpr auto SdlVsyncOption = static_cast(SdlVsync::Adaptive); } diff --git a/src/nostalgia/core/sdl/core.cpp b/src/nostalgia/core/sdl/core.cpp index 683c6c13..7a0348dc 100644 --- a/src/nostalgia/core/sdl/core.cpp +++ b/src/nostalgia/core/sdl/core.cpp @@ -8,9 +8,10 @@ #include +#include +#include #include #include -#include #include "core.hpp" @@ -29,7 +30,7 @@ ox::Error init(Context *ctx) { ox::Error run(Context *ctx) { const auto id = ctx->windowerData(); // try adaptive vsync - if (SDL_GL_SetSwapInterval(-1) < 0) { + if (SDL_GL_SetSwapInterval(config::SdlVsyncOption) < 0) { oxTrace("nostalgia::core::sdl", "Could not enable adaptive vsync, falling back on vsync"); SDL_GL_SetSwapInterval(1); // fallback on normal vsync }