Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vsync fix pr2 #6

Merged
merged 4 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2648,6 +2648,12 @@ 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
Expand Down
8 changes: 6 additions & 2 deletions src/sdltiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool>( "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;
Expand Down
Loading