From 092e70923573cf365a4035fc1c10148f5d9becb1 Mon Sep 17 00:00:00 2001
From: Sryder <sryder13@gmail.com>
Date: Thu, 17 May 2018 22:17:20 +0100
Subject: [PATCH] OpenGL Map Specific palettes working This makes OpenGL stop
 using a specific function that doesn't really do anything for it anymore. It
 looks like it was used for a hack that would change the colour of polygons
 for the flashpal equivalent in DOOM. I made it so ST_DoPaletteStuff doesn't
 set the flashpal in OpenGL as it already does its own hacky overlay and doing
 that would cause all the textures to be flushed more mid-level, it could be
 enabled for more correct flashpals, but they still wouldn't effect fog or
 lighting. This means the palette will be set when going to the title screen,
 and twice when starting a map, (causing the OpenGL cached textures to also be
 flushed at those times)

---
 src/d_main.c   |  7 +------
 src/p_setup.c  |  5 -----
 src/st_stuff.c | 10 +++++-----
 3 files changed, 6 insertions(+), 16 deletions(-)

diff --git a/src/d_main.c b/src/d_main.c
index 4cdfb13d92..fbec5f7d8d 100644
--- a/src/d_main.c
+++ b/src/d_main.c
@@ -730,11 +730,6 @@ void D_StartTitle(void)
 	CON_ToggleOff();
 
 	// Reset the palette
-#ifdef HWRENDER
-	if (rendermode == render_opengl)
-		HWR_SetPaletteColor(0);
-	else
-#endif
 	if (rendermode != render_none)
 		V_SetPaletteLump("PLAYPAL");
 }
@@ -1223,7 +1218,7 @@ void D_SRB2Main(void)
 	CONS_Printf("R_Init(): Init SRB2 refresh daemon.\n");
 	R_Init();
 
-	// setting up sound	
+	// setting up sound
 	if (dedicated)
 	{
 		nosound = true;
diff --git a/src/p_setup.c b/src/p_setup.c
index 52cd6ddbb1..c3aa9884da 100644
--- a/src/p_setup.c
+++ b/src/p_setup.c
@@ -2503,11 +2503,6 @@ boolean P_SetupLevel(boolean skipprecip)
 
 
 	// Reset the palette
-#ifdef HWRENDER
-	if (rendermode == render_opengl)
-		HWR_SetPaletteColor(0);
-	else
-#endif
 	if (rendermode != render_none)
 		V_SetPaletteLump("PLAYPAL");
 
diff --git a/src/st_stuff.c b/src/st_stuff.c
index 3562a9b713..72e0b6b94c 100644
--- a/src/st_stuff.c
+++ b/src/st_stuff.c
@@ -210,17 +210,17 @@ void ST_doPaletteStuff(void)
 	else
 		palette = 0;
 
+#ifdef HWRENDER
+	if (rendermode == render_opengl)
+		palette = 0; // No flashpals here in OpenGL
+#endif
+
 	palette = min(max(palette, 0), 13);
 
 	if (palette != st_palette)
 	{
 		st_palette = palette;
 
-#ifdef HWRENDER
-		if (rendermode == render_opengl)
-			HWR_SetPaletteColor(0);
-		else
-#endif
 		if (rendermode != render_none)
 		{
 			V_SetPaletteLump(GetPalette()); // Reset the palette
-- 
GitLab