From 1cccaa059f1fbee60660d00f0c85e66eb09d1ca4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gustaf=20Alh=C3=A4ll?= <gustaf@hanicef.me>
Date: Tue, 18 Mar 2025 20:50:14 +0100
Subject: [PATCH] Fix view warping when changing resolution in software

---
 src/hardware/hw_main.c | 15 +--------------
 src/r_main.c           |  1 +
 2 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c
index 34b718a2b..a6bc692f8 100644
--- a/src/hardware/hw_main.c
+++ b/src/hardware/hw_main.c
@@ -80,19 +80,6 @@ static sector_t *gl_backsector;
 // --------------------------------------------------------------------------
 
 FTransform atransform;
-// duplicates of the main code, set after R_SetupFrame() passed them into sharedstruct,
-// copied here for local use
-static angle_t dup_viewangle;
-
-static float gl_viewx, gl_viewy, gl_viewz;
-float gl_viewsin, gl_viewcos;
-
-// Maybe not necessary with the new T&L code (needs to be checked!)
-static float gl_viewludsin, gl_viewludcos; // look up down kik test
-static float gl_fovlud;
-
-static angle_t gl_aimingangle;
-static void HWR_SetTransformAiming(FTransform *trans, player_t *player, boolean skybox);
 
 // Render stats
 ps_metric_t ps_hw_skyboxtime = {0};
@@ -5195,7 +5182,7 @@ static void HWR_DrawSkyBackground(player_t *player)
 		// software doesn't draw any further than 1024 for skies anyway, but this doesn't overlap properly
 		// The only time this will probably be an issue is when a sky wider than 1024 is used as a sky AND a regular wall texture
 
-		angle = (dup_viewangle + xtoviewangle[0]);
+		angle = (viewangle + xtoviewangle[0]);
 
 		dimensionmultiply = ((float)textures[texturetranslation[skytexture]]->width/256.0f);
 
diff --git a/src/r_main.c b/src/r_main.c
index a8d5d4c98..f1864a37e 100644
--- a/src/r_main.c
+++ b/src/r_main.c
@@ -915,6 +915,7 @@ void R_ExecuteSetViewSize(void)
 	projection = projectiony = FixedDiv(centerxfrac, fovtan);
 
 	R_InitViewBuffer(viewwidth, viewheight);
+	R_SetFov(cv_fov.value);
 
 	// thing clipping
 	for (i = 0; i < viewwidth; i++)
-- 
GitLab