commit 767029e4d421e31185e215d22eb207d3bf7f5c22
Author: Fabian Greffrath <fabian@greffrath.com>
AuthorDate: Sun Feb 5 00:15:56 2017 +0100
Commit: Fabian Greffrath <fabian@greffrath.com>
CommitDate: Sun Feb 5 00:15:56 2017 +0100
Add option to force integer scales for resolution-independent rendering
Fixes #853
---
src/i_video.c | 11 +++++++++++
src/i_video.h | 1 +
src/m_config.c | 6 ++++++
src/setup/display.c | 5 +++++
4 files changed, 23 insertions(+)
diff --git a/src/i_video.c b/src/i_video.c
index 97f97d23..55a1f45f 100644
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -122,6 +122,10 @@ int fullscreen = true;
int aspect_ratio_correct = true;
+// Force integer scales for resolution-independent rendering
+
+int integer_scaling = false;
+
// Force software rendering, for systems which lack effective hardware
// acceleration
@@ -1151,6 +1155,12 @@ static void SetVideoMode(void)
SCREENWIDTH,
EffectiveScreenHeight());
+ // Force integer scales for resolution-independent rendering.
+
+#if SDL_VERSION_ATLEAST(2, 0, 5)
+ SDL_RenderSetIntegerScale(renderer, integer_scaling);
+#endif
+
// Blank out the full screen area in case there is any junk in
// the borders that won't otherwise be overwritten.
@@ -1330,6 +1340,7 @@ void I_BindVideoVariables(void)
M_BindIntVariable("fullscreen", &fullscreen);
M_BindIntVariable("video_display", &video_display);
M_BindIntVariable("aspect_ratio_correct", &aspect_ratio_correct);
+ M_BindIntVariable("integer_scaling", &integer_scaling);
M_BindIntVariable("startup_delay", &startup_delay);
M_BindIntVariable("fullscreen_width", &fullscreen_width);
M_BindIntVariable("fullscreen_height", &fullscreen_height);
diff --git a/src/i_video.h b/src/i_video.h
index a4ac1a79..59125103 100644
--- a/src/i_video.h
+++ b/src/i_video.h
@@ -90,6 +90,7 @@ extern int screen_width;
extern int screen_height;
extern int fullscreen;
extern int aspect_ratio_correct;
+extern int integer_scaling;
extern int force_software_renderer;
#endif
diff --git a/src/m_config.c b/src/m_config.c
index 718226bc..04c17cdb 100644
--- a/src/m_config.c
+++ b/src/m_config.c
@@ -727,6 +727,12 @@ static default_t extra_defaults_list[] =
CONFIG_VARIABLE_INT(aspect_ratio_correct),
+ //!
+ // If non-zero, forces integer scales for resolution-independent rendering.
+ //
+
+ CONFIG_VARIABLE_INT(integer_scaling),
+
//!
// Window width when running in windowed mode.
//
diff --git a/src/setup/display.c b/src/setup/display.c
index 79f799b4..3824122c 100644
--- a/src/setup/display.c
+++ b/src/setup/display.c
@@ -66,6 +66,7 @@ static window_size_t window_sizes_scaled[] =
static char *video_driver = "";
static char *window_position = "";
static int aspect_ratio_correct = 1;
+static int integer_scaling = 0;
static int force_software_renderer = 0;
static int fullscreen = 1;
static int fullscreen_width = 0, fullscreen_height = 0;
@@ -193,6 +194,9 @@ static void AdvancedDisplayConfig(TXT_UNCAST_ARG(widget),
TXT_AddWidgets(window,
ar_checkbox = TXT_NewCheckBox("Fix aspect ratio",
&aspect_ratio_correct),
+#if SDL_VERSION_ATLEAST(2, 0, 5)
+ TXT_NewCheckBox("Integer scaling", &integer_scaling),
+#endif
TXT_If(gamemission == heretic || gamemission == hexen
|| gamemission == strife,
TXT_NewCheckBox("Graphical startup", &graphical_startup)),
@@ -249,6 +253,7 @@ void ConfigDisplay(void)
void BindDisplayVariables(void)
{
M_BindIntVariable("aspect_ratio_correct", &aspect_ratio_correct);
+ M_BindIntVariable("integer_scaling", &integer_scaling);
M_BindIntVariable("fullscreen", &fullscreen);
M_BindIntVariable("fullscreen_width", &fullscreen_width);
M_BindIntVariable("fullscreen_height", &fullscreen_height);