diff --git a/src/Magnum/Test/CubeMapTextureArrayGLTest.cpp b/src/Magnum/Test/CubeMapTextureArrayGLTest.cpp index a3fd3b2a1..4db779ecb 100644 --- a/src/Magnum/Test/CubeMapTextureArrayGLTest.cpp +++ b/src/Magnum/Test/CubeMapTextureArrayGLTest.cpp @@ -211,11 +211,8 @@ void CubeMapTextureArrayGLTest::storage() { MAGNUM_VERIFY_NO_ERROR(); } -void CubeMapTextureArrayGLTest::image() { - if(!Context::current()->isExtensionSupported()) - CORRADE_SKIP(Extensions::GL::ARB::texture_cube_map_array::string() + std::string(" is not supported.")); - - constexpr UnsignedByte data[] = { +namespace { + constexpr UnsignedByte Data[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, @@ -234,9 +231,15 @@ void CubeMapTextureArrayGLTest::image() { 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f }; +} + +void CubeMapTextureArrayGLTest::image() { + if(!Context::current()->isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::texture_cube_map_array::string() + std::string(" is not supported.")); + CubeMapTextureArray texture; texture.setImage(0, TextureFormat::RGBA8, - ImageReference3D(ColorFormat::RGBA, ColorType::UnsignedByte, {2, 2, 6}, data)); + ImageReference3D(ColorFormat::RGBA, ColorType::UnsignedByte, {2, 2, 6}, Data)); MAGNUM_VERIFY_NO_ERROR(); @@ -245,36 +248,18 @@ void CubeMapTextureArrayGLTest::image() { MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector3i(2, 2, 6)); - CORRADE_COMPARE_AS(std::vector(image.data(), image.data()+image.pixelSize()*image.size().product()), - std::vector(data, data + 96), TestSuite::Compare::Container); + CORRADE_COMPARE_AS( + Containers::ArrayReference(image.data(), image.pixelSize()*image.size().product()), + Containers::ArrayReference{Data}, TestSuite::Compare::Container); } void CubeMapTextureArrayGLTest::imageBuffer() { if(!Context::current()->isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_cube_map_array::string() + std::string(" is not supported.")); - constexpr UnsignedByte data[] = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, - - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, - 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, - - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x16, 0x47, - 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x1e, 0x4f, - - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, - 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f - }; CubeMapTextureArray texture; texture.setImage(0, TextureFormat::RGBA8, - BufferImage3D(ColorFormat::RGBA, ColorType::UnsignedByte, {2, 2, 6}, data, BufferUsage::StaticDraw)); + BufferImage3D(ColorFormat::RGBA, ColorType::UnsignedByte, {2, 2, 6}, Data, BufferUsage::StaticDraw)); MAGNUM_VERIFY_NO_ERROR(); @@ -284,16 +269,13 @@ void CubeMapTextureArrayGLTest::imageBuffer() { MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector3i(2, 2, 6)); - CORRADE_COMPARE_AS(std::vector(imageData.begin(), imageData.end()), - std::vector(data, data + 96), TestSuite::Compare::Container); + CORRADE_COMPARE_AS(imageData, Containers::ArrayReference{Data}, TestSuite::Compare::Container); } -void CubeMapTextureArrayGLTest::subImage() { - if(!Context::current()->isExtensionSupported()) - CORRADE_SKIP(Extensions::GL::ARB::texture_cube_map_array::string() + std::string(" is not supported.")); +namespace { + constexpr UnsignedByte Zero[4*4*4*6] = {}; - constexpr UnsignedByte zero[4*4*4*6] = {}; - constexpr UnsignedByte subData[] = { + constexpr UnsignedByte SubData[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, @@ -306,20 +288,8 @@ void CubeMapTextureArrayGLTest::subImage() { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f }; - CubeMapTextureArray texture; - texture.setImage(0, TextureFormat::RGBA8, - ImageReference3D(ColorFormat::RGBA, ColorType::UnsignedByte, {4, 4, 6}, zero)); - texture.setSubImage(0, Vector3i(1), - ImageReference3D(ColorFormat::RGBA, ColorType::UnsignedByte, {2, 2, 4}, subData)); - - MAGNUM_VERIFY_NO_ERROR(); - Image3D image = texture.image(0, {ColorFormat::RGBA, ColorType::UnsignedByte}); - - MAGNUM_VERIFY_NO_ERROR(); - - CORRADE_COMPARE(image.size(), Vector3i(4, 4, 6)); - CORRADE_COMPARE_AS(std::vector(image.data(), image.data()+image.pixelSize()*image.size().product()), (std::vector{ + constexpr UnsignedByte SubDataComplete[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -349,72 +319,50 @@ void CubeMapTextureArrayGLTest::subImage() { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }), TestSuite::Compare::Container); + }; } -void CubeMapTextureArrayGLTest::subImageBuffer() { +void CubeMapTextureArrayGLTest::subImage() { if(!Context::current()->isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_cube_map_array::string() + std::string(" is not supported.")); - constexpr UnsignedByte zero[4*4*4*6] = {}; - constexpr UnsignedByte subData[] = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, - - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, - 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, - - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f - }; CubeMapTextureArray texture; texture.setImage(0, TextureFormat::RGBA8, - ImageReference3D(ColorFormat::RGBA, ColorType::UnsignedByte, {4, 4, 6}, zero)); + ImageReference3D(ColorFormat::RGBA, ColorType::UnsignedByte, {4, 4, 6}, Zero)); texture.setSubImage(0, Vector3i(1), - BufferImage3D(ColorFormat::RGBA, ColorType::UnsignedByte, {2, 2, 4}, subData, BufferUsage::StaticDraw)); + ImageReference3D(ColorFormat::RGBA, ColorType::UnsignedByte, {2, 2, 4}, SubData)); MAGNUM_VERIFY_NO_ERROR(); - BufferImage3D image = texture.image(0, {ColorFormat::RGBA, ColorType::UnsignedByte}, BufferUsage::StaticRead); - const auto imageData = image.buffer().data(); + Image3D image = texture.image(0, {ColorFormat::RGBA, ColorType::UnsignedByte}); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector3i(4, 4, 6)); - CORRADE_COMPARE_AS(std::vector(imageData.begin(), imageData.end()), (std::vector{ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + CORRADE_COMPARE_AS( + Containers::ArrayReference(image.data(), image.pixelSize()*image.size().product()), + Containers::ArrayReference{SubDataComplete}, TestSuite::Compare::Container); +} - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0, 0, 0, 0, - 0, 0, 0, 0, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +void CubeMapTextureArrayGLTest::subImageBuffer() { + if(!Context::current()->isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::texture_cube_map_array::string() + std::string(" is not supported.")); - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0, 0, 0, 0, - 0, 0, 0, 0, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + CubeMapTextureArray texture; + texture.setImage(0, TextureFormat::RGBA8, + ImageReference3D(ColorFormat::RGBA, ColorType::UnsignedByte, {4, 4, 6}, Zero)); + texture.setSubImage(0, Vector3i(1), + BufferImage3D(ColorFormat::RGBA, ColorType::UnsignedByte, {2, 2, 4}, SubData, BufferUsage::StaticDraw)); - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0, 0, 0, 0, - 0, 0, 0, 0, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + MAGNUM_VERIFY_NO_ERROR(); - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0, 0, 0, 0, - 0, 0, 0, 0, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + BufferImage3D image = texture.image(0, {ColorFormat::RGBA, ColorType::UnsignedByte}, BufferUsage::StaticRead); + const auto imageData = image.buffer().data(); - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }), TestSuite::Compare::Container); + MAGNUM_VERIFY_NO_ERROR(); + + CORRADE_COMPARE(image.size(), Vector3i(4, 4, 6)); + CORRADE_COMPARE_AS(imageData, Containers::ArrayReference{SubDataComplete}, TestSuite::Compare::Container); } void CubeMapTextureArrayGLTest::generateMipmap() { diff --git a/src/Magnum/Test/CubeMapTextureGLTest.cpp b/src/Magnum/Test/CubeMapTextureGLTest.cpp index 01954ecb2..976316219 100644 --- a/src/Magnum/Test/CubeMapTextureGLTest.cpp +++ b/src/Magnum/Test/CubeMapTextureGLTest.cpp @@ -285,35 +285,35 @@ void CubeMapTextureGLTest::storage() { } namespace { - constexpr UnsignedByte Data[] = { 0x00, 0x01, 0x02, 0x03, - 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, - 0x0c, 0x0d, 0x0e, 0x0f, - - 0x10, 0x11, 0x12, 0x13, - 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1a, 0x1b, - 0x1c, 0x1d, 0x1e, 0x1f, - - 0x20, 0x21, 0x22, 0x23, - 0x24, 0x25, 0x26, 0x27, - 0x28, 0x29, 0x2a, 0x2b, - 0x2c, 0x2d, 0x2e, 0x2f, - - 0x30, 0x31, 0x32, 0x33, - 0x34, 0x35, 0x36, 0x37, - 0x38, 0x39, 0x3a, 0x3b, - 0x3c, 0x3d, 0x3e, 0x3f, - - 0x40, 0x41, 0x42, 0x43, - 0x44, 0x45, 0x46, 0x47, - 0x48, 0x49, 0x4a, 0x4b, - 0x4c, 0x4d, 0x4e, 0x4f, - - 0x50, 0x51, 0x52, 0x53, - 0x54, 0x55, 0x56, 0x57, - 0x58, 0x59, 0x5a, 0x5b, - 0x5c, 0x5d, 0x5e, 0x5f }; + constexpr UnsignedByte DataFull[] = { 0x00, 0x01, 0x02, 0x03, + 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, + 0x0c, 0x0d, 0x0e, 0x0f, + + 0x10, 0x11, 0x12, 0x13, + 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, + 0x1c, 0x1d, 0x1e, 0x1f, + + 0x20, 0x21, 0x22, 0x23, + 0x24, 0x25, 0x26, 0x27, + 0x28, 0x29, 0x2a, 0x2b, + 0x2c, 0x2d, 0x2e, 0x2f, + + 0x30, 0x31, 0x32, 0x33, + 0x34, 0x35, 0x36, 0x37, + 0x38, 0x39, 0x3a, 0x3b, + 0x3c, 0x3d, 0x3e, 0x3f, + + 0x40, 0x41, 0x42, 0x43, + 0x44, 0x45, 0x46, 0x47, + 0x48, 0x49, 0x4a, 0x4b, + 0x4c, 0x4d, 0x4e, 0x4f, + + 0x50, 0x51, 0x52, 0x53, + 0x54, 0x55, 0x56, 0x57, + 0x58, 0x59, 0x5a, 0x5b, + 0x5c, 0x5d, 0x5e, 0x5f }; } #ifndef MAGNUM_TARGET_GLES @@ -323,7 +323,7 @@ void CubeMapTextureGLTest::imageFull() { CubeMapTexture texture; texture.setStorage(1, TextureFormat::RGBA8, Vector2i{2, 2}) - .setSubImage(0, {}, ImageReference3D{ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i{2, 2, 6}, Data}); + .setSubImage(0, {}, ImageReference3D{ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i{2, 2, 6}, DataFull}); MAGNUM_VERIFY_NO_ERROR(); @@ -332,8 +332,9 @@ void CubeMapTextureGLTest::imageFull() { MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector3i(2, 2, 6)); - CORRADE_COMPARE_AS(std::vector(image.data(), image.data()+image.pixelSize()*image.size().product()), - std::vector(Data, Data+96), TestSuite::Compare::Container); + CORRADE_COMPARE_AS( + Containers::ArrayReference(image.data(), image.pixelSize()*image.size().product()), + Containers::ArrayReference{DataFull}, TestSuite::Compare::Container); } void CubeMapTextureGLTest::imageFullBuffer() { @@ -342,7 +343,7 @@ void CubeMapTextureGLTest::imageFullBuffer() { CubeMapTexture texture; texture.setStorage(1, TextureFormat::RGBA8, Vector2i{2}) - .setSubImage(0, {}, BufferImage3D{ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i{2, 2, 6}, Data, BufferUsage::StaticDraw}); + .setSubImage(0, {}, BufferImage3D{ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i{2, 2, 6}, DataFull, BufferUsage::StaticDraw}); MAGNUM_VERIFY_NO_ERROR(); @@ -352,19 +353,21 @@ void CubeMapTextureGLTest::imageFullBuffer() { CORRADE_COMPARE(image.size(), Vector3i(2, 2, 6)); const auto imageData = image.buffer().data(); - CORRADE_COMPARE_AS(std::vector(imageData.begin(), imageData.end()), - std::vector(Data, Data+96), TestSuite::Compare::Container); + CORRADE_COMPARE_AS(imageData, Containers::ArrayReference{DataFull}, TestSuite::Compare::Container); } #endif -void CubeMapTextureGLTest::image() { - constexpr UnsignedByte data[] = { 0x00, 0x01, 0x02, 0x03, +namespace { + constexpr UnsignedByte Data[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }; +} + +void CubeMapTextureGLTest::image() { CubeMapTexture texture; texture.setImage(CubeMapTexture::Coordinate::PositiveX, 0, TextureFormat::RGBA8, - ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), data)); + ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data)); MAGNUM_VERIFY_NO_ERROR(); @@ -375,20 +378,17 @@ void CubeMapTextureGLTest::image() { MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector2i(2)); - CORRADE_COMPARE_AS(std::vector(image.data(), image.data()+image.pixelSize()*image.size().product()), - std::vector(data, data+16), TestSuite::Compare::Container); + CORRADE_COMPARE_AS( + Containers::ArrayReference(image.data(), image.pixelSize()*image.size().product()), + Containers::ArrayReference{Data}, TestSuite::Compare::Container); #endif } #ifndef MAGNUM_TARGET_GLES2 void CubeMapTextureGLTest::imageBuffer() { - constexpr UnsignedByte data[] = { 0x00, 0x01, 0x02, 0x03, - 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, - 0x0c, 0x0d, 0x0e, 0x0f }; CubeMapTexture texture; texture.setImage(CubeMapTexture::Coordinate::PositiveX, 0, TextureFormat::RGBA8, - BufferImage2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), data, BufferUsage::StaticDraw)); + BufferImage2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data, BufferUsage::StaticDraw)); MAGNUM_VERIFY_NO_ERROR(); @@ -400,23 +400,27 @@ void CubeMapTextureGLTest::imageBuffer() { MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector2i(2)); - CORRADE_COMPARE_AS(std::vector(imageData.begin(), imageData.end()), - std::vector(data, data+16), TestSuite::Compare::Container); + CORRADE_COMPARE_AS(imageData, Containers::ArrayReference{Data}, TestSuite::Compare::Container); #endif } #endif +namespace { + constexpr UnsignedByte Zero[4*4*4] = {}; + constexpr UnsignedByte SubDataComplete[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0, 0, 0, 0, + 0, 0, 0, 0, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + }; +} + void CubeMapTextureGLTest::subImage() { - constexpr UnsignedByte zero[4*4*4] = {}; - constexpr UnsignedByte subData[] = { 0x00, 0x01, 0x02, 0x03, - 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, - 0x0c, 0x0d, 0x0e, 0x0f }; CubeMapTexture texture; texture.setImage(CubeMapTexture::Coordinate::PositiveX, 0, TextureFormat::RGBA8, - ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(4), zero)); + ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(4), Zero)); texture.setSubImage(CubeMapTexture::Coordinate::PositiveX, 0, Vector2i(1), - ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), subData)); + ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data)); MAGNUM_VERIFY_NO_ERROR(); @@ -427,27 +431,19 @@ void CubeMapTextureGLTest::subImage() { MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector2i(4)); - CORRADE_COMPARE_AS(std::vector(image.data(), image.data()+image.pixelSize()*image.size().product()), (std::vector{ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0, 0, 0, 0, - 0, 0, 0, 0, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }), TestSuite::Compare::Container); + CORRADE_COMPARE_AS( + Containers::ArrayReference(image.data(), image.pixelSize()*image.size().product()), + Containers::ArrayReference{SubDataComplete}, TestSuite::Compare::Container); #endif } #ifndef MAGNUM_TARGET_GLES2 void CubeMapTextureGLTest::subImageBuffer() { - constexpr UnsignedByte zero[4*4*4] = {}; - constexpr UnsignedByte subData[] = { 0x00, 0x01, 0x02, 0x03, - 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, - 0x0c, 0x0d, 0x0e, 0x0f }; CubeMapTexture texture; texture.setImage(CubeMapTexture::Coordinate::PositiveX, 0, TextureFormat::RGBA8, - ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(4), zero)); + ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(4), Zero)); texture.setSubImage(CubeMapTexture::Coordinate::PositiveX, 0, Vector2i(1), - BufferImage2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), subData, BufferUsage::StaticDraw)); + BufferImage2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data, BufferUsage::StaticDraw)); MAGNUM_VERIFY_NO_ERROR(); @@ -459,12 +455,7 @@ void CubeMapTextureGLTest::subImageBuffer() { MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector2i(4)); - CORRADE_COMPARE_AS(std::vector(imageData.begin(), imageData.end()), (std::vector{ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0, 0, 0, 0, - 0, 0, 0, 0, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }), TestSuite::Compare::Container); + CORRADE_COMPARE_AS(imageData, Containers::ArrayReference{SubDataComplete}, TestSuite::Compare::Container); #endif } #endif diff --git a/src/Magnum/Test/RectangleTextureGLTest.cpp b/src/Magnum/Test/RectangleTextureGLTest.cpp index e6ff80521..e636fce4b 100644 --- a/src/Magnum/Test/RectangleTextureGLTest.cpp +++ b/src/Magnum/Test/RectangleTextureGLTest.cpp @@ -199,17 +199,20 @@ void RectangleTextureGLTest::storage() { MAGNUM_VERIFY_NO_ERROR(); } +namespace { + constexpr UnsignedByte Data[] = { 0x00, 0x01, 0x02, 0x03, + 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, + 0x0c, 0x0d, 0x0e, 0x0f }; +} + void RectangleTextureGLTest::image() { if(!Context::current()->isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported.")); - constexpr UnsignedByte data[] = { 0x00, 0x01, 0x02, 0x03, - 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, - 0x0c, 0x0d, 0x0e, 0x0f }; RectangleTexture texture; texture.setImage(TextureFormat::RGBA8, - ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), data)); + ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data)); MAGNUM_VERIFY_NO_ERROR(); @@ -218,21 +221,18 @@ void RectangleTextureGLTest::image() { MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector2i(2)); - CORRADE_COMPARE_AS(std::vector(image.data(), image.data()+image.pixelSize()*image.size().product()), - std::vector(data, data + 16), TestSuite::Compare::Container); + CORRADE_COMPARE_AS( + Containers::ArrayReference(image.data(), image.pixelSize()*image.size().product()), + Containers::ArrayReference{Data}, TestSuite::Compare::Container); } void RectangleTextureGLTest::imageBuffer() { if(!Context::current()->isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported.")); - constexpr UnsignedByte data[] = { 0x00, 0x01, 0x02, 0x03, - 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, - 0x0c, 0x0d, 0x0e, 0x0f }; RectangleTexture texture; texture.setImage(TextureFormat::RGBA8, - BufferImage2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), data, BufferUsage::StaticDraw)); + BufferImage2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data, BufferUsage::StaticDraw)); MAGNUM_VERIFY_NO_ERROR(); @@ -242,24 +242,29 @@ void RectangleTextureGLTest::imageBuffer() { MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector2i(2)); - CORRADE_COMPARE_AS(std::vector(imageData.begin(), imageData.end()), - std::vector(data, data+16), TestSuite::Compare::Container); + CORRADE_COMPARE_AS(imageData, Containers::ArrayReference{Data}, TestSuite::Compare::Container); +} + +namespace { + constexpr UnsignedByte Zero[4*4*4] = {}; + + constexpr UnsignedByte SubDataComplete[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0, 0, 0, 0, + 0, 0, 0, 0, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + }; } void RectangleTextureGLTest::subImage() { if(!Context::current()->isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported.")); - constexpr UnsignedByte zero[4*4*4] = {}; - constexpr UnsignedByte subData[] = { 0x00, 0x01, 0x02, 0x03, - 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, - 0x0c, 0x0d, 0x0e, 0x0f }; RectangleTexture texture; texture.setImage(TextureFormat::RGBA8, - ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(4), zero)); + ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(4), Zero)); texture.setSubImage(Vector2i(1), - ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), subData)); + ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data)); MAGNUM_VERIFY_NO_ERROR(); @@ -268,28 +273,20 @@ void RectangleTextureGLTest::subImage() { MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector2i(4)); - CORRADE_COMPARE_AS(std::vector(image.data(), image.data()+image.pixelSize()*image.size().product()), (std::vector{ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0, 0, 0, 0, - 0, 0, 0, 0, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }), TestSuite::Compare::Container); + CORRADE_COMPARE_AS( + Containers::ArrayReference(image.data(), image.pixelSize()*image.size().product()), + Containers::ArrayReference{SubDataComplete}, TestSuite::Compare::Container); } void RectangleTextureGLTest::subImageBuffer() { if(!Context::current()->isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported.")); - constexpr UnsignedByte zero[4*4*4] = {}; - constexpr UnsignedByte subData[] = { 0x00, 0x01, 0x02, 0x03, - 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, - 0x0c, 0x0d, 0x0e, 0x0f }; RectangleTexture texture; texture.setImage(TextureFormat::RGBA8, - ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(4), zero)); + ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(4), Zero)); texture.setSubImage(Vector2i(1), - BufferImage2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), subData, BufferUsage::StaticDraw)); + BufferImage2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data, BufferUsage::StaticDraw)); MAGNUM_VERIFY_NO_ERROR(); @@ -299,12 +296,7 @@ void RectangleTextureGLTest::subImageBuffer() { MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector2i(4)); - CORRADE_COMPARE_AS(std::vector(imageData.begin(), imageData.end()), (std::vector{ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0, 0, 0, 0, - 0, 0, 0, 0, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }), TestSuite::Compare::Container); + CORRADE_COMPARE_AS(imageData, Containers::ArrayReference{SubDataComplete}, TestSuite::Compare::Container); } void RectangleTextureGLTest::invalidateImage() { diff --git a/src/Magnum/Test/TextureArrayGLTest.cpp b/src/Magnum/Test/TextureArrayGLTest.cpp index 7e92f64cd..b1cc7566c 100644 --- a/src/Magnum/Test/TextureArrayGLTest.cpp +++ b/src/Magnum/Test/TextureArrayGLTest.cpp @@ -534,18 +534,21 @@ void TextureArrayGLTest::storage2D() { #endif } +namespace { + constexpr UnsignedByte Data1D[] = { 0x00, 0x01, 0x02, 0x03, + 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, + 0x0c, 0x0d, 0x0e, 0x0f }; +} + #ifndef MAGNUM_TARGET_GLES void TextureArrayGLTest::image1D() { if(!Context::current()->isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); - constexpr UnsignedByte data[] = { 0x00, 0x01, 0x02, 0x03, - 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, - 0x0c, 0x0d, 0x0e, 0x0f }; Texture1DArray texture; texture.setImage(0, TextureFormat::RGBA8, - ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), data)); + ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data1D)); MAGNUM_VERIFY_NO_ERROR(); @@ -554,21 +557,18 @@ void TextureArrayGLTest::image1D() { MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector2i(2)); - CORRADE_COMPARE_AS(std::vector(image.data(), image.data()+image.pixelSize()*image.size().product()), - std::vector(data, data + 16), TestSuite::Compare::Container); + CORRADE_COMPARE_AS( + Containers::ArrayReference(image.data(), image.pixelSize()*image.size().product()), + Containers::ArrayReference{Data1D}, TestSuite::Compare::Container); } void TextureArrayGLTest::image1DBuffer() { if(!Context::current()->isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); - constexpr UnsignedByte data[] = { 0x00, 0x01, 0x02, 0x03, - 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, - 0x0c, 0x0d, 0x0e, 0x0f }; Texture1DArray texture; texture.setImage(0, TextureFormat::RGBA8, - BufferImage2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), data, BufferUsage::StaticDraw)); + BufferImage2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data1D, BufferUsage::StaticDraw)); MAGNUM_VERIFY_NO_ERROR(); @@ -578,28 +578,30 @@ void TextureArrayGLTest::image1DBuffer() { MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector2i(2)); - CORRADE_COMPARE_AS(std::vector(imageData.begin(), imageData.end()), - std::vector(data, data + 16), TestSuite::Compare::Container); + CORRADE_COMPARE_AS(imageData, Containers::ArrayReference{Data1D}, TestSuite::Compare::Container); } #endif +namespace { + constexpr UnsignedByte Data2D[] = { 0x00, 0x01, 0x02, 0x03, + 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, + 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, + 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, + 0x1c, 0x1d, 0x1e, 0x1f }; +} + void TextureArrayGLTest::image2D() { #ifndef MAGNUM_TARGET_GLES if(!Context::current()->isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); #endif - constexpr UnsignedByte data[] = { 0x00, 0x01, 0x02, 0x03, - 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, - 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13, - 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1a, 0x1b, - 0x1c, 0x1d, 0x1e, 0x1f }; Texture2DArray texture; texture.setImage(0, TextureFormat::RGBA8, - ImageReference3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(2), data)); + ImageReference3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(2), Data2D)); MAGNUM_VERIFY_NO_ERROR(); @@ -610,8 +612,9 @@ void TextureArrayGLTest::image2D() { MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector3i(2)); - CORRADE_COMPARE_AS(std::vector(image.data(), image.data()+image.pixelSize()*image.size().product()), - std::vector(data, data + 32), TestSuite::Compare::Container); + CORRADE_COMPARE_AS( + Containers::ArrayReference(image.data(), image.pixelSize()*image.size().product()), + Containers::ArrayReference{Data2D}, TestSuite::Compare::Container); #endif } @@ -621,17 +624,9 @@ void TextureArrayGLTest::image2DBuffer() { CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); #endif - constexpr UnsignedByte data[] = { 0x00, 0x01, 0x02, 0x03, - 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, - 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13, - 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1a, 0x1b, - 0x1c, 0x1d, 0x1e, 0x1f }; Texture2DArray texture; texture.setImage(0, TextureFormat::RGBA8, - BufferImage3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(2), data, BufferUsage::StaticDraw)); + BufferImage3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(2), Data2D, BufferUsage::StaticDraw)); MAGNUM_VERIFY_NO_ERROR(); @@ -643,26 +638,34 @@ void TextureArrayGLTest::image2DBuffer() { MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector3i(2)); - CORRADE_COMPARE_AS(std::vector(imageData.begin(), imageData.end()), - std::vector(data, data + 32), TestSuite::Compare::Container); + CORRADE_COMPARE_AS(imageData, Containers::ArrayReference{Data2D}, TestSuite::Compare::Container); #endif } +namespace { + constexpr UnsignedByte Zero1D[4*4*4] = {}; + constexpr UnsignedByte SubData1D[] = { 0x00, 0x01, 0x02, 0x03, + 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, + 0x0c, 0x0d, 0x0e, 0x0f }; + constexpr UnsignedByte SubData1DComplete[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0, 0, 0, 0, + 0, 0, 0, 0, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + }; +} + #ifndef MAGNUM_TARGET_GLES void TextureArrayGLTest::subImage1D() { if(!Context::current()->isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); - constexpr UnsignedByte zero[4*4*4] = {}; - constexpr UnsignedByte subData[] = { 0x00, 0x01, 0x02, 0x03, - 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, - 0x0c, 0x0d, 0x0e, 0x0f }; Texture1DArray texture; texture.setImage(0, TextureFormat::RGBA8, - ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(4), zero)); + ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(4), Zero1D)); texture.setSubImage(0, Vector2i(1), - ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), subData)); + ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), SubData1D)); MAGNUM_VERIFY_NO_ERROR(); @@ -671,28 +674,20 @@ void TextureArrayGLTest::subImage1D() { MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector2i(4)); - CORRADE_COMPARE_AS(std::vector(image.data(), image.data()+image.pixelSize()*image.size().product()), (std::vector{ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0, 0, 0, 0, - 0, 0, 0, 0, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }), TestSuite::Compare::Container); + CORRADE_COMPARE_AS( + Containers::ArrayReference(image.data(), image.pixelSize()*image.size().product()), + Containers::ArrayReference{SubData1DComplete}, TestSuite::Compare::Container); } void TextureArrayGLTest::subImage1DBuffer() { if(!Context::current()->isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); - constexpr UnsignedByte zero[4*4*4] = {}; - constexpr UnsignedByte subData[] = { 0x00, 0x01, 0x02, 0x03, - 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, - 0x0c, 0x0d, 0x0e, 0x0f }; Texture1DArray texture; texture.setImage(0, TextureFormat::RGBA8, - ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(4), zero)); + ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(4), Zero1D)); texture.setSubImage(0, Vector2i(1), - BufferImage2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), subData, BufferUsage::StaticDraw)); + BufferImage2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), SubData1D, BufferUsage::StaticDraw)); MAGNUM_VERIFY_NO_ERROR(); @@ -702,14 +697,42 @@ void TextureArrayGLTest::subImage1DBuffer() { MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector2i(4)); - CORRADE_COMPARE_AS(std::vector(imageData.begin(), imageData.end()), (std::vector{ + CORRADE_COMPARE_AS(imageData, Containers::ArrayReference{SubData1DComplete}, TestSuite::Compare::Container); +} +#endif + +namespace { + constexpr UnsignedByte Zero2D[4*4*4*4] = {}; + constexpr UnsignedByte SubData2D[] = { 0x00, 0x01, 0x02, 0x03, + 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, + 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, + 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, + 0x1c, 0x1d, 0x1e, 0x1f }; + constexpr UnsignedByte SubData2DComplete[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0, 0, 0, 0, 0, 0, 0, 0, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0, 0, 0, 0, + 0, 0, 0, 0, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }), TestSuite::Compare::Container); + }; } -#endif void TextureArrayGLTest::subImage2D() { #ifndef MAGNUM_TARGET_GLES @@ -717,20 +740,11 @@ void TextureArrayGLTest::subImage2D() { CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); #endif - constexpr UnsignedByte zero[4*4*4*4] = {}; - constexpr UnsignedByte subData[] = { 0x00, 0x01, 0x02, 0x03, - 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, - 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13, - 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1a, 0x1b, - 0x1c, 0x1d, 0x1e, 0x1f }; Texture2DArray texture; texture.setImage(0, TextureFormat::RGBA8, - ImageReference3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(4), zero)); + ImageReference3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(4), Zero2D)); texture.setSubImage(0, Vector3i(1), - ImageReference3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(2), subData)); + ImageReference3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(2), SubData2D)); MAGNUM_VERIFY_NO_ERROR(); @@ -741,27 +755,8 @@ void TextureArrayGLTest::subImage2D() { MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector3i(4)); - CORRADE_COMPARE_AS(std::vector(image.data(), image.data()+image.pixelSize()*image.size().product()), (std::vector{ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0, 0, 0, 0, - 0, 0, 0, 0, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0, 0, 0, 0, - 0, 0, 0, 0, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }), TestSuite::Compare::Container); + CORRADE_COMPARE_AS( + Containers::ArrayReference(image.data(), image.pixelSize()*image.size().product()), Containers::ArrayReference{SubData2DComplete}, TestSuite::Compare::Container); #endif } @@ -771,20 +766,11 @@ void TextureArrayGLTest::subImage2DBuffer() { CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); #endif - constexpr UnsignedByte zero[4*4*4*4] = {}; - constexpr UnsignedByte subData[] = { 0x00, 0x01, 0x02, 0x03, - 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, - 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13, - 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1a, 0x1b, - 0x1c, 0x1d, 0x1e, 0x1f }; Texture2DArray texture; texture.setImage(0, TextureFormat::RGBA8, - ImageReference3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(4), zero)); + ImageReference3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(4), Zero2D)); texture.setSubImage(0, Vector3i(1), - BufferImage3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(2), subData, BufferUsage::StaticDraw)); + BufferImage3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(2), SubData2D, BufferUsage::StaticDraw)); MAGNUM_VERIFY_NO_ERROR(); @@ -796,27 +782,7 @@ void TextureArrayGLTest::subImage2DBuffer() { MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector3i(4)); - CORRADE_COMPARE_AS(std::vector(imageData.begin(), imageData.end()), (std::vector{ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0, 0, 0, 0, - 0, 0, 0, 0, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0, 0, 0, 0, - 0, 0, 0, 0, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }), TestSuite::Compare::Container); + CORRADE_COMPARE_AS(imageData, Containers::ArrayReference{SubData2DComplete}, TestSuite::Compare::Container); #endif } diff --git a/src/Magnum/Test/TextureGLTest.cpp b/src/Magnum/Test/TextureGLTest.cpp index 790a403ce..1a603f8d1 100644 --- a/src/Magnum/Test/TextureGLTest.cpp +++ b/src/Magnum/Test/TextureGLTest.cpp @@ -714,13 +714,16 @@ void TextureGLTest::storage3D() { #endif } +namespace { + constexpr UnsignedByte Data1D[] = { 0x00, 0x01, 0x02, 0x03, + 0x04, 0x05, 0x06, 0x07 }; +} + #ifndef MAGNUM_TARGET_GLES void TextureGLTest::image1D() { - constexpr UnsignedByte data[] = { 0x00, 0x01, 0x02, 0x03, - 0x04, 0x05, 0x06, 0x07 }; Texture1D texture; texture.setImage(0, TextureFormat::RGBA8, - ImageReference1D(ColorFormat::RGBA, ColorType::UnsignedByte, 2, data)); + ImageReference1D(ColorFormat::RGBA, ColorType::UnsignedByte, 2, Data1D)); MAGNUM_VERIFY_NO_ERROR(); @@ -729,16 +732,15 @@ void TextureGLTest::image1D() { MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), 2); - CORRADE_COMPARE_AS(std::vector(image.data(), image.data()+image.pixelSize()*image.size().product()), - std::vector(data, data + 8), TestSuite::Compare::Container); + CORRADE_COMPARE_AS( + Containers::ArrayReference(image.data(), image.pixelSize()*image.size().product()), + Containers::ArrayReference{Data1D}, TestSuite::Compare::Container); } void TextureGLTest::image1DBuffer() { - constexpr UnsignedByte data[] = { 0x00, 0x01, 0x02, 0x03, - 0x04, 0x05, 0x06, 0x07 }; Texture1D texture; texture.setImage(0, TextureFormat::RGBA8, - BufferImage1D(ColorFormat::RGBA, ColorType::UnsignedByte, 2, data, BufferUsage::StaticDraw)); + BufferImage1D(ColorFormat::RGBA, ColorType::UnsignedByte, 2, Data1D, BufferUsage::StaticDraw)); MAGNUM_VERIFY_NO_ERROR(); @@ -748,19 +750,21 @@ void TextureGLTest::image1DBuffer() { MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), 2); - CORRADE_COMPARE_AS(std::vector(imageData.begin(), imageData.end()), - std::vector(data, data + 8), TestSuite::Compare::Container); + CORRADE_COMPARE_AS(imageData, Containers::ArrayReference{Data1D}, TestSuite::Compare::Container); } #endif +namespace { + constexpr UnsignedByte Data2D[] = { 0x00, 0x01, 0x02, 0x03, + 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, + 0x0c, 0x0d, 0x0e, 0x0f }; +} + void TextureGLTest::image2D() { - constexpr UnsignedByte data[] = { 0x00, 0x01, 0x02, 0x03, - 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, - 0x0c, 0x0d, 0x0e, 0x0f }; Texture2D texture; texture.setImage(0, TextureFormat::RGBA8, - ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), data)); + ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data2D)); MAGNUM_VERIFY_NO_ERROR(); @@ -771,20 +775,17 @@ void TextureGLTest::image2D() { MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector2i(2)); - CORRADE_COMPARE_AS(std::vector(image.data(), image.data()+image.pixelSize()*image.size().product()), - std::vector(data, data + 16), TestSuite::Compare::Container); + CORRADE_COMPARE_AS( + Containers::ArrayReference(image.data(), image.pixelSize()*image.size().product()), + Containers::ArrayReference{Data2D}, TestSuite::Compare::Container); #endif } #ifndef MAGNUM_TARGET_GLES2 void TextureGLTest::image2DBuffer() { - constexpr UnsignedByte data[] = { 0x00, 0x01, 0x02, 0x03, - 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, - 0x0c, 0x0d, 0x0e, 0x0f }; Texture2D texture; texture.setImage(0, TextureFormat::RGBA8, - BufferImage2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), data, BufferUsage::StaticDraw)); + BufferImage2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data2D, BufferUsage::StaticDraw)); MAGNUM_VERIFY_NO_ERROR(); @@ -796,29 +797,31 @@ void TextureGLTest::image2DBuffer() { MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector2i(2)); - CORRADE_COMPARE_AS(std::vector(imageData.begin(), imageData.end()), - std::vector(data, data + 16), TestSuite::Compare::Container); + CORRADE_COMPARE_AS(imageData, Containers::ArrayReference{Data2D}, TestSuite::Compare::Container); #endif } #endif +namespace { + constexpr UnsignedByte Data3D[] = { 0x00, 0x01, 0x02, 0x03, + 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, + 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, + 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, + 0x1c, 0x1d, 0x1e, 0x1f }; +} + void TextureGLTest::image3D() { #ifdef MAGNUM_TARGET_GLES2 if(!Context::current()->isExtensionSupported()) CORRADE_SKIP(Extensions::GL::OES::texture_3D::string() + std::string(" is not supported.")); #endif - constexpr UnsignedByte data[] = { 0x00, 0x01, 0x02, 0x03, - 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, - 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13, - 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1a, 0x1b, - 0x1c, 0x1d, 0x1e, 0x1f }; Texture3D texture; texture.setImage(0, TextureFormat::RGBA8, - ImageReference3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(2), data)); + ImageReference3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(2), Data3D)); MAGNUM_VERIFY_NO_ERROR(); @@ -829,24 +832,17 @@ void TextureGLTest::image3D() { MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector3i(2)); - CORRADE_COMPARE_AS(std::vector(image.data(), image.data()+image.pixelSize()*image.size().product()), - std::vector(data, data + 32), TestSuite::Compare::Container); + CORRADE_COMPARE_AS( + Containers::ArrayReference(image.data(), image.pixelSize()*image.size().product()), + Containers::ArrayReference{Data3D}, TestSuite::Compare::Container); #endif } #ifndef MAGNUM_TARGET_GLES2 void TextureGLTest::image3DBuffer() { - constexpr UnsignedByte data[] = { 0x00, 0x01, 0x02, 0x03, - 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, - 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13, - 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1a, 0x1b, - 0x1c, 0x1d, 0x1e, 0x1f }; Texture3D texture; texture.setImage(0, TextureFormat::RGBA8, - BufferImage3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(2), data, BufferUsage::StaticDraw)); + BufferImage3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(2), Data3D, BufferUsage::StaticDraw)); MAGNUM_VERIFY_NO_ERROR(); @@ -858,22 +854,25 @@ void TextureGLTest::image3DBuffer() { MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector3i(2)); - CORRADE_COMPARE_AS(std::vector(imageData.begin(), imageData.end()), - std::vector(data, data + 32), TestSuite::Compare::Container); + CORRADE_COMPARE_AS(imageData, Containers::ArrayReference{Data3D}, TestSuite::Compare::Container); #endif } #endif +namespace { + constexpr UnsignedByte Zero1D[4*4] = {}; + constexpr UnsignedByte SubData1DComplete[] = { + 0, 0, 0, 0, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0, 0, 0, 0 + }; +} + #ifndef MAGNUM_TARGET_GLES void TextureGLTest::subImage1D() { - constexpr UnsignedByte zero[4*4] = {}; - constexpr UnsignedByte subData[] = { 0x00, 0x01, 0x02, 0x03, - 0x04, 0x05, 0x06, 0x07 }; Texture1D texture; texture.setImage(0, TextureFormat::RGBA8, - ImageReference1D(ColorFormat::RGBA, ColorType::UnsignedByte, 4, zero)); + ImageReference1D(ColorFormat::RGBA, ColorType::UnsignedByte, 4, Zero1D)); texture.setSubImage(0, 1, - ImageReference1D(ColorFormat::RGBA, ColorType::UnsignedByte, 2, subData)); + ImageReference1D(ColorFormat::RGBA, ColorType::UnsignedByte, 2, Data1D)); MAGNUM_VERIFY_NO_ERROR(); @@ -882,20 +881,17 @@ void TextureGLTest::subImage1D() { MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), 4); - CORRADE_COMPARE_AS(std::vector(image.data(), image.data()+image.pixelSize()*image.size().product()), (std::vector{ - 0, 0, 0, 0, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0, 0, 0, 0 - }), TestSuite::Compare::Container); + CORRADE_COMPARE_AS( + Containers::ArrayReference(image.data(), image.pixelSize()*image.size().product()), + Containers::ArrayReference{SubData1DComplete}, TestSuite::Compare::Container); } void TextureGLTest::subImage1DBuffer() { - constexpr UnsignedByte zero[4*4] = {}; - constexpr UnsignedByte subData[] = { 0x00, 0x01, 0x02, 0x03, - 0x04, 0x05, 0x06, 0x07 }; Texture1D texture; texture.setImage(0, TextureFormat::RGBA8, - ImageReference1D(ColorFormat::RGBA, ColorType::UnsignedByte, 4, zero)); + ImageReference1D(ColorFormat::RGBA, ColorType::UnsignedByte, 4, Zero1D)); texture.setSubImage(0, 1, - BufferImage1D(ColorFormat::RGBA, ColorType::UnsignedByte, 2, subData, BufferUsage::StaticDraw)); + BufferImage1D(ColorFormat::RGBA, ColorType::UnsignedByte, 2, Data1D, BufferUsage::StaticDraw)); MAGNUM_VERIFY_NO_ERROR(); @@ -905,23 +901,26 @@ void TextureGLTest::subImage1DBuffer() { MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), 4); - CORRADE_COMPARE_AS(std::vector(imageData.begin(), imageData.end()), (std::vector{ - 0, 0, 0, 0, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0, 0, 0, 0 - }), TestSuite::Compare::Container); + CORRADE_COMPARE_AS(imageData, Containers::ArrayReference{SubData1DComplete}, TestSuite::Compare::Container); } #endif +namespace { + constexpr UnsignedByte Zero2D[4*4*4] = {}; + constexpr UnsignedByte SubData2DComplete[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0, 0, 0, 0, + 0, 0, 0, 0, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + }; +} + void TextureGLTest::subImage2D() { - constexpr UnsignedByte zero[4*4*4] = {}; - constexpr UnsignedByte subData[] = { 0x00, 0x01, 0x02, 0x03, - 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, - 0x0c, 0x0d, 0x0e, 0x0f }; Texture2D texture; texture.setImage(0, TextureFormat::RGBA8, - ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(4), zero)); + ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(4), Zero2D)); texture.setSubImage(0, Vector2i(1), - ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), subData)); + ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data2D)); MAGNUM_VERIFY_NO_ERROR(); @@ -932,27 +931,19 @@ void TextureGLTest::subImage2D() { MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector2i(4)); - CORRADE_COMPARE_AS(std::vector(image.data(), image.data()+image.pixelSize()*image.size().product()), (std::vector{ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0, 0, 0, 0, - 0, 0, 0, 0, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }), TestSuite::Compare::Container); + CORRADE_COMPARE_AS( + Containers::ArrayReference(image.data(), image.pixelSize()*image.size().product()), + Containers::ArrayReference{SubData2DComplete}, TestSuite::Compare::Container); #endif } #ifndef MAGNUM_TARGET_GLES2 void TextureGLTest::subImage2DBuffer() { - constexpr UnsignedByte zero[4*4*4] = {}; - constexpr UnsignedByte subData[] = { 0x00, 0x01, 0x02, 0x03, - 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, - 0x0c, 0x0d, 0x0e, 0x0f }; Texture2D texture; texture.setImage(0, TextureFormat::RGBA8, - ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(4), zero)); + ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(4), Zero2D)); texture.setSubImage(0, Vector2i(1), - BufferImage2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), subData, BufferUsage::StaticDraw)); + BufferImage2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data2D, BufferUsage::StaticDraw)); MAGNUM_VERIFY_NO_ERROR(); @@ -964,15 +955,35 @@ void TextureGLTest::subImage2DBuffer() { MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector2i(4)); - CORRADE_COMPARE_AS(std::vector(imageData.begin(), imageData.end()), (std::vector{ + CORRADE_COMPARE_AS(imageData, Containers::ArrayReference{SubData2DComplete}, TestSuite::Compare::Container); + #endif +} +#endif + +namespace { + constexpr UnsignedByte Zero3D[4*4*4*4] = {}; + constexpr UnsignedByte SubData3DComplete[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0, 0, 0, 0, 0, 0, 0, 0, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0, 0, 0, 0, + 0, 0, 0, 0, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }), TestSuite::Compare::Container); - #endif + }; } -#endif void TextureGLTest::subImage3D() { #ifdef MAGNUM_TARGET_GLES2 @@ -980,20 +991,11 @@ void TextureGLTest::subImage3D() { CORRADE_SKIP(Extensions::GL::OES::texture_3D::string() + std::string(" is not supported.")); #endif - constexpr UnsignedByte zero[4*4*4*4] = {}; - constexpr UnsignedByte subData[] = { 0x00, 0x01, 0x02, 0x03, - 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, - 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13, - 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1a, 0x1b, - 0x1c, 0x1d, 0x1e, 0x1f }; Texture3D texture; texture.setImage(0, TextureFormat::RGBA8, - ImageReference3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(4), zero)); + ImageReference3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(4), Zero3D)); texture.setSubImage(0, Vector3i(1), - ImageReference3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(2), subData)); + ImageReference3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(2), Data3D)); MAGNUM_VERIFY_NO_ERROR(); @@ -1004,46 +1006,19 @@ void TextureGLTest::subImage3D() { MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector3i(4)); - CORRADE_COMPARE_AS(std::vector(image.data(), image.data()+image.pixelSize()*image.size().product()), (std::vector{ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0, 0, 0, 0, - 0, 0, 0, 0, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0, 0, 0, 0, - 0, 0, 0, 0, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }), TestSuite::Compare::Container); + CORRADE_COMPARE_AS( + Containers::ArrayReference(image.data(), image.pixelSize()*image.size().product()), + Containers::ArrayReference{SubData3DComplete}, TestSuite::Compare::Container); #endif } #ifndef MAGNUM_TARGET_GLES2 void TextureGLTest::subImage3DBuffer() { - constexpr UnsignedByte zero[4*4*4*4] = {}; - constexpr UnsignedByte subData[] = { 0x00, 0x01, 0x02, 0x03, - 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, - 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13, - 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1a, 0x1b, - 0x1c, 0x1d, 0x1e, 0x1f }; Texture3D texture; texture.setImage(0, TextureFormat::RGBA8, - ImageReference3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(4), zero)); + ImageReference3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(4), Zero3D)); texture.setSubImage(0, Vector3i(1), - BufferImage3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(2), subData, BufferUsage::StaticDraw)); + BufferImage3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(2), Data3D, BufferUsage::StaticDraw)); MAGNUM_VERIFY_NO_ERROR(); @@ -1055,27 +1030,7 @@ void TextureGLTest::subImage3DBuffer() { MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector3i(4)); - CORRADE_COMPARE_AS(std::vector(imageData.begin(), imageData.end()), (std::vector{ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0, 0, 0, 0, - 0, 0, 0, 0, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0, 0, 0, 0, - 0, 0, 0, 0, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }), TestSuite::Compare::Container); + CORRADE_COMPARE_AS(imageData, Containers::ArrayReference{SubData3DComplete}, TestSuite::Compare::Container); #endif } #endif