diff --git a/src/graphics/stk_tex_manager.cpp b/src/graphics/stk_tex_manager.cpp index 299829831..ea160c77c 100644 --- a/src/graphics/stk_tex_manager.cpp +++ b/src/graphics/stk_tex_manager.cpp @@ -17,6 +17,7 @@ #include "graphics/stk_tex_manager.hpp" #include "graphics/central_settings.hpp" +#include "graphics/irr_driver.hpp" #include "graphics/stk_texture.hpp" #include "io/file_manager.hpp" #include "utils/string_utils.hpp" @@ -131,3 +132,21 @@ int STKTexManager::dumpTextureUsage() Log::info("STKTexManager", "Total %dMB", size); return size; } // dumpAllTexture + +// ---------------------------------------------------------------------------- +STKTexture* STKTexManager::getUnicolorTexture(const irr::video::SColor &c) +{ + std::string name = StringUtils::toString(c.color) + "unic"; + auto ret = m_all_textures.find(name); + if (ret != m_all_textures.end()) + return ret->second; + + uint32_t color[4] = { c.color, c.color, c.color, c.color }; + video::IImage* image = irr_driver->getVideoDriver() + ->createImageFromData(video::ECF_A8R8G8B8, + core::dimension2d(2, 2), color); + STKTexture* texture = new STKTexture(image, name); + addTexture(texture); + return texture; + +} // getUnicolorTexture diff --git a/src/graphics/stk_tex_manager.hpp b/src/graphics/stk_tex_manager.hpp index b66b927cd..1bb337632 100644 --- a/src/graphics/stk_tex_manager.hpp +++ b/src/graphics/stk_tex_manager.hpp @@ -27,6 +27,10 @@ #include class STKTexture; +namespace irr +{ + namespace video { class SColor; } +} class STKTexManager : public Singleton, NoCopy { @@ -49,6 +53,8 @@ public: bool set_material = false, bool mesh_tex = false, bool no_upload = false); // ------------------------------------------------------------------------ + STKTexture* getUnicolorTexture(const irr::video::SColor &c); + // ------------------------------------------------------------------------ void addTexture(STKTexture* t); // ------------------------------------------------------------------------ void removeTexture(STKTexture* t); diff --git a/src/graphics/stk_texture.cpp b/src/graphics/stk_texture.cpp index 484da9620..a2a754c63 100644 --- a/src/graphics/stk_texture.cpp +++ b/src/graphics/stk_texture.cpp @@ -25,7 +25,6 @@ #include #include -#include // ---------------------------------------------------------------------------- STKTexture::STKTexture(const std::string& path, bool srgb, bool premul_alpha,