From f46b77ab7b9233b065e281c264de10a6f12f2060 Mon Sep 17 00:00:00 2001 From: hayaunderscore Date: Mon, 11 Sep 2023 13:59:15 +0800 Subject: [PATCH] fix shader compile error, fix custom level palettes --- src/hardware/r_opengl/r_opengl.c | 6 +++--- src/hardware/r_opengl/r_opengl.h | 4 ++++ src/v_video.c | 7 ++++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 82787faf6..2b2dc1b1d 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -566,7 +566,7 @@ static boolean gl_batching = false;// are we currently collecting batches? static GLint gl_palette[768]; static INT32 gl_use_palette_shader = 0; -static boolean gl_palette_initialized = false; +boolean gl_palette_initialized = false; static INT32 gl_enable_screen_textures = 1; @@ -740,7 +740,7 @@ static gl_shaderprogram_t gl_shaderprograms[MAXSHADERPROGRAMS]; GLSL_DOOM_COLORMAP \ "void main(void) {\n" \ "vec4 texel = texture2D(tex, gl_TexCoord[0].st);\n" \ - "float pal_idx = int(texture3D(lookup_tex, vec3((texel * 63.0 + 0.5) / 64.0))[0] * 255.0);\n" \ + "int pal_idx = int(texture3D(lookup_tex, vec3((texel * 63.0 + 0.5) / 64.0))[0] * 255.0);\n" \ "float z = gl_FragCoord.z / gl_FragCoord.w;\n" \ "float light_y = clamp(floor(R_DoomColormap(lighting, z)), 0.0, 31.0);\n" \ "gl_FragColor = vec4(float(palette[pal_idx*3])/255.0, float(palette[pal_idx*3+1])/255.0, float(palette[pal_idx*3+2])/255.0, 1.0);\n" \ @@ -1109,7 +1109,7 @@ EXPORT void HWRAPI(KillShaders) (void) // the +2 in the NearestColor call also needs to be adjusted if LUT_SIZE is changed! // the hardcoded values in the shader also need to be adjusted if LUT_SIZE is changed! -static void InitPalette(void) +void InitPalette(void) { int i, r, g, b; // init the palette diff --git a/src/hardware/r_opengl/r_opengl.h b/src/hardware/r_opengl/r_opengl.h index 6d11bf4e3..f4a3f3849 100644 --- a/src/hardware/r_opengl/r_opengl.h +++ b/src/hardware/r_opengl/r_opengl.h @@ -133,4 +133,8 @@ typedef enum GLF_NOTEXENV = 0x02, } oglflags_t; +// in order for custom playpals n shit to work properly +extern boolean gl_palette_initialized; +void InitPalette(void); + #endif diff --git a/src/v_video.c b/src/v_video.c index 602e89248..77295c41b 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -28,6 +28,7 @@ #ifdef HWRENDER #include "hardware/hw_main.h" +#include "hardware/r_opengl/r_opengl.h" #endif // Each screen is [vid.width*vid.height]; @@ -238,8 +239,12 @@ void V_SetPaletteLump(const char *pal) { LoadPalette(pal); #ifdef HWRENDER - if (rendermode != render_soft && rendermode != render_none) + if (rendermode != render_soft && rendermode != render_none) { + // reset our palette lookups n shit + gl_palette_initialized = false; + InitPalette(); HWR_SetPalette(pLocalPalette); + } #if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (HAVE_SDL) else #endif -- 2.54.0