Fix resolution configuration on SDL2

This commit is contained in:
Michael Martin
2019-09-28 18:54:22 -07:00
parent 6f63db2c3d
commit 6855fb028d
5 changed files with 35 additions and 9 deletions
+1
View File
@@ -69,6 +69,7 @@ void TFB_UninitGraphics (void);
void TFB_ProcessEvents (void);
void TFB_SetGamma (float gamma);
void TFB_UploadTransitionScreen (void);
int TFB_SupportsHardwareScaling (void);
// This function should not be called directly
void TFB_SwapBuffers (int force_full_redraw);
+10
View File
@@ -209,4 +209,14 @@ TFB_SetColors (SDL_Surface *surface, SDL_Color *colors, int firstcolor, int ncol
return SDL_SetColors (surface, colors, firstcolor, ncolors);
}
int
TFB_SupportsHardwareScaling (void)
{
#ifdef HAVE_OPENGL
return 1;
#else
return 0;
#endif
}
#endif
+5
View File
@@ -203,4 +203,9 @@ TFB_SetColors (SDL_Surface *surface, SDL_Color *colors, int firstcolor, int ncol
return 0;
}
int
TFB_SupportsHardwareScaling (void)
{
return 1;
}
#endif
+3
View File
@@ -218,6 +218,9 @@ TFB_Pure_ConfigureVideo (int driver, int flags, int width, int height, int toggl
graphics_backend = &sdl2_unscaled_backend;
}
/* We succeeded, so alter the screen size to our new sizes */
ScreenWidthActual = width;
ScreenHeightActual = height;
/* TODO: Set bilinear vs nearest-neighbor filtering based on
* GfxFlags & TFB_GFXFLAGS_SCALE_ANY */
return 0;
+16 -9
View File
@@ -66,12 +66,6 @@ static void rename_template (WIDGET_TEXTENTRY *self);
static void rebind_control (WIDGET_CONTROLENTRY *widget);
static void clear_control (WIDGET_CONTROLENTRY *widget);
#ifdef HAVE_OPENGL
#define RES_OPTS 4
#else
#define RES_OPTS 2
#endif
#define MENU_COUNT 8
#define CHOICE_COUNT 22
#define SLIDER_COUNT 3
@@ -190,6 +184,19 @@ static WIDGET **menu_widgets[MENU_COUNT] = {
main_widgets, graphics_widgets, audio_widgets, engine_widgets,
incomplete_widgets, keyconfig_widgets, advanced_widgets, editkeys_widgets };
static int
number_res_options (void)
{
if (TFB_SupportsHardwareScaling ())
{
return 4;
}
else
{
return 2;
}
}
static int
quit_main_menu (WIDGET *self, int event)
{
@@ -359,11 +366,11 @@ SetDefaults (void)
GetGlobalOptions (&opts);
if (opts.res == OPTVAL_CUSTOM)
{
choices[0].numopts = RES_OPTS + 1;
choices[0].numopts = number_res_options () + 1;
}
else
{
choices[0].numopts = RES_OPTS;
choices[0].numopts = number_res_options ();
}
choices[0].selected = opts.res;
choices[1].selected = opts.driver;
@@ -728,7 +735,7 @@ init_widgets (void)
}
/* The first choice is resolution, and is handled specially */
choices[0].numopts = RES_OPTS;
choices[0].numopts = number_res_options ();
/* Choices 18-20 are also special, being the names of the key configurations */
for (i = 0; i < 6; i++)