← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/bug-1536377-texture-atlas-size into lp:widelands

 

GunChleoc has proposed merging lp:~widelands-dev/widelands/bug-1536377-texture-atlas-size into lp:widelands.

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #1536377 in widelands: "The texture atlas must use at least 2048 as size (1024 was given)"
  https://bugs.launchpad.net/widelands/+bug/1536377

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1536377-texture-atlas-size/+merge/293067

Next try - relax the size requirement.
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1536377-texture-atlas-size into lp:widelands.
=== modified file 'src/graphic/build_texture_atlas.cc'
--- src/graphic/build_texture_atlas.cc	2016-04-05 06:14:46 +0000
+++ src/graphic/build_texture_atlas.cc	2016-04-30 16:03:23 +0000
@@ -39,9 +39,10 @@
 // threshold, but not background pictures.
 constexpr int kMaxAreaForTextureAtlas = 240 * 240;
 
-// A graphics card must at least support this size for texture for Widelands to
-// run.
-constexpr int kMinimumSizeForTextures = 2048;
+// A graphics card should at least support this size for texture for Widelands to run.
+constexpr int kRecommendedSizeForTextures = 2048;
+// A graphics card must at least support this size for texture for Widelands to run.
+constexpr int kMinimumSizeForTextures = 1024;
 
 // Returns true if 'filename' ends with an image extension.
 bool is_image(const std::string& filename) {
@@ -117,9 +118,13 @@
 build_texture_atlas(const int max_size,
                     std::map<std::string, std::unique_ptr<Texture>>* textures_in_atlas) {
 	if (max_size < kMinimumSizeForTextures) {
-		throw wexception("The texture atlas must use at least %d as size (%d was given)",
-		                 kMinimumSizeForTextures, max_size);
+		throw wexception("The texture atlas must use at least %d as size (%d was given)\n",
+							  kMinimumSizeForTextures, max_size);
+	} else if (max_size < kRecommendedSizeForTextures) {
+		log("The texture atlas should use at least %d as size (%d was given)\n",
+			 kRecommendedSizeForTextures, max_size);
 	}
+
 	std::vector<std::string> first_atlas_images;
 	std::unordered_set<std::string> all_images;
 
@@ -127,13 +132,15 @@
 	find_images("world/terrains", &all_images, &first_atlas_images);
 	// For flags and roads.
 	find_images("tribes/images", &all_images, &first_atlas_images);
-	// For UI elements mostly, but we get more than we need really.
-	find_images("images", &all_images, &first_atlas_images);
+	if (max_size >= kRecommendedSizeForTextures) { // If we don't exclude these, animated terrain gets wonky.
+		// For UI elements mostly, but we get more than we need really.
+		find_images("images", &all_images, &first_atlas_images);
+	}
 
 	auto first_texture_atlas = pack_images(first_atlas_images, max_size, textures_in_atlas);
 	if (first_texture_atlas.size() != 1) {
-		throw wexception("Not all images that should fit in the first texture atlas did actually "
-		                 "fit. Widelands has now more images than before.");
+		log("Not all images that should fit in the first texture atlas did actually "
+			 "fit. Widelands has now more images than before.\n");
 	}
 	return first_texture_atlas;
 }


References