mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-20 06:58:20 +00:00
fixed fsaa sampling and reduction of fsaa if gfx init fails
This commit is contained in:
parent
2a7402dd6c
commit
d0bcf50ef5
|
@ -209,6 +209,41 @@ static int try_init()
|
|||
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 i;
|
||||
|
@ -230,36 +265,9 @@ int gfx_init()
|
|||
if(!getenv("SDL_VIDEO_WINDOW_POS") && !getenv("SDL_VIDEO_CENTERED"))
|
||||
putenv("SDL_VIDEO_WINDOW_POS=8,27");
|
||||
#endif
|
||||
do
|
||||
{
|
||||
if(try_init() == 0)
|
||||
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);
|
||||
|
||||
if(gfx_init_window() != 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Init vertices */
|
||||
|
|
|
@ -502,12 +502,7 @@ void MENUS::render_settings_graphics(RECT 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(config.gfx_fsaa_samples < 2) config.gfx_fsaa_samples = 2;
|
||||
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;
|
||||
config.gfx_fsaa_samples = (config.gfx_fsaa_samples+1)%17;
|
||||
need_restart = true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue