From 4e2f1bcf2b1475e3cf2c5719d1ddd2d639990ebe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustaf=20Alh=C3=A4ll?= Date: Thu, 5 Jun 2025 19:23:20 +0200 Subject: [PATCH] Fix invalid formats being passed to interal texture formats The effects that this had on the engine is unknown, but the reference pages makes in very clear that the old behavior is wrong. --- src/hardware/r_opengl/r_opengl.c | 15 ++++++--------- src/sdl/ogl_sdl.c | 2 ++ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index a8e9d6350..1fc319f0e 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -689,7 +689,7 @@ typedef enum gluniform_leveltime, gluniform_scr_resolution, - + gluniform_max, } gluniform_t; @@ -1803,7 +1803,7 @@ void GL_UpdateTexture(GLMipmap_t *pTexInfo) case GL_TEXFMT_ALPHA_INTENSITY_88: GL_AllocTextureBuffer(pTexInfo); ptex = tex = textureBuffer; - texformat = GL_LUMINANCE_ALPHA; + texformat = GL_RGBA; for (idx = 0, j = 0; j < h; j++) { @@ -1821,7 +1821,7 @@ void GL_UpdateTexture(GLMipmap_t *pTexInfo) case GL_TEXFMT_ALPHA_8: // Used for fade masks GL_AllocTextureBuffer(pTexInfo); ptex = tex = textureBuffer; - texformat = GL_ALPHA; + texformat = GL_RGBA; memset(&tex->s, 255, sizeof(byteColor_t)*w*h); // 255 because the fade mask is modulated with the screen texture, so alpha affects it while the colours don't @@ -1857,8 +1857,6 @@ void GL_UpdateTexture(GLMipmap_t *pTexInfo) if (MipMap && !transparent) // No mipmaps on transparent stuff { - int maxlod = (texformat == GL_LUMINANCE_ALPHA || texformat == GL_ALPHA) ? 4 : 5; - pglTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE); if (update) @@ -1868,7 +1866,7 @@ void GL_UpdateTexture(GLMipmap_t *pTexInfo) // Control the mipmap level of detail pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_LOD, 0); - pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, maxlod); + pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 5); } else { @@ -1892,7 +1890,6 @@ void GL_UpdateTexture(GLMipmap_t *pTexInfo) pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, anisotropic_filter); } - // -----------------+ // SetTexture : The mipmap becomes the current texture source // -----------------+ @@ -2735,7 +2732,7 @@ void GL_DrawModelEx(model_t *model, INT32 frameIndex, float duration, float tics poly.green = byte2float[Surface->PolyColor.s.green]; poly.blue = byte2float[Surface->PolyColor.s.blue]; poly.alpha = byte2float[Surface->PolyColor.s.alpha]; - + pglColor4ubv((GLubyte*)&Surface->PolyColor.s); GL_SetBlend(((poly.alpha < 1) ? Surface->PolyFlags : (PF_Masked|PF_Occlude))|PF_Modulated); @@ -2749,7 +2746,7 @@ void GL_DrawModelEx(model_t *model, INT32 frameIndex, float duration, float tics fade.green = byte2float[Surface->FadeColor.s.green]; fade.blue = byte2float[Surface->FadeColor.s.blue]; fade.alpha = byte2float[Surface->FadeColor.s.alpha]; - + if (Surface->LightTableId && Surface->LightTableId != lt_downloaded) { pglActiveTexture(GL_TEXTURE2); diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index c8701506e..93609685c 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -237,6 +237,8 @@ boolean OglSdlSurface(INT32 w, INT32 h) first_init = true; + HWR_Startup(); + return true; }