From 6d2257c9a67d4cd8dcf30a9636822992735054dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 16 Feb 2025 19:58:15 +0100 Subject: [PATCH] TextureTools: use a more realistic image type for atlas inputs. The views made it look like one cannot use Trade::ImageData etc. as inputs, and the reason for using them was because there was a load-bearing const in the view type that allowed slice() to work. The slice() API is fixed now so this doesn't need to be silly anymore. --- doc/snippets/TextureTools.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/doc/snippets/TextureTools.cpp b/doc/snippets/TextureTools.cpp index 6393cadb2..24ecff56d 100644 --- a/doc/snippets/TextureTools.cpp +++ b/doc/snippets/TextureTools.cpp @@ -53,13 +53,13 @@ void mainTextureTools(); void mainTextureTools() { { /* [AtlasLandfill-usage] */ -Containers::ArrayView images = DOXYGEN_ELLIPSIS({}); +Containers::Array images = DOXYGEN_ELLIPSIS({}); /* or ImageView2D, Trade::ImageData2D... */ Containers::Array offsets{NoInit, images.size()}; Containers::BitArray rotations{NoInit, images.size()}; /* Fill the atlas with an unbounded height */ TextureTools::AtlasLandfill atlas{{1024, 0}}; -atlas.add(stridedArrayView(images).slice(&ImageView2D::size), offsets, rotations); +atlas.add(stridedArrayView(images).slice(&Image2D::size), offsets, rotations); /* Copy the image data to the atlas, assuming all are RGBA8Unorm as well */ Image2D output{PixelFormat::RGBA8Unorm, atlas.filledSize().xy(), @@ -78,13 +78,13 @@ for(std::size_t i = 0; i != images.size(); ++i) { } { -Containers::ArrayView images; +Containers::Array images; Containers::Array offsets{NoInit, images.size()}; TextureTools::AtlasLandfill atlas{{1024, 0}}; /* [AtlasLandfill-usage-no-rotation] */ atlas.clearFlags(TextureTools::AtlasLandfillFlag::RotatePortrait| TextureTools::AtlasLandfillFlag::RotateLandscape) - .add(stridedArrayView(images).slice(&ImageView2D::size), offsets); + .add(stridedArrayView(images).slice(&Image2D::size), offsets); /* Copy the image data to the atlas, assuming all are RGBA8Unorm as well */ Image2D output{PixelFormat::RGBA8Unorm, atlas.filledSize().xy(), @@ -101,13 +101,13 @@ for(std::size_t i = 0; i != images.size(); ++i) { { /* [AtlasLandfill-usage-array] */ -Containers::ArrayView images = DOXYGEN_ELLIPSIS({}); +Containers::Array images = DOXYGEN_ELLIPSIS({}); Containers::Array offsets{NoInit, images.size()}; Containers::BitArray rotations{NoInit, images.size()}; /* Fill the atlas with an unbounded depth */ TextureTools::AtlasLandfill atlas{{1024, 1024, 0}}; -atlas.add(stridedArrayView(images).slice(&ImageView2D::size), offsets, rotations); +atlas.add(stridedArrayView(images).slice(&Image2D::size), offsets, rotations); /* Copy the image data to the atlas, assuming all are RGBA8Unorm as well */ Image3D output{PixelFormat::RGBA8Unorm, atlas.filledSize(), @@ -128,9 +128,9 @@ for(std::size_t i = 0; i != images.size(); ++i) { { /* [atlasArrayPowerOfTwo] */ -Containers::ArrayView input; +Containers::Array input = DOXYGEN_ELLIPSIS({}); /* or ImageView2D, Trade::ImageData2D... */ Containers::StridedArrayView1D sizes = - stridedArrayView(input).slice(&ImageView2D::size); + stridedArrayView(input).slice(&Image2D::size); Containers::Array offsets{NoInit, input.size()}; /* Size the atlas based on the largest image and fill it */