Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Commit

Permalink
Fix mip map size calculation for non-square textures
Browse files Browse the repository at this point in the history
The size of a mip map is `max{floor(width / 2 ^ level), 1} x max{floor(height / 2 ^ level), 1}`,
where `width x height` is the size of the full-resolution image,
`level` is the integer mip map level
and the smallest mip map has `1 x 1` resolution.
If `regenerateMipMapLevels` is called with custom mip map data,
the mip map sizes are calculated in this function and separately in `uploadTexture`.
`uploadTexture` calculates a size by `floor(width / 2 ^ level) x floor(height / 2 ^ level)`.

To support non-square textures, after this change,
`uploadTexture` sets the mip map width or height to `1` if it is `0`.
  • Loading branch information
HybridDog authored and sfan5 committed Jan 5, 2024
1 parent 91e4129 commit fb4ee6a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions source/Irrlicht/COpenGLCoreTexture.h
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,10 @@ class COpenGLCoreTexture : public ITexture

u32 width = Size.Width >> level;
u32 height = Size.Height >> level;
if (width < 1)
width = 1;
if (height < 1)
height = 1;

GLenum tmpTextureType = TextureType;

Expand Down

0 comments on commit fb4ee6a

Please sign in to comment.