diff options
author | Weblate <42@minetest.ru> | 2013-06-21 10:24:16 +0200 |
---|---|---|
committer | Weblate <42@minetest.ru> | 2013-06-21 10:24:16 +0200 |
commit | 3af90db5b51da0c37f77fe6410e488c8c27acd67 (patch) | |
tree | 12edd6f0661b464e36863517241b5ec0b87b5ec1 /src/tile.cpp | |
parent | 58f3cd3eb598a7cf79983fe9e48c738591c6e004 (diff) | |
parent | b1ebd9f79c63cf78b0e0fb2ea6f52d82cdfb95b6 (diff) | |
download | minetest-3af90db5b51da0c37f77fe6410e488c8c27acd67.tar.gz minetest-3af90db5b51da0c37f77fe6410e488c8c27acd67.tar.bz2 minetest-3af90db5b51da0c37f77fe6410e488c8c27acd67.zip |
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'src/tile.cpp')
-rw-r--r-- | src/tile.cpp | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/tile.cpp b/src/tile.cpp index 5f25e123b..f176d1549 100644 --- a/src/tile.cpp +++ b/src/tile.cpp @@ -364,14 +364,14 @@ public: // Gets a separate texture video::ITexture* getTextureRaw(const std::string &name) { - AtlasPointer ap = getTexture(name + "^[forcesingle"); + AtlasPointer ap = getTexture(name + m_forcesingle_suffix); return ap.atlas; } // Gets a separate texture atlas pointer AtlasPointer getTextureRawAP(const AtlasPointer &ap) { - return getTexture(getTextureName(ap.id) + "^[forcesingle"); + return getTexture(getTextureName(ap.id) + m_forcesingle_suffix); } // Returns a pointer to the irrlicht device @@ -437,9 +437,14 @@ private: // Main texture atlas. This is filled at startup and is then not touched. video::IImage *m_main_atlas_image; video::ITexture *m_main_atlas_texture; + std::string m_forcesingle_suffix; // Queued texture fetches (to be processed by the main thread) RequestQueue<std::string, u32, u8, u8> m_get_texture_queue; + + // Textures that have been overwritten with other ones + // but can't be deleted because the ITexture* might still be used + std::list<video::ITexture*> m_texture_trash; }; IWritableTextureSource* createTextureSource(IrrlichtDevice *device) @@ -485,6 +490,16 @@ TextureSource::~TextureSource() } m_atlaspointer_cache.clear(); + for (std::list<video::ITexture*>::iterator iter = + m_texture_trash.begin(); iter != m_texture_trash.end(); + iter++) + { + video::ITexture *t = *iter; + + //cleanup trashed texture + driver->removeTexture(t); + } + infostream << "~TextureSource() "<< textures_before << "/" << driver->getTextureCount() << std::endl; } @@ -870,7 +885,7 @@ void TextureSource::rebuildImagesAndTextures() sap->intsize = img->getDimension(); if (t_old != 0) - driver->removeTexture(t_old); + m_texture_trash.push_back(t_old); } } @@ -1123,6 +1138,8 @@ void TextureSource::buildMainAtlas(class IGameDef *gamedef) <<atlaspath<<std::endl; fs::RecursiveDelete(atlaspath); driver->writeImageToFile(atlas_img, atlaspath.c_str());*/ + + m_forcesingle_suffix = "^[forcesingle"; } video::IImage* generate_image_from_scratch(std::string name, |