fixed fsaa sampling and reduction of fsaa if gfx init fails

This commit is contained in:
Magnus Auvinen 2009-01-11 12:13:18 +00:00
parent 2a7402dd6c
commit d0bcf50ef5
2 changed files with 39 additions and 36 deletions

View file

@ -209,6 +209,41 @@ static int try_init()
return 0; return 0;
} }
static int gfx_init_window()
{
if(try_init() == 0)
return 0;
/* try disabling fsaa */
while(config.gfx_fsaa_samples)
{
config.gfx_fsaa_samples--;
if(config.gfx_fsaa_samples)
dbg_msg("gfx", "lowering FSAA to %d and trying again", config.gfx_fsaa_samples);
else
dbg_msg("gfx", "disabling FSAA and trying again");
if(try_init() == 0)
return 0;
}
/* try lowering the resolution */
if(config.gfx_screen_width != 640 || config.gfx_screen_height != 480)
{
dbg_msg("gfx", "setting resolution to 640x480 and trying again");
config.gfx_screen_width = 640;
config.gfx_screen_height = 480;
if(try_init() == 0)
return 0;
}
dbg_msg("gfx", "out of ideas. failed to init graphics");
return -1;
}
int gfx_init() int gfx_init()
{ {
int i; int i;
@ -230,36 +265,9 @@ int gfx_init()
if(!getenv("SDL_VIDEO_WINDOW_POS") && !getenv("SDL_VIDEO_CENTERED")) if(!getenv("SDL_VIDEO_WINDOW_POS") && !getenv("SDL_VIDEO_CENTERED"))
putenv("SDL_VIDEO_WINDOW_POS=8,27"); putenv("SDL_VIDEO_WINDOW_POS=8,27");
#endif #endif
do
{ if(gfx_init_window() != 0)
if(try_init() == 0) return -1;
break;
/* try disabling fsaa */
if(config.gfx_fsaa_samples)
{
dbg_msg("gfx", "disabling FSAA and trying again");
config.gfx_fsaa_samples = 0;
if(try_init() == 0)
break;
}
/* try lowering the resolution */
if(config.gfx_screen_width != 640 || config.gfx_screen_height != 480)
{
dbg_msg("gfx", "setting resolution to 640x480 and trying again");
config.gfx_screen_width = 640;
config.gfx_screen_height = 480;
if(try_init() == 0)
break;
}
dbg_msg("gfx", "out of ideas. failed to init graphics");
return -1;
} while(0);
} }
/* Init vertices */ /* Init vertices */

View file

@ -502,12 +502,7 @@ void MENUS::render_settings_graphics(RECT main_view)
ui_hsplit_t(&main_view, 20.0f, &button, &main_view); ui_hsplit_t(&main_view, 20.0f, &button, &main_view);
if (ui_do_button(&config.gfx_fsaa_samples, "FSAA samples", config.gfx_fsaa_samples, &button, ui_draw_checkbox_number, 0)) if (ui_do_button(&config.gfx_fsaa_samples, "FSAA samples", config.gfx_fsaa_samples, &button, ui_draw_checkbox_number, 0))
{ {
if(config.gfx_fsaa_samples < 2) config.gfx_fsaa_samples = 2; config.gfx_fsaa_samples = (config.gfx_fsaa_samples+1)%17;
else if(config.gfx_fsaa_samples < 4) config.gfx_fsaa_samples = 4;
else if(config.gfx_fsaa_samples < 6) config.gfx_fsaa_samples = 6;
else if(config.gfx_fsaa_samples < 8) config.gfx_fsaa_samples = 8;
else if(config.gfx_fsaa_samples < 16) config.gfx_fsaa_samples = 16;
else if(config.gfx_fsaa_samples >= 16) config.gfx_fsaa_samples = 0;
need_restart = true; need_restart = true;
} }