commit f48bc14086eeeacc5f3bab4361d7302f019baca5
Author: Mike Swanson <mikeonthecomputer@gmail.com>
AuthorDate: Sat Mar 31 11:55:10 2018 -0700
Commit: Mike Swanson <mikeonthecomputer@gmail.com>
CommitDate: Sat Mar 31 11:55:10 2018 -0700
video: allow setting linear filtering via config file
Suggested by @vanfanel in #1009, nearest filtering can produce poor
results in low resolutions. Now, in the extra config file, scaling_filter
can be set to "linear" which normally results in Blur-O-Vision, but
might be desirable in low resolutions.
---
src/i_video.c | 22 ++++++++++++++++++----
src/i_video.h | 1 +
src/m_config.c | 10 ++++++++++
src/setup/display.c | 2 ++
4 files changed, 31 insertions(+), 4 deletions(-)
diff --git a/src/i_video.c b/src/i_video.c
index c44a8a6c..fbe3ffd2 100644
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -104,6 +104,10 @@ char *video_driver = "";
char *window_position = "center";
+// Scaling filter applied
+
+char *scaling_filter = "nearest";
+
// SDL display number on which to run.
int video_display = 0;
@@ -1290,11 +1294,20 @@ static void SetVideoMode(void)
SDL_DestroyTexture(texture);
}
- // Set the scaling quality for rendering the intermediate texture into
- // the upscaled texture to "nearest", which is gritty and pixelated and
- // resembles software scaling pretty well.
+ // Set the scaling quality for rendering and immediate texture.
+ // Defaults to "nearest", which is gritty and pixelated and resembles
+ // software scaling pretty well. "linear" can be set as an alternative,
+ // which may give better results at low resolutions.
- SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "nearest");
+ if (!strcmp(scaling_filter, "linear"))
+ {
+ SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear");
+ }
+ else
+ {
+ scaling_filter = "nearest";
+ SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "nearest");
+ }
// Create the intermediate texture that the RGBA surface gets loaded into.
// The SDL_TEXTUREACCESS_STREAMING flag means that this texture's content
@@ -1456,6 +1469,7 @@ void I_BindVideoVariables(void)
M_BindIntVariable("grabmouse", &grabmouse);
M_BindStringVariable("video_driver", &video_driver);
M_BindStringVariable("window_position", &window_position);
+ M_BindStringVariable("scaling_filter", &scaling_filter);
M_BindIntVariable("usegamma", &usegamma);
M_BindIntVariable("png_screenshots", &png_screenshots);
}
diff --git a/src/i_video.h b/src/i_video.h
index 6e5c2e05..5f64ebc3 100644
--- a/src/i_video.h
+++ b/src/i_video.h
@@ -86,6 +86,7 @@ extern boolean screensaver_mode;
extern int usegamma;
extern pixel_t *I_VideoBuffer;
+extern char *scaling_filter;
extern int screen_width;
extern int screen_height;
extern int fullscreen;
diff --git a/src/m_config.c b/src/m_config.c
index 019c48c7..0b5d50e0 100644
--- a/src/m_config.c
+++ b/src/m_config.c
@@ -705,6 +705,16 @@ static default_t extra_defaults_list[] =
CONFIG_VARIABLE_STRING(window_position),
+ //!
+ //
+ // Scaling filter to use, accepted values are "nearest" (default)
+ // and "linear" - nearest gives a crisper display, but linear
+ // might produce more pleasing results at low resolutions
+ // (sub-640x480).
+ //
+
+ CONFIG_VARIABLE_STRING(scaling_filter),
+
//!
// If non-zero, the game will run in full screen mode. If zero,
// the game will run in a window.
diff --git a/src/setup/display.c b/src/setup/display.c
index b99d9fd3..f7b9a662 100644
--- a/src/setup/display.c
+++ b/src/setup/display.c
@@ -65,6 +65,7 @@ static window_size_t window_sizes_scaled[] =
static char *video_driver = "";
static char *window_position = "";
+static char *scaling_filter = "nearest";
static int aspect_ratio_correct = 1;
static int integer_scaling = 0;
static int vga_porch_flash = 0;
@@ -261,6 +262,7 @@ void BindDisplayVariables(void)
M_BindIntVariable("startup_delay", &startup_delay);
M_BindStringVariable("video_driver", &video_driver);
M_BindStringVariable("window_position", &window_position);
+ M_BindStringVariable("scaling_filter", &scaling_filter);
M_BindIntVariable("usegamma", &usegamma);
M_BindIntVariable("png_screenshots", &png_screenshots);
M_BindIntVariable("vga_porch_flash", &vga_porch_flash);