From c2148f22128cf936d5c1dc54a4d31b3622b17876 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Mon, 18 Feb 2019 21:27:01 +0100 Subject: [PATCH] Add scaling factor option --- src/options.cpp | 6 ++++++ src/sdltiles.cpp | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/src/options.cpp b/src/options.cpp index 8f6709955965c..801718955ba81 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -1594,6 +1594,12 @@ void options_manager::add_options_graphics() { "linear", translate_marker( "Linear filtering" ) } }, "none", COPT_CURSES_HIDE ); + + add( "SCALING_FACTOR", "graphics", translate_marker( "Scaling factor" ), + translate_marker( "Factor by which to scale the display" ), + 1.0, 20.0, 1.0, 1.0, COPT_CURSES_HIDE + ); + } void options_manager::add_options_debug() diff --git a/src/sdltiles.cpp b/src/sdltiles.cpp index dbcfed027fcfc..8311def63f21a 100644 --- a/src/sdltiles.cpp +++ b/src/sdltiles.cpp @@ -198,6 +198,7 @@ int fontheight; //the height of the font, background is always this size static int TERMINAL_WIDTH; static int TERMINAL_HEIGHT; bool fullscreen; +float scaling_factor; static SDL_Joystick *joystick; // Only one joystick for now. @@ -338,6 +339,8 @@ void WinCreate() SDL_SetHint( SDL_HINT_RENDER_SCALE_QUALITY, get_option( "SCALING_MODE" ).c_str() ); } + scaling_factor = get_option( "SCALING_FACTOR" ); + #ifndef __ANDROID__ if (get_option( "FULLSCREEN" ) == "fullscreen") { window_flags |= SDL_WINDOW_FULLSCREEN; @@ -754,6 +757,7 @@ void refresh_display() // Select default target (the window), copy rendered buffer // there, present it, select the buffer as target again. SetRenderTarget( renderer, NULL ); + SDL_RenderSetLogicalSize( renderer.get(), TERMINAL_WIDTH * fontwidth / scaling_factor, TERMINAL_HEIGHT * fontheight / scaling_factor ); #ifdef __ANDROID__ SDL_Rect dstrect = get_android_render_rect( TERMINAL_WIDTH * fontwidth, TERMINAL_HEIGHT * fontheight ); SetRenderDrawColor( renderer, 0, 0, 0, 255 );