foxygit / doom Log in
commit 47759a7292b957ab7d52ad5090eb22955cf6a965
Author:     StevenSYS <139715581+StevenSYS@users.noreply.github.com>
AuthorDate: Sat Mar 8 14:29:03 2025 +0000
Commit:     Turo Lamminen <turol@users.noreply.github.com>
CommitDate: Sat Apr 26 20:14:29 2025 +0300

    Add option to enable or disable smooth pixel scaling
---
 src/i_video.c       | 18 ++++++++++++++++--
 src/i_video.h       |  3 ++-
 src/m_config.c      |  9 +++++++--
 src/setup/display.c |  5 ++++-
 4 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/src/i_video.c b/src/i_video.c
index 6c94bf7b..264a724f 100644
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -129,6 +129,9 @@ int fullscreen = true;
 int aspect_ratio_correct = true;
 static int actualheight;

+// Smooth pixel scaling
+int smooth_pixel_scaling = true;
+
 // Force integer scales for resolution-independent rendering

 int integer_scaling = false;
@@ -789,7 +792,10 @@ void I_FinishUpdate (void)

     // Render this intermediate texture into the upscaled texture
     // using "nearest" integer scaling.
-
+    if (smooth_pixel_scaling && !force_software_renderer)
+    {
+    // Render this intermediate texture into the upscaled texture
+    // using "nearest" integer scaling.
     SDL_SetRenderTarget(renderer, texture_upscaled);
     SDL_RenderCopy(renderer, texture, NULL, NULL);

@@ -797,6 +803,13 @@ void I_FinishUpdate (void)

     SDL_SetRenderTarget(renderer, NULL);
     SDL_RenderCopy(renderer, texture_upscaled, NULL, NULL);
+    }
+    else
+    {
+        SDL_SetRenderTarget(renderer, NULL);
+        SDL_RenderCopy(renderer, texture, NULL, NULL);
+    }
+

     // Draw!

@@ -1503,6 +1516,7 @@ void I_BindVideoVariables(void)
     M_BindIntVariable("video_display",             &video_display);
     M_BindIntVariable("aspect_ratio_correct",      &aspect_ratio_correct);
     M_BindIntVariable("integer_scaling",           &integer_scaling);
+    M_BindIntVariable("smooth_pixel_scaling",      &smooth_pixel_scaling);
     M_BindIntVariable("vga_porch_flash",           &vga_porch_flash);
     M_BindIntVariable("startup_delay",             &startup_delay);
     M_BindIntVariable("fullscreen_width",          &fullscreen_width);
@@ -1516,4 +1530,4 @@ void I_BindVideoVariables(void)
     M_BindStringVariable("window_position",        &window_position);
     M_BindIntVariable("usegamma",                  &usegamma);
     M_BindIntVariable("png_screenshots",           &png_screenshots);
-}
+}
\ No newline at end of file
diff --git a/src/i_video.h b/src/i_video.h
index 83ab96d5..d98b8f50 100644
--- a/src/i_video.h
+++ b/src/i_video.h
@@ -92,6 +92,7 @@ extern int screen_height;
 extern int fullscreen;
 extern int aspect_ratio_correct;
 extern int integer_scaling;
+extern int smooth_pixel_scaling;
 extern int vga_porch_flash;
 extern int force_software_renderer;

@@ -106,4 +107,4 @@ extern unsigned int joywait;
 extern int usemouse;


-#endif
+#endif
\ No newline at end of file
diff --git a/src/m_config.c b/src/m_config.c
index 141f896b..0ef35ac8 100644
--- a/src/m_config.c
+++ b/src/m_config.c
@@ -738,6 +738,12 @@ static default_t extra_defaults_list[] =

     CONFIG_VARIABLE_INT(aspect_ratio_correct),

+    //!
+    // If non-zero, the screen will have smooth scaling.
+    //
+
+    CONFIG_VARIABLE_INT(smooth_pixel_scaling),
+
     //!
     // If non-zero, forces integer scales for resolution-independent rendering.
     //
@@ -2802,5 +2808,4 @@ char *M_GetAutoloadDir(const char *iwadname)
     // TODO: Add README file

     return result;
-}
-
+}
\ No newline at end of file
diff --git a/src/setup/display.c b/src/setup/display.c
index 9e72d208..0f89a093 100644
--- a/src/setup/display.c
+++ b/src/setup/display.c
@@ -67,6 +67,7 @@ static char *window_position = "";
 static int video_display = 0;
 static int aspect_ratio_correct = 1;
 static int integer_scaling = 0;
+static int smooth_pixel_scaling = 1;
 static int vga_porch_flash = 0;
 static int force_software_renderer = 0;
 static int fullscreen = 1;
@@ -207,6 +208,7 @@ static void AdvancedDisplayConfig(TXT_UNCAST_ARG(widget),
         TXT_NewCheckBox("Save screenshots in PNG format",
                         &png_screenshots),
 #endif
+        TXT_NewCheckBox("Smooth pixel scaling", &smooth_pixel_scaling),
         NULL);

     TXT_SignalConnect(ar_checkbox, "changed", GenerateSizesTable, sizes_table);
@@ -254,6 +256,7 @@ void BindDisplayVariables(void)
     M_BindIntVariable("video_display",             &video_display);
     M_BindIntVariable("aspect_ratio_correct",      &aspect_ratio_correct);
     M_BindIntVariable("integer_scaling",           &integer_scaling);
+    M_BindIntVariable("smooth_pixel_scaling",      &smooth_pixel_scaling);
     M_BindIntVariable("fullscreen",                &fullscreen);
     M_BindIntVariable("fullscreen_width",          &fullscreen_width);
     M_BindIntVariable("fullscreen_height",         &fullscreen_height);
@@ -283,4 +286,4 @@ void BindDisplayVariables(void)
     {
         M_BindIntVariable("graphical_startup",        &graphical_startup);
     }
-}
+}
\ No newline at end of file