+bool ContentFeatures::textureAlphaCheck(ITextureSource *tsrc, const TileDef *tiles, int length)
+{
+ video::IVideoDriver *driver = RenderingEngine::get_video_driver();
+ static thread_local bool long_warning_printed = false;
+ std::set<std::string> seen;
+ for (int i = 0; i < length; i++) {
+ if (seen.find(tiles[i].name) != seen.end())
+ continue;
+ seen.insert(tiles[i].name);
+
+ // Load the texture and see if there's any transparent pixels
+ video::ITexture *texture = tsrc->getTexture(tiles[i].name);
+ video::IImage *image = driver->createImage(texture,
+ core::position2d<s32>(0, 0), texture->getOriginalSize());
+ if (!image)
+ continue;
+ core::dimension2d<u32> dim = image->getDimension();
+ bool ok = true;
+ for (u16 x = 0; x < dim.Width; x++) {
+ for (u16 y = 0; y < dim.Height; y++) {
+ if (image->getPixel(x, y).getAlpha() < 255) {
+ ok = false;
+ goto break_loop;
+ }
+ }
+ }
+
+break_loop:
+ image->drop();
+ if (!ok) {
+ warningstream << "Texture \"" << tiles[i].name << "\" of "
+ << name << " has transparent pixels, assuming "
+ "use_texture_alpha = true." << std::endl;
+ if (!long_warning_printed) {
+ warningstream << " This warning can be a false-positive if "
+ "unused pixels in the texture are transparent. However if "
+ "it is meant to be transparent, you *MUST* update the "
+ "nodedef and set use_texture_alpha = true! This compatibility "
+ "code will be removed in a few releases." << std::endl;
+ long_warning_printed = true;
+ }
+ return true;
+ }
+ }
+ return false;
+}
+