Fix clamping bug when r_mipmap is off

This commit is contained in:
Magnus Norddahl 2016-11-06 07:33:17 +01:00
parent 5e547e9455
commit 70d4097b34

View file

@ -275,9 +275,9 @@ void R_DrawMaskedColumnBgra(FTexture *tex, fixed_t col, bool useRt, bool unmaske
int mipmap_offset = 0; int mipmap_offset = 0;
int mip_width = tex->GetWidth(); int mip_width = tex->GetWidth();
int mip_height = tex->GetHeight(); int mip_height = tex->GetHeight();
uint32_t xpos = (uint32_t)((((uint64_t)xoffset) << FRACBITS) / mip_width);
if (r_mipmap && tex->Mipmapped() && mip_width > 1 && mip_height > 1) if (r_mipmap && tex->Mipmapped() && mip_width > 1 && mip_height > 1)
{ {
uint32_t xpos = (uint32_t)((((uint64_t)xoffset) << FRACBITS) / mip_width);
int level = (int)lod; int level = (int)lod;
while (level > 0 && mip_width > 1 && mip_height > 1) while (level > 0 && mip_width > 1 && mip_height > 1)
{ {
@ -286,8 +286,8 @@ void R_DrawMaskedColumnBgra(FTexture *tex, fixed_t col, bool useRt, bool unmaske
mip_width = MAX(mip_width >> 1, 1); mip_width = MAX(mip_width >> 1, 1);
mip_height = MAX(mip_height >> 1, 1); mip_height = MAX(mip_height >> 1, 1);
} }
xoffset = (xpos >> FRACBITS) * mip_width;
} }
xoffset = (xpos >> FRACBITS) * mip_width;
const uint32_t *pixels = tex->GetPixelsBgra() + mipmap_offset; const uint32_t *pixels = tex->GetPixelsBgra() + mipmap_offset;