Skip to content

Commit

Permalink
Merge pull request #741 from Blackhawk-TA/patch-mipmap-bounds
Browse files Browse the repository at this point in the history
Fix mipmap boundary check
  • Loading branch information
Gadgetoid committed Jan 7, 2022
2 parents 1204303 + 4149ad3 commit 810f637
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions 32blit/types/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ namespace blit {
uint16_t mipmap_index = floorf(mipmap);
uint8_t blend = (mipmap - floorf(mipmap)) * 255;

mipmap_index = mipmap_index >= sprites->mipmaps.size() ? uint16_t(sprites->mipmaps.size() - 1) : mipmap_index;
mipmap_index = mipmap_index < 0 ? 0 : mipmap_index;
if (mipmap_index >= sprites->mipmaps.size()) {
mipmap_index = int32_t(sprites->mipmaps.size()) - 1 < 0 ? 0 : uint16_t(sprites->mipmaps.size() - 1);
}

dest->alpha = 255;
texture_span(dest, s, c, sprites->mipmaps[mipmap_index], swc, ewc, mipmap_index);
Expand Down

0 comments on commit 810f637

Please sign in to comment.