[sdl2] add --scale=<float> option to scale up/down the size of SDL2's window
This commit is contained in:
parent
a5ff52d7c0
commit
a825ed2ba6
4 changed files with 19 additions and 1 deletions
2
dist/x48ng.man.1
vendored
2
dist/x48ng.man.1
vendored
|
@ -100,6 +100,8 @@ where options include (depending on compiled front-ends):
|
||||||
\-\-no\-chrome only display the LCD (default: false)
|
\-\-no\-chrome only display the LCD (default: false)
|
||||||
.br
|
.br
|
||||||
\-\-fullscreen make the UI fullscreen (default: false)
|
\-\-fullscreen make the UI fullscreen (default: false)
|
||||||
|
.br
|
||||||
|
\-\-scale=<float> scale the SDL2 UI by <float>
|
||||||
.br
|
.br
|
||||||
\-\-netbook make the UI horizontal (default: false)
|
\-\-netbook make the UI horizontal (default: false)
|
||||||
.br
|
.br
|
||||||
|
|
12
src/config.c
12
src/config.c
|
@ -43,6 +43,7 @@ config_t config = {
|
||||||
/* sdl */
|
/* sdl */
|
||||||
.hide_chrome = false,
|
.hide_chrome = false,
|
||||||
.show_ui_fullscreen = false,
|
.show_ui_fullscreen = false,
|
||||||
|
.scale = 1.0,
|
||||||
|
|
||||||
/* x11 */
|
/* x11 */
|
||||||
.netbook = false,
|
.netbook = false,
|
||||||
|
@ -245,6 +246,7 @@ int config_init( int argc, char* argv[] )
|
||||||
int clopt_throttle = -1;
|
int clopt_throttle = -1;
|
||||||
int clopt_hide_chrome = -1;
|
int clopt_hide_chrome = -1;
|
||||||
int clopt_show_ui_fullscreen = -1;
|
int clopt_show_ui_fullscreen = -1;
|
||||||
|
double clopt_scale = -1.0;
|
||||||
int clopt_netbook = -1;
|
int clopt_netbook = -1;
|
||||||
int clopt_mono = -1;
|
int clopt_mono = -1;
|
||||||
int clopt_gray = -1;
|
int clopt_gray = -1;
|
||||||
|
@ -282,6 +284,7 @@ int config_init( int argc, char* argv[] )
|
||||||
{"sdl", no_argument, &clopt_frontend_type, FRONTEND_SDL },
|
{"sdl", no_argument, &clopt_frontend_type, FRONTEND_SDL },
|
||||||
{"no-chrome", no_argument, &clopt_hide_chrome, true },
|
{"no-chrome", no_argument, &clopt_hide_chrome, true },
|
||||||
{"fullscreen", no_argument, &clopt_show_ui_fullscreen, true },
|
{"fullscreen", no_argument, &clopt_show_ui_fullscreen, true },
|
||||||
|
{"scale", required_argument, NULL, 7110 },
|
||||||
|
|
||||||
{"x11", no_argument, &clopt_frontend_type, FRONTEND_X11 },
|
{"x11", no_argument, &clopt_frontend_type, FRONTEND_X11 },
|
||||||
{"netbook", no_argument, &clopt_netbook, true },
|
{"netbook", no_argument, &clopt_netbook, true },
|
||||||
|
@ -404,6 +407,9 @@ int config_init( int argc, char* argv[] )
|
||||||
case 1015:
|
case 1015:
|
||||||
clopt_serialLine = optarg;
|
clopt_serialLine = optarg;
|
||||||
break;
|
break;
|
||||||
|
case 7110:
|
||||||
|
clopt_scale = atof( optarg );
|
||||||
|
break;
|
||||||
case 8110:
|
case 8110:
|
||||||
clopt_x11_visual = optarg;
|
clopt_x11_visual = optarg;
|
||||||
break;
|
break;
|
||||||
|
@ -562,6 +568,9 @@ int config_init( int argc, char* argv[] )
|
||||||
lua_getglobal( config_lua_values, "fullscreen" );
|
lua_getglobal( config_lua_values, "fullscreen" );
|
||||||
config.show_ui_fullscreen = lua_toboolean( config_lua_values, -1 );
|
config.show_ui_fullscreen = lua_toboolean( config_lua_values, -1 );
|
||||||
|
|
||||||
|
lua_getglobal( config_lua_values, "scale" );
|
||||||
|
config.scale = lua_tonumber( config_lua_values, -1.0 );
|
||||||
|
|
||||||
lua_getglobal( config_lua_values, "netbook" );
|
lua_getglobal( config_lua_values, "netbook" );
|
||||||
config.netbook = lua_toboolean( config_lua_values, -1 );
|
config.netbook = lua_toboolean( config_lua_values, -1 );
|
||||||
|
|
||||||
|
@ -644,6 +653,8 @@ int config_init( int argc, char* argv[] )
|
||||||
config.hide_chrome = clopt_hide_chrome;
|
config.hide_chrome = clopt_hide_chrome;
|
||||||
if ( clopt_show_ui_fullscreen != -1 )
|
if ( clopt_show_ui_fullscreen != -1 )
|
||||||
config.show_ui_fullscreen = clopt_show_ui_fullscreen;
|
config.show_ui_fullscreen = clopt_show_ui_fullscreen;
|
||||||
|
if ( clopt_scale != -1.0 )
|
||||||
|
config.scale = clopt_scale;
|
||||||
if ( clopt_netbook != -1 )
|
if ( clopt_netbook != -1 )
|
||||||
config.netbook = clopt_netbook;
|
config.netbook = clopt_netbook;
|
||||||
if ( clopt_mono != -1 )
|
if ( clopt_mono != -1 )
|
||||||
|
@ -715,6 +726,7 @@ int config_init( int argc, char* argv[] )
|
||||||
fprintf( stdout, "\" -- possible values: \"x11\", \"sdl2\", \"sdl\" (deprecated), \"tui\", \"tui-small\", \"tui-tiny\"\n" );
|
fprintf( stdout, "\" -- possible values: \"x11\", \"sdl2\", \"sdl\" (deprecated), \"tui\", \"tui-small\", \"tui-tiny\"\n" );
|
||||||
fprintf( stdout, "hide_chrome = %s\n", config.hide_chrome ? "true" : "false" );
|
fprintf( stdout, "hide_chrome = %s\n", config.hide_chrome ? "true" : "false" );
|
||||||
fprintf( stdout, "fullscreen = %s\n", config.show_ui_fullscreen ? "true" : "false" );
|
fprintf( stdout, "fullscreen = %s\n", config.show_ui_fullscreen ? "true" : "false" );
|
||||||
|
fprintf( stdout, "scale = %f -- applies only to sdl2\n", config.scale );
|
||||||
fprintf( stdout, "mono = %s\n", config.mono ? "true" : "false" );
|
fprintf( stdout, "mono = %s\n", config.mono ? "true" : "false" );
|
||||||
fprintf( stdout, "gray = %s\n", config.gray ? "true" : "false" );
|
fprintf( stdout, "gray = %s\n", config.gray ? "true" : "false" );
|
||||||
fprintf( stdout, "leave_shift_keys = %s\n", config.leave_shift_keys ? "true" : "false" );
|
fprintf( stdout, "leave_shift_keys = %s\n", config.leave_shift_keys ? "true" : "false" );
|
||||||
|
|
|
@ -35,6 +35,7 @@ typedef struct {
|
||||||
/* sdl */
|
/* sdl */
|
||||||
bool hide_chrome;
|
bool hide_chrome;
|
||||||
bool show_ui_fullscreen;
|
bool show_ui_fullscreen;
|
||||||
|
double scale;
|
||||||
|
|
||||||
/* x11 */
|
/* x11 */
|
||||||
bool netbook;
|
bool netbook;
|
||||||
|
|
|
@ -1101,7 +1101,8 @@ void init_sdl2_ui( int argc, char** argv )
|
||||||
else
|
else
|
||||||
window_flags |= SDL_WINDOW_RESIZABLE;
|
window_flags |= SDL_WINDOW_RESIZABLE;
|
||||||
|
|
||||||
window = SDL_CreateWindow( config.progname, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, window_flags );
|
window = SDL_CreateWindow( config.progname, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width * config.scale,
|
||||||
|
height * config.scale, window_flags );
|
||||||
if ( window == NULL ) {
|
if ( window == NULL ) {
|
||||||
printf( "Couldn't create window: %s\n", SDL_GetError() );
|
printf( "Couldn't create window: %s\n", SDL_GetError() );
|
||||||
exit( 1 );
|
exit( 1 );
|
||||||
|
@ -1111,6 +1112,8 @@ void init_sdl2_ui( int argc, char** argv )
|
||||||
if ( renderer == NULL )
|
if ( renderer == NULL )
|
||||||
exit( 2 );
|
exit( 2 );
|
||||||
|
|
||||||
|
SDL_RenderSetLogicalSize( renderer, width, height );
|
||||||
|
|
||||||
main_texture = SDL_CreateTexture( renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, width, height );
|
main_texture = SDL_CreateTexture( renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, width, height );
|
||||||
|
|
||||||
SDL_SetRenderTarget( renderer, main_texture );
|
SDL_SetRenderTarget( renderer, main_texture );
|
||||||
|
|
Loading…
Reference in a new issue