@@ -81,12 +81,6 @@ struct StringMaker<TextureAtlasTiles::TileHandle> {
81
81
82
82
auto tileData (TileData::Padding padding = {}) { return TileData (TileData::Size (4 ), padding); }
83
83
84
- auto mipmappedTileData (TileData::Padding padding = {})
85
- {
86
- auto mipmapper = [](const TileData& tile_data) { return TileData (dgl::nextMipmapSize (tile_data.size ())); };
87
- return MipmapLevels (tileData (padding), mipmapper);
88
- }
89
-
90
84
auto atlasTiles () { return TextureAtlasTiles ({16 , 4 }); }
91
85
92
86
auto atlasTilesWithTileHandle (const TileData::Padding& padding = {})
@@ -111,6 +105,12 @@ auto frozenTilesWithTileHandle()
111
105
return std::pair{freeze (std::move (atlas_tiles)), tile_handle};
112
106
}
113
107
108
+ auto applyMipmap (const TileData& tile_data)
109
+ {
110
+ auto mipmapper = [](const TileData& tile_data) { return TileData (dgl::nextMipmapSize (tile_data.size ())); };
111
+ return MipmapLevels (tile_data, mipmapper);
112
+ }
113
+
114
114
TEST_CASE (" TextureAtlasTiles can be constructed and moved." , " [texturing][texture-atlas-tiles]" )
115
115
{
116
116
SECTION (" Constructing TextureAtlasTiles." )
@@ -281,6 +281,7 @@ TEST_CASE("TextureAtlasTiles can be filled with tiles of the same size, spanning
281
281
auto tile_height = GENERATE (range<std::size_t >(1 , 5 ));
282
282
283
283
auto tile_size = TileData::Size (tile_width, tile_height);
284
+ auto tile_data = GENERATE_COPY (MipmapLevels (TileData (tile_size)), applyMipmap (TileData (tile_size)));
284
285
285
286
// Tiles are aligned on powers of two:
286
287
auto tile_width_log2 = dutils::ilog2ceil (tile_width);
@@ -299,7 +300,7 @@ TEST_CASE("TextureAtlasTiles can be filled with tiles of the same size, spanning
299
300
DYNAMIC_SECTION (" Atlas of size " << max_texture_size << " cannot fit any tile of size " << tile_size
300
301
<< " .\n Adding a single tile should throw an invalid_argument exception." )
301
302
{
302
- CHECK_THROWS_AS (atlas_tiles.add (TileData (tile_size) ), std::invalid_argument);
303
+ CHECK_THROWS_AS (atlas_tiles.add (tile_data ), std::invalid_argument);
303
304
}
304
305
}
305
306
else {
@@ -311,7 +312,7 @@ TEST_CASE("TextureAtlasTiles can be filled with tiles of the same size, spanning
311
312
for (std::size_t layer = 0 ; layer < max_layer_count; layer++) {
312
313
std::set<dmath::svec2> tile_positions;
313
314
for (std::size_t i = 0 ; i < tiles_per_layer; i++) {
314
- auto tile = atlas_tiles.add (TileData (tile_size) );
315
+ auto tile = atlas_tiles.add (tile_data );
315
316
auto tile_pos = tile.pixelPos ();
316
317
auto [_, position_is_unique] = tile_positions.insert (tile_pos);
317
318
@@ -329,7 +330,7 @@ TEST_CASE("TextureAtlasTiles can be filled with tiles of the same size, spanning
329
330
330
331
SECTION (" Adding one more tile should throw a length_error exception." )
331
332
{
332
- CHECK_THROWS_AS (atlas_tiles.add (TileData (tile_size) ), std::length_error);
333
+ CHECK_THROWS_AS (atlas_tiles.add (tile_data ), std::length_error);
333
334
}
334
335
}
335
336
}
@@ -347,12 +348,13 @@ TEST_CASE("TextureAtlasTiles can be used to update a texture.", "[texturing]")
347
348
auto mipmap_levels = dgl::maxMipmapLevels (size);
348
349
auto tile_size = GENERATE (as<std::size_t >{}, 1 , 2 , 4 );
349
350
auto layers = GENERATE (as<std::size_t >{}, 1 , 2 , 4 );
351
+ auto tile_data = GENERATE_COPY (MipmapLevels (TileData (tile_size)), applyMipmap (TileData (tile_size)));
350
352
351
353
auto tile_count = dutils::sqr (size) / dutils::sqr (tile_size) * layers;
352
354
353
355
auto atlas_tiles = TextureAtlasTiles ({size, layers});
354
356
for (std::size_t i = 0 ; i < tile_count; i++)
355
- (void )atlas_tiles.add (TileData ( TileData::Size (tile_size)) );
357
+ (void )atlas_tiles.add (tile_data );
356
358
357
359
SECTION (" Using the updateTexture method, which allows further modifications." )
358
360
{
@@ -364,7 +366,7 @@ TEST_CASE("TextureAtlasTiles can be used to update a texture.", "[texturing]")
364
366
}
365
367
366
368
CHECK_THAT (resize, CalledWith (size, layers, mipmap_levels));
367
- CHECK_THAT (modify, Called (tile_count));
369
+ CHECK_THAT (modify, Called (tile_count * tile_data. count () ));
368
370
369
371
std::set<std::pair<dmath::svec3, std::size_t >> positions_and_mipmap_levels;
370
372
for (const auto & [tile_data, offset, mipmap_level] : modify.invocations ()) {
0 commit comments