From 14be968089c052f74b0b1c76fcd9dcb75d2921bb Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 8 Jul 2025 16:52:56 +0100 Subject: [PATCH] fix for non pow2 width textures in software from doom-legacy --- src/r_data.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/r_data.c b/src/r_data.c index 8fbcaaef8..b0e3a18b6 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -595,9 +595,23 @@ Rloadtextures (INT32 i, INT32 w) Z_Free(patchlump); + // determine width power of 2 +#if 1 + // [WDJ] only need to determine if exact power of 2. + k = 1; + while (k < texture->width) + k<<=1; +#else + // Largest power of 2 that fits within width. k = 1; while (k << 1 <= texture->width) k <<= 1; +#endif + if (k != texture->width) + { + // Odd width + k = 1; // make texturewidthmask = 0 + } texturewidthmask[i] = k - 1; textureheight[i] = texture->height << FRACBITS;