diff options
author | SmallJoker <mk939@ymail.com> | 2016-04-21 21:54:30 +0200 |
---|---|---|
committer | paramat <mat.gregory@virginmedia.com> | 2016-04-25 06:39:32 +0100 |
commit | 31c1fca6fd5e200c4f4b24d7ba62b36a16494ed2 (patch) | |
tree | c36aa4db1bf6eb6b1e6041e5093ef909332e782c /src | |
parent | 46da0e8b3b7ac9f833b660afd34b24095531bcb0 (diff) | |
download | minetest-31c1fca6fd5e200c4f4b24d7ba62b36a16494ed2.tar.gz minetest-31c1fca6fd5e200c4f4b24d7ba62b36a16494ed2.tar.bz2 minetest-31c1fca6fd5e200c4f4b24d7ba62b36a16494ed2.zip |
tile.cpp: Automatically upscale lower resolution texture
Diffstat (limited to 'src')
-rw-r--r-- | src/client/tile.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/client/tile.cpp b/src/client/tile.cpp index e6668063c..72d626da7 100644 --- a/src/client/tile.cpp +++ b/src/client/tile.cpp @@ -1175,7 +1175,28 @@ bool TextureSource::generateImagePart(std::string part_of_name, core::rect<s32>(pos_from, dim), video::SColor(255,255,255,255), NULL);*/ - blit_with_alpha(image, baseimg, pos_from, pos_to, dim); + + core::dimension2d<u32> dim_dst = baseimg->getDimension(); + if (dim == dim_dst) { + blit_with_alpha(image, baseimg, pos_from, pos_to, dim); + } else if (dim.Width * dim.Height < dim_dst.Width * dim_dst.Height) { + // Upscale overlying image + video::IImage* scaled_image = m_device->getVideoDriver()-> + createImage(video::ECF_A8R8G8B8, dim_dst); + image->copyToScaling(scaled_image); + + blit_with_alpha(scaled_image, baseimg, pos_from, pos_to, dim_dst); + scaled_image->drop(); + } else { + // Upscale base image + video::IImage* scaled_base = m_device->getVideoDriver()-> + createImage(video::ECF_A8R8G8B8, dim); + baseimg->copyToScaling(scaled_base); + baseimg->drop(); + baseimg = scaled_base; + + blit_with_alpha(image, baseimg, pos_from, pos_to, dim); + } } //cleanup image->drop(); |