add code for letterboxing. this option is configurable and disabled by default for now, as it doesn't work correctly yet

This commit is contained in:
Sebastian Krzyszkowiak 2012-08-04 13:57:29 +02:00
parent 2078f2da29
commit 219fc714db

View file

@ -446,6 +446,25 @@ int main(int argc, char **argv){
break;
}
if (atoi(GetConfigOptionDefault("SuperDerpy", "letterbox", "0"))) {
float const aspectRatio = (float)800 / (float)500;
int clipWidth = al_get_display_width(game.display), clipHeight = al_get_display_width(game.display) / aspectRatio;
int clipX = 0, clipY = (al_get_display_height(game.display) - clipHeight) / 2;
if (clipY <= 0) {
clipHeight = al_get_display_height(game.display);
clipWidth = al_get_display_height(game.display) * aspectRatio;
clipX = (al_get_display_width(game.display) - clipWidth) / 2;
clipY = 0;
}
al_set_clipping_rectangle(clipX, clipY, clipWidth, clipHeight);
float scaleX = (float)clipWidth / (float)800,
scaleY = (float)clipHeight / (float)500;
ALLEGRO_TRANSFORM projection;
al_build_transform(&projection, clipX, clipY, scaleX, scaleY, 0.0f);
al_use_transform(&projection);
}
while(1) {
ALLEGRO_EVENT ev;
bool event = false;