X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fmain.cpp;h=6acd08c5e497465dc13fad8a2d4b317959ddfc73;hb=c75799590ba936c673bea467b65518c3c2c2e284;hp=c355c811ff3ce348ff7197051a9fae8b2bb3d910;hpb=2d3b7e2b2b0504f1d890d95f38d8929678a50dd4;p=supertux.git diff --git a/src/main.cpp b/src/main.cpp index c355c811f..6acd08c5e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -313,24 +313,32 @@ static bool parse_commandline(int argc, char** argv) } else { - int aspect_width = 4; - int aspect_height = 3; - if(sscanf(argv[i], "%d:%d", &aspect_width, &aspect_height) != 2) { - print_usage(argv[0]); - throw std::runtime_error("Invalid aspect spec, should be WIDTH:HEIGHT"); - } else { - float aspect_ratio = static_cast(config->aspect_width) / - static_cast(config->aspect_height); - - // use aspect ratio to calculate logical resolution - if (aspect_ratio > 1) { - config->aspect_width = static_cast (600 * aspect_ratio + 0.5); - config->aspect_height = 600; - } else { - config->aspect_width = 600; - config->aspect_height = static_cast (600 * 1/aspect_ratio + 0.5); + int aspect_width = 0; + int aspect_height = 0; + if (strcmp(argv[i], "auto") == 0) + { + aspect_width = 0; + aspect_height = 0; + } + else if (sscanf(argv[i], "%d:%d", &aspect_width, &aspect_height) != 2) + { + print_usage(argv[0]); + throw std::runtime_error("Invalid aspect spec, should be WIDTH:HEIGHT or auto"); + } + else + { + float aspect_ratio = static_cast(config->aspect_width) / + static_cast(config->aspect_height); + + // use aspect ratio to calculate logical resolution + if (aspect_ratio > 1) { + config->aspect_width = static_cast (600 * aspect_ratio + 0.5); + config->aspect_height = 600; + } else { + config->aspect_width = 600; + config->aspect_height = static_cast (600 * 1/aspect_ratio + 0.5); + } } - } } } else if(arg == "--show-fps") { config->show_fps = true;