mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 20:40:04 +00:00
Fix rendering of placefile icons, now works on one map
This commit is contained in:
parent
f074e487de
commit
bc1bf8cef6
5 changed files with 32 additions and 21 deletions
|
|
@ -38,27 +38,22 @@ static const auto logger_ = scwx::util::Logger::Create(logPrefix_);
|
|||
class TextureAtlas::Impl
|
||||
{
|
||||
public:
|
||||
explicit Impl() :
|
||||
texturePathMap_ {},
|
||||
texturePathMutex_ {},
|
||||
atlas_ {},
|
||||
atlasMap_ {},
|
||||
atlasMutex_ {}
|
||||
{
|
||||
}
|
||||
explicit Impl() {}
|
||||
~Impl() {}
|
||||
|
||||
static boost::gil::rgba8_image_t LoadImage(const std::string& imagePath);
|
||||
|
||||
std::unordered_map<std::string, std::string> texturePathMap_;
|
||||
std::shared_mutex texturePathMutex_;
|
||||
std::unordered_map<std::string, std::string> texturePathMap_ {};
|
||||
std::shared_mutex texturePathMutex_ {};
|
||||
|
||||
std::shared_mutex textureCacheMutex_;
|
||||
std::unordered_map<std::string, boost::gil::rgba8_image_t> textureCache_;
|
||||
std::shared_mutex textureCacheMutex_ {};
|
||||
std::unordered_map<std::string, boost::gil::rgba8_image_t> textureCache_ {};
|
||||
|
||||
boost::gil::rgba8_image_t atlas_;
|
||||
std::unordered_map<std::string, TextureAttributes> atlasMap_;
|
||||
std::shared_mutex atlasMutex_;
|
||||
boost::gil::rgba8_image_t atlas_ {};
|
||||
std::unordered_map<std::string, TextureAttributes> atlasMap_ {};
|
||||
std::shared_mutex atlasMutex_ {};
|
||||
|
||||
bool needsBuffered_ {true};
|
||||
};
|
||||
|
||||
TextureAtlas::TextureAtlas() : p(std::make_unique<Impl>()) {}
|
||||
|
|
@ -67,6 +62,11 @@ TextureAtlas::~TextureAtlas() = default;
|
|||
TextureAtlas::TextureAtlas(TextureAtlas&&) noexcept = default;
|
||||
TextureAtlas& TextureAtlas::operator=(TextureAtlas&&) noexcept = default;
|
||||
|
||||
bool TextureAtlas::NeedsBuffered() const
|
||||
{
|
||||
return p->needsBuffered_;
|
||||
}
|
||||
|
||||
void TextureAtlas::RegisterTexture(const std::string& name,
|
||||
const std::string& path)
|
||||
{
|
||||
|
|
@ -275,6 +275,9 @@ void TextureAtlas::BuildAtlas(size_t width, size_t height)
|
|||
logger_->warn("Unable to pack texture: {}", images[i].first);
|
||||
}
|
||||
}
|
||||
|
||||
// Mark the need to buffer the atlas
|
||||
p->needsBuffered_ = true;
|
||||
}
|
||||
|
||||
GLuint TextureAtlas::BufferAtlas(gl::OpenGLFunctions& gl)
|
||||
|
|
@ -318,6 +321,9 @@ GLuint TextureAtlas::BufferAtlas(gl::OpenGLFunctions& gl)
|
|||
pixelData.data());
|
||||
}
|
||||
|
||||
// Atlas has been successfully buffered
|
||||
p->needsBuffered_ = false;
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue