From ad39ade2862973b9de8cae4e731d185c3e845c73 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 11 Feb 2025 19:21:38 +0100 Subject: [PATCH] split screentexture width and height most displays are widescreen, so their width and height differ quite significantly, this may make the overall screentexture alot smaller --- src/hardware/r_opengl/r_opengl.c | 78 ++++++++++++++++++++------------ 1 file changed, 48 insertions(+), 30 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 0db93e19d..d2224e118 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -2853,7 +2853,7 @@ void GL_PostImgRedraw(float points[SCREENVERTS][SCREENVERTS][2]) INT32 x, y; float float_x, float_y, float_nextx, float_nexty; float xfix, yfix; - INT32 texsize = 512; + INT32 texsizew = 512, texsizey = 512; const float blackBack[16] = { @@ -2867,12 +2867,15 @@ void GL_PostImgRedraw(float points[SCREENVERTS][SCREENVERTS][2]) return; // look for power of two that is large enough for the screen - while (texsize < screen_width || texsize < screen_height) - texsize <<= 1; + while (texsizew < screen_width) + texsizew <<= 1; + + while (texsizey < screen_height) + texsizey <<= 1; // X/Y stretch fix for all resolutions(!) - xfix = (float)(texsize)/((float)((screen_width)/(float)(SCREENVERTS-1))); - yfix = (float)(texsize)/((float)((screen_height)/(float)(SCREENVERTS-1))); + xfix = (float)(texsizew)/((float)((screen_width)/(float)(SCREENVERTS-1))); + yfix = (float)(texsizey)/((float)((screen_height)/(float)(SCREENVERTS-1))); pglDisable(GL_DEPTH_TEST); pglDisable(GL_BLEND); @@ -2945,7 +2948,7 @@ void GL_FlushScreenTextures(void) void GL_DrawScreenTexture(int tex, FSurfaceInfo *surf, FBITFIELD polyflags) { float xfix, yfix; - INT32 texsize = 512; + INT32 texsizew = 512, texsizey = 512; const float screenVerts[12] = { @@ -2961,11 +2964,14 @@ void GL_DrawScreenTexture(int tex, FSurfaceInfo *surf, FBITFIELD polyflags) return; // look for power of two that is large enough for the screen - while (texsize < screen_width || texsize < screen_height) - texsize <<= 1; + while (texsizew < screen_width) + texsizew <<= 1; - xfix = 1/((float)(texsize)/((float)((screen_width)))); - yfix = 1/((float)(texsize)/((float)((screen_height)))); + while (texsizey < screen_height) + texsizey <<= 1; + + xfix = 1/((float)(texsizew)/((float)((screen_width)))); + yfix = 1/((float)(texsizey)/((float)((screen_height)))); // const float screenVerts[12] @@ -2998,7 +3004,7 @@ void GL_DrawScreenTexture(int tex, FSurfaceInfo *surf, FBITFIELD polyflags) // Do screen fades! void GL_DoScreenWipe(int wipeStart, int wipeEnd) { - INT32 texsize = 512; + INT32 texsizew = 512, texsizey = 512; float xfix, yfix; INT32 fademaskdownloaded = tex_downloaded; // the fade mask that has been set @@ -3025,11 +3031,14 @@ void GL_DoScreenWipe(int wipeStart, int wipeEnd) return; // look for power of two that is large enough for the screen - while (texsize < screen_width || texsize < screen_height) - texsize <<= 1; + while (texsizew < screen_width) + texsizew <<= 1; - xfix = 1/((float)(texsize)/((float)((screen_width)))); - yfix = 1/((float)(texsize)/((float)((screen_height)))); + while (texsizey < screen_height) + texsizey <<= 1; + + xfix = 1/((float)(texsizew)/((float)((screen_width)))); + yfix = 1/((float)(texsizey)/((float)((screen_height)))); // const float screenVerts[12] @@ -3089,7 +3098,7 @@ void GL_DoScreenWipe(int wipeStart, int wipeEnd) void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 downdistort, UINT8 barsize) { - INT32 texsize = 512; + INT32 texsizew = 512, texsizey = 512; int tex = HWD_SCREENTEXTURE_VHS; float xfix, yfix; float fix[8]; @@ -3108,11 +3117,14 @@ void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 return; // look for power of two that is large enough for the screen - while (texsize < screen_width || texsize < screen_height) - texsize <<= 1; + while (texsizew < screen_width) + texsizew <<= 1; - xfix = 1/((float)(texsize)/((float)((screen_width)))); - yfix = 1/((float)(texsize)/((float)((screen_height)))); + while (texsizey < screen_height) + texsizey <<= 1; + + xfix = 1/((float)(texsizew)/((float)((screen_width)))); + yfix = 1/((float)(texsizey)/((float)((screen_height)))); // Slight fuzziness GL_MakeScreenTexture(tex); @@ -3196,15 +3208,18 @@ void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 // Create a texture from the screen. void GL_MakeScreenTexture(int tex) { - INT32 texsize = 512; + INT32 texsizew = 512, texsizey = 512; boolean firstTime = (screenTextures[tex] == 0); if (!gl_enable_screen_textures) return; // look for power of two that is large enough for the screen - while (texsize < screen_width || texsize < screen_height) - texsize <<= 1; + while (texsizew < screen_width) + texsizew <<= 1; + + while (texsizey < screen_height) + texsizey <<= 1; // Create screen texture if (firstTime) @@ -3217,10 +3232,10 @@ void GL_MakeScreenTexture(int tex) pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); Clamp2D(GL_TEXTURE_WRAP_S); Clamp2D(GL_TEXTURE_WRAP_T); - pglCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, texsize, texsize, 0); + pglCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, texsizew, texsizey, 0); } else - pglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texsize, texsize); + pglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texsizew, texsizey); tex_downloaded = screenTextures[tex]; } @@ -3231,7 +3246,7 @@ void GL_DrawScreenFinalTexture(int tex, INT32 width, INT32 height, boolean usesh float origaspect, newaspect; float xoff = 1, yoff = 1; // xoffset and yoffset for the polygon to have black bars around the screen FRGBAFloat clearColour; - INT32 texsize = 512; + INT32 texsizew = 512, texsizey = 512; float off[12]; float fix[8]; @@ -3240,11 +3255,14 @@ void GL_DrawScreenFinalTexture(int tex, INT32 width, INT32 height, boolean usesh return; // look for power of two that is large enough for the screen - while (texsize < screen_width || texsize < screen_height) - texsize <<= 1; + while (texsizew < screen_width) + texsizew <<= 1; - xfix = 1/((float)(texsize)/((float)((screen_width)))); - yfix = 1/((float)(texsize)/((float)((screen_height)))); + while (texsizey < screen_height) + texsizey <<= 1; + + xfix = 1/((float)(texsizew)/((float)((screen_width)))); + yfix = 1/((float)(texsizey)/((float)((screen_height)))); origaspect = (float)screen_width / screen_height; newaspect = (float)width / height;