diff --git a/src/options.cpp b/src/options.cpp index ffe1c0c269bc7..5c5930a118f95 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -2648,6 +2648,13 @@ void options_manager::add_options_graphics() false, COPT_CURSES_HIDE ); + #if defined(SDL_HINT_RENDER_VSYNC) + add( "VSYNC", graphics, translate_marker( "Use VSync" ), + translate_marker( "Enable vertical synchronization to prevent screen tearing. VSync can slow the game down a lot. Requires restart." ), + false, COPT_CURSES_HIDE + ); +#endif + #if defined(__ANDROID__) get_option( "FRAMEBUFFER_ACCEL" ).setPrerequisite( "SOFTWARE_RENDERING" ); #else diff --git a/src/sdltiles.cpp b/src/sdltiles.cpp index d99ad5eb431fd..d2f072b524bc3 100644 --- a/src/sdltiles.cpp +++ b/src/sdltiles.cpp @@ -360,8 +360,12 @@ static void WinCreate() if( !software_renderer ) { dbg( D_INFO ) << "Attempting to initialize accelerated SDL renderer."; - renderer.reset( SDL_CreateRenderer( ::window.get(), renderer_id, SDL_RENDERER_ACCELERATED | - SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE ) ); + int init_flags = SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE; + if( get_option( "VSYNC" ) ) { + init_flags |= SDL_RENDERER_PRESENTVSYNC; + } + + renderer.reset( SDL_CreateRenderer( ::window.get(), renderer_id, init_flags ) ); if( printErrorIf( !renderer, "Failed to initialize accelerated renderer, falling back to software rendering" ) ) { software_renderer = true;