Run in window mode
.TP
.B \-g, \-\-geometry WIDTHxHEIGHT
-Run SuperTux in given resolution
+Run SuperTux in given resolution (eg. \-g 800x600)
+.TP
+.B \-a, \-\-aspect WIDTH:HEIGHT
+Run SuperTux with given aspect ratio (eg. \-a 4:3)
.TP
.B \-\-disable\-sfx
Disable sound effects
screenwidth = 800;
screenheight = 600;
+ aspectwidth = 4;
+ aspectheight = 3;
enable_script_debugger = false;
}
config_video_lisp->get("fullscreen", use_fullscreen);
config_video_lisp->get("width", screenwidth);
config_video_lisp->get("height", screenheight);
+ config_video_lisp->get("aspectwidth", aspectwidth);
+ config_video_lisp->get("aspectheight", aspectheight);
}
const lisp::Lisp* config_audio_lisp = config_lisp->get_lisp("audio");
writer.write_bool("fullscreen", use_fullscreen);
writer.write_int("width", screenwidth);
writer.write_int("height", screenheight);
+ writer.write_int("aspectwidth", aspectwidth);
+ writer.write_int("aspectheight", aspectheight);
writer.end_list("video");
writer.start_list("audio");
*/
int screenwidth;
int screenheight;
+ int aspectwidth;
+ int aspectheight;
bool use_fullscreen;
bool show_fps;
JoystickKeyboardController* main_controller = 0;
TinyGetText::DictionaryManager dictionary_manager;
+int SCREEN_WIDTH;
+int SCREEN_HEIGHT;
+
static void init_config()
{
config = new Config();
" -f, --fullscreen Run in fullscreen mode\n"
" -w, --window Run in window mode\n"
" -g, --geometry WIDTHxHEIGHT Run SuperTux in given resolution\n"
+ " -a, --aspect WIDTH:HEIGHT Run SuperTux with given aspect ratio\n"
" --disable-sfx Disable sound effects\n"
" --disable-music Disable music\n"
" --help Show this help message\n"
print_usage(argv[0]);
throw std::runtime_error("Invalid geometry spec, should be WIDTHxHEIGHT");
}
+ } else if(arg == "--aspect" || arg == "-a") {
+ if(i+1 >= argc) {
+ print_usage(argv[0]);
+ throw std::runtime_error("Need to specify a parameter for aspect switch");
+ }
+ if(sscanf(argv[++i], "%d:%d", &config->aspectwidth, &config->aspectheight)
+ != 2) {
+ print_usage(argv[0]);
+ throw std::runtime_error("Invalid aspect spec, should be WIDTH:HEIGHT");
+ }
} else if(arg == "--show-fps") {
config->show_fps = true;
} else if(arg == "--no-show-fps") {
}
#endif
+ // use aspect ratio to calculate logical resolution
+ if (config->aspectwidth > config->aspectheight) {
+ SCREEN_HEIGHT=600;
+ SCREEN_WIDTH=600*config->aspectwidth/config->aspectheight;
+ }
+ else {
+ SCREEN_WIDTH=600;
+ SCREEN_HEIGHT=600*config->aspectheight/config->aspectwidth;
+ }
+
// setup opengl state and transform
glDisable(GL_DEPTH_TEST);
glDisable(GL_CULL_FACE);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
// logical resolution here not real monitor resolution
- glOrtho(0, 800, 600, 0, -1.0, 1.0);
+ glOrtho(0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0, 0, 0);
void wait_for_event(float min_delay, float max_delay);
/// The width of the display (this is a logical value, not the physical value)
-static const float SCREEN_WIDTH = 800;
+extern int SCREEN_WIDTH;
/// The height of the display (this is a logical value, not the physical value)
-static const float SCREEN_HEIGHT = 600;
+extern int SCREEN_HEIGHT;
// global variables
class JoystickKeyboardController;
void
TextScroller::draw(DrawingContext& context)
{
- context.draw_surface(background.get(), Vector(0,0), 0);
+ context.draw_filled_rect(Vector(0, 0), Vector(SCREEN_WIDTH, SCREEN_HEIGHT),
+ Color(0.6f, 0.7f, 0.8f, 0.5f), 0);
+ context.draw_surface(background.get(), Vector(SCREEN_WIDTH/2 - background->get_width()/2 , SCREEN_HEIGHT/2 - background->get_height()/2), 0);
float y = SCREEN_HEIGHT - scroll;
for(size_t i = 0; i < lines.size(); i++) {
void
InfoBox::draw(DrawingContext& context)
{
- float x1 = 200;
- float y1 = 100;
+ float x1 = SCREEN_WIDTH/2-200;
+ float y1 = SCREEN_HEIGHT/2-200;
float width = 400;
float height = 200;