summaryrefslogtreecommitdiff
path: root/src/tile.cpp
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2011-02-10 15:55:15 +0200
committerPerttu Ahola <celeron55@gmail.com>2011-02-10 15:55:15 +0200
commit841ac10e5c20ad152f375f43bceb992fc3945041 (patch)
treed2758b8eb34827e2ca3d1a20b2c523a2b623ec38 /src/tile.cpp
parenta7b158fada356f886b5c4648a7bd5f8114dca717 (diff)
downloadminetest-841ac10e5c20ad152f375f43bceb992fc3945041.tar.gz
minetest-841ac10e5c20ad152f375f43bceb992fc3945041.tar.bz2
minetest-841ac10e5c20ad152f375f43bceb992fc3945041.zip
fixes toward mingw compatibility
Diffstat (limited to 'src/tile.cpp')
-rw-r--r--src/tile.cpp30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/tile.cpp b/src/tile.cpp
index d71055c7a..7b19b3651 100644
--- a/src/tile.cpp
+++ b/src/tile.cpp
@@ -387,10 +387,16 @@ void TextureSource::buildMainAtlas()
sourcelist.push_back("sand.png^mineral_coal.png");
sourcelist.push_back("sand.png^mineral_iron.png");
+ // Padding to disallow texture bleeding
+ s32 padding = 8;
+
/*
First pass: generate almost everything
*/
core::position2d<s32> pos_in_atlas(0,0);
+
+ pos_in_atlas.Y += padding;
+
for(u32 i=0; i<sourcelist.size(); i++)
{
std::string name = sourcelist[i];
@@ -423,6 +429,28 @@ void TextureSource::buildMainAtlas()
NULL);
}
+ // Copy the borders a few times to disallow texture bleeding
+ for(u32 side=0; side<2; side++) // top and bottom
+ for(s32 y0=0; y0<padding; y0++)
+ for(s32 x0=0; x0<(s32)xwise_tiling*(s32)dim.Width; x0++)
+ {
+ s32 dst_y;
+ s32 src_y;
+ if(side==0)
+ {
+ dst_y = y0 + pos_in_atlas.Y + dim.Height;
+ src_y = pos_in_atlas.Y + dim.Height - 1;
+ }
+ else
+ {
+ dst_y = -y0 + pos_in_atlas.Y-1;
+ src_y = pos_in_atlas.Y;
+ }
+ s32 x = x0 + pos_in_atlas.X * dim.Width;
+ video::SColor c = atlas_img->getPixel(x, src_y);
+ atlas_img->setPixel(x,dst_y,c);
+ }
+
img2->drop();
/*
@@ -447,7 +475,7 @@ void TextureSource::buildMainAtlas()
m_name_to_id.insert(name, id);
// Increment position
- pos_in_atlas.Y += dim.Height;
+ pos_in_atlas.Y += dim.Height + padding * 2;
}
/*