shithub: choc

Download patch

ref: 7e528998a2c4dac76c004dc869d0a398188926fd
parent: 75005106f1582a284628aeb7148a231640a5bd14
parent: 767029e4d421e31185e215d22eb207d3bf7f5c22
author: Simon Howard <[email protected]>
date: Sun Feb 19 08:35:58 EST 2017

Merge pull request #855 from chocolate-doom/integer_scaling

Add option to force integer scales for resolution-independent rendering

--- a/src/i_video.c
+++ b/src/i_video.c
@@ -126,6 +126,10 @@
 
 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
 
@@ -1210,6 +1214,12 @@
                              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.
 
@@ -1389,6 +1399,7 @@
     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);
--- a/src/i_video.h
+++ b/src/i_video.h
@@ -90,6 +90,7 @@
 extern int screen_height;
 extern int fullscreen;
 extern int aspect_ratio_correct;
+extern int integer_scaling;
 extern int force_software_renderer;
 
 #endif
--- a/src/m_config.c
+++ b/src/m_config.c
@@ -728,6 +728,12 @@
     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.
     //
 
--- a/src/setup/display.c
+++ b/src/setup/display.c
@@ -66,6 +66,7 @@
 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;
@@ -194,6 +195,9 @@
     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)),
@@ -250,6 +254,7 @@
 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);