Skip to content

Commit

Permalink
Decrease level of mip-map texture if texture with given size and leve…
Browse files Browse the repository at this point in the history
…l can't be created by OpenGL.

Fixed shadows of empire: black triangles (regression!) #1612
  • Loading branch information
gonetz committed Oct 2, 2017
1 parent e4f29a1 commit deaf612
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/Textures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <algorithm>
#include <thread> // std::this_thread::sleep_for
#include <chrono> // std::chrono::seconds
#include "Platform.h"
#include "Textures.h"
#include "GBI.h"
#include "RSP.h"
Expand Down Expand Up @@ -1147,8 +1148,16 @@ void TextureCache::_load(u32 _tile, CachedTexture *_pTexture)
s32 mipLevel = 0;
_pTexture->max_level = 0;

if (config.generalEmulation.enableLOD != 0 && gSP.texture.level > 1)
_pTexture->max_level = static_cast<u8>(_tile == 0 ? 0 : gSP.texture.level - 1);
if (config.generalEmulation.enableLOD != 0 && gSP.texture.level > 1) {
if (_tile == 0) {
_pTexture->max_level = 0;
} else {
_pTexture->max_level = static_cast<u8>(gSP.texture.level - 1);
const u16 dim = std::max(_pTexture->width, _pTexture->height);
while (dim < static_cast<u16>(1 << _pTexture->max_level))
--_pTexture->max_level;
}
}

ObjectHandle name;
CachedTexture tmptex(name);
Expand Down

0 comments on commit deaf612

Please sign in to comment.