Skip to content

Commit

Permalink
Add scaling factor option
Browse files Browse the repository at this point in the history
  • Loading branch information
ifreund committed Feb 18, 2019
1 parent 9900d9c commit c2148f2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 4 additions & 0 deletions src/sdltiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -338,6 +339,8 @@ void WinCreate()
SDL_SetHint( SDL_HINT_RENDER_SCALE_QUALITY, get_option<std::string>( "SCALING_MODE" ).c_str() );
}

scaling_factor = get_option<float>( "SCALING_FACTOR" );

#ifndef __ANDROID__
if (get_option<std::string>( "FULLSCREEN" ) == "fullscreen") {
window_flags |= SDL_WINDOW_FULLSCREEN;
Expand Down Expand Up @@ -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 );
Expand Down

0 comments on commit c2148f2

Please sign in to comment.