diff --git a/src/r_swrenderer.cpp b/src/r_swrenderer.cpp
index df928b25e..051506e11 100644
--- a/src/r_swrenderer.cpp
+++ b/src/r_swrenderer.cpp
@@ -267,6 +267,11 @@ void FSoftwareRenderer::RenderTextureView (FCanvasTexture *tex, AActor *viewpoin
 	BYTE *Pixels = const_cast<BYTE*>(tex->GetPixels());
 	DSimpleCanvas *Canvas = tex->GetCanvas();
 
+	// curse Doom's overuse of global variables in the renderer.
+	// These get clobbered by rendering to a camera texture but they need to be preserved so the final rendering can be done with the correct palette.
+	unsigned char *savecolormap = fixedcolormap;
+	FSpecialColormap *savecm = realfixedcolormap;
+
 	float savedfov = LastFOV;
 	R_SetFOV ((float)fov);
 	R_RenderViewToCanvas (viewpoint, Canvas, 0, 0, tex->GetWidth(), tex->GetHeight(), tex->bFirstUpdate);
@@ -280,6 +285,8 @@ void FSoftwareRenderer::RenderTextureView (FCanvasTexture *tex, AActor *viewpoin
 		FTexture::FlipNonSquareBlockRemap (Pixels, Canvas->GetBuffer(), tex->GetWidth(), tex->GetHeight(), Canvas->GetPitch(), GPalette.Remap);
 	}
 	tex->SetUpdated();
+	fixedcolormap = savecolormap;
+	realfixedcolormap = savecm;
 }
 
 //==========================================================================
diff --git a/src/r_utility.cpp b/src/r_utility.cpp
index 60e2c1af1..cfe1767c7 100644
--- a/src/r_utility.cpp
+++ b/src/r_utility.cpp
@@ -62,9 +62,6 @@
 extern bool DrawFSHUD;		// [RH] Defined in d_main.cpp
 EXTERN_CVAR (Bool, cl_capfps)
 
-extern lighttable_t*	fixedcolormap;
-extern FSpecialColormap*realfixedcolormap;
-
 // TYPES -------------------------------------------------------------------
 
 struct InterpolationViewer
@@ -1101,11 +1098,6 @@ void FCanvasTextureInfo::UpdateAll ()
 {
 	FCanvasTextureInfo *probe;
 
-	// curse Doom's overuse of global variables in the renderer.
-	// These get clobbered by rendering to a camera texture but they need to be preserved so the final rendering can be done with the correct palette.
-	unsigned char *savecolormap = fixedcolormap;
-	FSpecialColormap *savecm = realfixedcolormap;
-
 	for (probe = List; probe != NULL; probe = probe->Next)
 	{
 		if (probe->Viewpoint != NULL && probe->Texture->bNeedsUpdate)
@@ -1113,9 +1105,6 @@ void FCanvasTextureInfo::UpdateAll ()
 			Renderer->RenderTextureView(probe->Texture, probe->Viewpoint, probe->FOV);
 		}
 	}
-
-	fixedcolormap = savecolormap;
-	realfixedcolormap = savecm;
 }
 
 //==========================================================================