From 55a1de899c35c63d5f191d09a905a7fa42a853ce Mon Sep 17 00:00:00 2001 From: Sean Ryder Date: Fri, 29 Apr 2016 18:58:20 +0100 Subject: [PATCH 1/3] The fade masks textures should use an alpha format So they don't get effected by the texture format set by the screen depth GL_RGB5_A1 from 16-bit was removing all alpha from the texture --- src/hardware/r_opengl/r_opengl.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index a407a9e4..587a2393 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1470,6 +1470,26 @@ EXPORT void HWRAPI(SetTexture) (FTextureInfo *pTexInfo) else pglTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, ptex); } + else if (pTexInfo->grInfo.format == GR_TEXFMT_ALPHA_8) + { + //pglTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, ptex); + if (MipMap) + { + pgluBuild2DMipmaps(GL_TEXTURE_2D, GL_ALPHA, w, h, GL_RGBA, GL_UNSIGNED_BYTE, ptex); +#ifdef GL_TEXTURE_MIN_LOD + pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_LOD, 0); +#endif +#ifdef GL_TEXTURE_MAX_LOD + if (pTexInfo->flags & TF_TRANSPARENT) + pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 0); // No mippmaps on transparent stuff + else + pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 4); +#endif + //pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_LINEAR_MIPMAP_LINEAR); + } + else + pglTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, ptex); + } else { if (MipMap) From d2d73f085d641f5fdbd0ad531384793ecf4456fe Mon Sep 17 00:00:00 2001 From: Sean Ryder Date: Fri, 29 Apr 2016 20:56:46 +0100 Subject: [PATCH 2/3] Change internal formats of screen fade texture to RGB Don't think either of them need RGBA --- src/hardware/r_opengl/r_opengl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 587a2393..ddd5807a 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -2163,7 +2163,7 @@ EXPORT void HWRAPI(StartScreenWipe) (void) Clamp2D(GL_TEXTURE_WRAP_S); Clamp2D(GL_TEXTURE_WRAP_T); #ifndef KOS_GL_COMPATIBILITY - pglCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, texsize, texsize, 0); + pglCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, texsize, texsize, 0); #endif tex_downloaded = 0; // 0 so it knows it doesn't have any of the cached patches downloaded right now @@ -2192,7 +2192,7 @@ EXPORT void HWRAPI(EndScreenWipe)(void) Clamp2D(GL_TEXTURE_WRAP_S); Clamp2D(GL_TEXTURE_WRAP_T); #ifndef KOS_GL_COMPATIBILITY - pglCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, texsize, texsize, 0); + pglCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, texsize, texsize, 0); #endif tex_downloaded = 0; // 0 so it knows it doesn't have any of the cached patches downloaded right now From 0eb41b4450c715971cfbfabfbb2723a9488bf48d Mon Sep 17 00:00:00 2001 From: Sean Ryder Date: Sat, 30 Apr 2016 13:40:00 +0100 Subject: [PATCH 3/3] Flip fade mask Y coordinates For some reason every texture and flat loaded into GL is vertically flipped --- src/hardware/r_opengl/r_opengl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index ddd5807a..5115da60 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -2307,22 +2307,22 @@ EXPORT void HWRAPI(DoScreenWipe)(float alpha) // Bottom left pglMultiTexCoord2f(GL_TEXTURE0, 0.0f, 0.0f); - pglMultiTexCoord2f(GL_TEXTURE1, 0.0f, 0.0f); + pglMultiTexCoord2f(GL_TEXTURE1, 0.0f, 1.0f); pglVertex3f(-1.0f, -1.0f, 1.0f); // Top left pglMultiTexCoord2f(GL_TEXTURE0, 0.0f, yfix); - pglMultiTexCoord2f(GL_TEXTURE1, 0.0f, 1.0f); + pglMultiTexCoord2f(GL_TEXTURE1, 0.0f, 0.0f); pglVertex3f(-1.0f, 1.0f, 1.0f); // Top right pglMultiTexCoord2f(GL_TEXTURE0, xfix, yfix); - pglMultiTexCoord2f(GL_TEXTURE1, 1.0f, 1.0f); + pglMultiTexCoord2f(GL_TEXTURE1, 1.0f, 0.0f); pglVertex3f(1.0f, 1.0f, 1.0f); // Bottom right pglMultiTexCoord2f(GL_TEXTURE0, xfix, 0.0f); - pglMultiTexCoord2f(GL_TEXTURE1, 1.0f, 0.0f); + pglMultiTexCoord2f(GL_TEXTURE1, 1.0f, 1.0f); pglVertex3f(1.0f, -1.0f, 1.0f); pglEnd();