From 25bc55730e1674ab4178a452685ca54ea3d0f84d Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 9 Jan 2024 12:23:43 +0100 Subject: [PATCH] change this --- src/hardware/hw_main.c | 2 ++ src/hardware/r_opengl/r_opengl.c | 11 ++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 4a394943a..fcc1330b7 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -517,6 +517,8 @@ void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *col Surface->LightTableId = colormap->gl_lighttable_id; } + else + Surface->LightTableId = 0; } void HWR_ClearLightTableCache(void) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index ea1189d5c..8d076e4ba 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -76,6 +76,7 @@ static float NEAR_CLIPPING_PLANE = NZCLIP_PLANE; static GLuint tex_downloaded = 0; +static GLuint lt_downloaded = 0; // currently bound lighttable texture static GLfloat fov = 90.0f; static FBITFIELD CurrentPolyFlags; @@ -1688,6 +1689,7 @@ EXPORT void HWRAPI(ClearLightTableCache) (void) ltcachehead = next; } ltcachetail = NULL; + lt_downloaded = 0; } // -----------------+ @@ -2567,11 +2569,12 @@ EXPORT void HWRAPI(RenderBatches) (precise_t *sSortTime, precise_t *sDrawTime, i if (gl_allowshaders) { Shader_Load(¤tSurfaceInfo, &firstPoly, &firstTint, &firstFade); - if (gl_palshader) + if ((gl_palshader) && (currentSurfaceInfo.LightTableId && currentSurfaceInfo.LightTableId != lt_downloaded)) { pglActiveTexture(GL_TEXTURE2);// this stuff could be done better but gonna do it quick like this for now pglBindTexture(GL_TEXTURE_2D, currentSurfaceInfo.LightTableId); pglActiveTexture(GL_TEXTURE0); + lt_downloaded = currentSurfaceInfo.LightTableId; } } @@ -2829,11 +2832,12 @@ EXPORT void HWRAPI(RenderBatches) (precise_t *sSortTime, precise_t *sDrawTime, i Shader_Load(&nextSurfaceInfo, &poly, &tint, &fade); - if (gl_palshader) + if ((gl_palshader) && (nextSurfaceInfo.LightTableId && nextSurfaceInfo.LightTableId != lt_downloaded)) { pglActiveTexture(GL_TEXTURE2);// this stuff could be done better but gonna do it quick like this for now pglBindTexture(GL_TEXTURE_2D, nextSurfaceInfo.LightTableId); pglActiveTexture(GL_TEXTURE0); + lt_downloaded = nextSurfaceInfo.LightTableId; } } @@ -2940,11 +2944,12 @@ EXPORT void HWRAPI(DrawPolygon) (FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUI fade.alpha = byte2float[pSurf->FadeColor.s.alpha]; } - if (gl_palshader && gl_allowshaders) + if ((gl_palshader && gl_allowshaders) && (pSurf->LightTableId && pSurf->LightTableId != lt_downloaded)) { pglActiveTexture(GL_TEXTURE2); pglBindTexture(GL_TEXTURE_2D, pSurf->LightTableId); pglActiveTexture(GL_TEXTURE0); + lt_downloaded = pSurf->LightTableId; } }