aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2012-11-25 16:39:07 +0200
committerPerttu Ahola <celeron55@gmail.com>2012-11-25 16:39:07 +0200
commite02b95741bb0953a4322955bfab18511ff31511d (patch)
tree3ceb3b96a7c57f72d5d710267ac3db3e8a32e6a8 /src
parentbbd990f2cca59b9e5775707ba24fbab21a0c6164 (diff)
downloadminetest-e02b95741bb0953a4322955bfab18511ff31511d.tar.gz
minetest-e02b95741bb0953a4322955bfab18511ff31511d.tar.bz2
minetest-e02b95741bb0953a4322955bfab18511ff31511d.zip
Revert "Don't leak textures all over the place"
This causes textures to be deleted before they are no longer accessed, resulting in a segmentation fault. This needs to be rewritten in such a way that textures are deleted when the client disconnects from a server. This reverts commit 41c00e87d42580881d8c7001f39014814e3b55f2.
Diffstat (limited to 'src')
-rw-r--r--src/mesh.cpp3
-rw-r--r--src/tile.cpp40
2 files changed, 12 insertions, 31 deletions
diff --git a/src/mesh.cpp b/src/mesh.cpp
index b9ec82e18..0f075f72b 100644
--- a/src/mesh.cpp
+++ b/src/mesh.cpp
@@ -433,9 +433,6 @@ video::ITexture *generateTextureFromMesh(scene::IMesh *mesh,
}
// Create render target texture
- video::ITexture *oldtexture = driver->findTexture(texture_name.c_str());
- if(oldtexture)
- driver->removeTexture(oldtexture);
video::ITexture *rtt = driver->addRenderTargetTexture(
dim, texture_name.c_str(), video::ECF_A8R8G8B8);
if(rtt == NULL)
diff --git a/src/tile.cpp b/src/tile.cpp
index e676c56c4..f7f1779ca 100644
--- a/src/tile.cpp
+++ b/src/tile.cpp
@@ -519,15 +519,6 @@ core::dimension2d<u32> imageTransformDimension(u32 transform, core::dimension2d<
void imageTransform(u32 transform, video::IImage *src, video::IImage *dst);
/*
- Adds a new texture to the video driver and returns a pointer to it.
- This pointer should not be dropped. Any texture that was registered
- with that name before is removed (this may invalidate some ITexture
- pointers).
-*/
-video::ITexture* register_texture(video::IVideoDriver *driver,
- std::string name, video::IImage *img);
-
-/*
Generate image based on a string like "stone.png" or "[crack0".
if baseimg is NULL, it is created. Otherwise stuff is made on it.
*/
@@ -695,9 +686,11 @@ u32 TextureSource::getTextureIdDirect(const std::string &name)
" create texture \""<<name<<"\""<<std::endl;
}
- // Create texture from resulting image
if(baseimg != NULL)
- t = register_texture(driver, name, baseimg);
+ {
+ // Create texture from resulting image
+ t = driver->addTexture(name.c_str(), baseimg);
+ }
/*
Add texture to caches (add NULL textures too)
@@ -816,7 +809,7 @@ void TextureSource::rebuildImagesAndTextures()
// Create texture from resulting image
video::ITexture *t = NULL;
if(img)
- t = register_texture(driver, sap->name, img);
+ t = driver->addTexture(sap->name.c_str(), img);
// Replace texture
sap->a.atlas = t;
@@ -1051,7 +1044,7 @@ void TextureSource::buildMainAtlas(class IGameDef *gamedef)
/*
Make texture
*/
- video::ITexture *t = register_texture(driver, "__main_atlas__", atlas_img);
+ video::ITexture *t = driver->addTexture("__main_atlas__", atlas_img);
assert(t);
/*
@@ -1142,15 +1135,6 @@ video::IImage* generate_image_from_scratch(std::string name,
return baseimg;
}
-video::ITexture* register_texture(video::IVideoDriver *driver,
- std::string name, video::IImage *img)
-{
- video::ITexture *old_texture = driver->findTexture(name.c_str());
- if(old_texture)
- driver->removeTexture(old_texture);
- return driver->addTexture(name.c_str(), img);
-}
-
bool generate_image(std::string part_of_name, video::IImage *& baseimg,
IrrlichtDevice *device, SourceImageCache *sourcecache)
{
@@ -1557,12 +1541,12 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
assert(img_top && img_left && img_right);
// Create textures from images
- video::ITexture *texture_top = register_texture(driver,
- imagename_top + "__temp1__", img_top);
- video::ITexture *texture_left = register_texture(driver,
- imagename_left + "__temp2__", img_left);
- video::ITexture *texture_right = register_texture(driver,
- imagename_right + "__temp3__", img_right);
+ video::ITexture *texture_top = driver->addTexture(
+ (imagename_top + "__temp__").c_str(), img_top);
+ video::ITexture *texture_left = driver->addTexture(
+ (imagename_left + "__temp__").c_str(), img_left);
+ video::ITexture *texture_right = driver->addTexture(
+ (imagename_right + "__temp__").c_str(), img_right);
assert(texture_top && texture_left && texture_right);
// Drop images