diff --git a/src/Magnum/DebugTools/BufferData.cpp b/src/Magnum/DebugTools/BufferData.cpp index e8ed4b7ea..da6f30d20 100644 --- a/src/Magnum/DebugTools/BufferData.cpp +++ b/src/Magnum/DebugTools/BufferData.cpp @@ -29,8 +29,8 @@ namespace Magnum { namespace DebugTools { namespace Implementation { void bufferSubData(Buffer& buffer, GLintptr offset, GLsizeiptr size, void* output) { - const char* data = buffer.map(offset, size, Buffer::MapFlag::Read); - std::copy(data, data + size, reinterpret_cast(output)); + Containers::ArrayView data = buffer.mapRead(offset, size); + std::copy(data.begin(), data.end(), reinterpret_cast(output)); buffer.unmap(); } diff --git a/src/Magnum/DebugTools/Implementation/AbstractShapeRenderer.cpp b/src/Magnum/DebugTools/Implementation/AbstractShapeRenderer.cpp index 3dc5a2d4f..4e62e8626 100644 --- a/src/Magnum/DebugTools/Implementation/AbstractShapeRenderer.cpp +++ b/src/Magnum/DebugTools/Implementation/AbstractShapeRenderer.cpp @@ -25,6 +25,8 @@ #include "AbstractShapeRenderer.h" +#include + #include "Magnum/AbstractShaderProgram.h" #include "Magnum/Buffer.h" #include "Magnum/Mesh.h" diff --git a/src/Magnum/Test/BufferGLTest.cpp b/src/Magnum/Test/BufferGLTest.cpp index ca86175b4..ba31f620c 100644 --- a/src/Magnum/Test/BufferGLTest.cpp +++ b/src/Magnum/Test/BufferGLTest.cpp @@ -233,9 +233,10 @@ void BufferGLTest::data() { /** @todo How to verify the contents in ES? */ #ifndef MAGNUM_TARGET_GLES - const Containers::Array contents = buffer.data(); + auto contents = buffer.data(); MAGNUM_VERIFY_NO_ERROR(); - CORRADE_COMPARE_AS(contents, Containers::arrayView(data), + CORRADE_COMPARE_AS(Containers::arrayCast(contents), + Containers::arrayView(data), TestSuite::Compare::Container); #endif @@ -259,9 +260,10 @@ void BufferGLTest::data() { /** @todo How to verify the contents in ES? */ #ifndef MAGNUM_TARGET_GLES - const Containers::Array subContents = buffer.subData(4, 3); + auto subContents = buffer.subData(4, 3*4); MAGNUM_VERIFY_NO_ERROR(); - CORRADE_COMPARE_AS(subContents, Containers::arrayView(subData), + CORRADE_COMPARE_AS(Containers::arrayCast(subContents), + Containers::arrayView(subData), TestSuite::Compare::Container); #endif } @@ -276,11 +278,13 @@ void BufferGLTest::map() { constexpr char data[] = {2, 7, 5, 13, 25}; buffer.setData(data, BufferUsage::StaticDraw); - #ifndef MAGNUM_TARGET_GLES - char* contents = buffer.map(Buffer::MapAccess::ReadWrite); - #else - char* contents = buffer.map(Buffer::MapAccess::WriteOnly); - #endif + char* contents = buffer.map( + #ifndef MAGNUM_TARGET_GLES + Buffer::MapAccess::ReadWrite + #else + Buffer::MapAccess::WriteOnly + #endif + ); MAGNUM_VERIFY_NO_ERROR(); CORRADE_VERIFY(contents); @@ -294,7 +298,7 @@ void BufferGLTest::map() { /** @todo How to verify the contents in ES? */ #ifndef MAGNUM_TARGET_GLES - Containers::Array changedContents = buffer.data(); + Containers::Array changedContents = buffer.data(); CORRADE_COMPARE(changedContents.size(), 5); CORRADE_COMPARE(changedContents[3], 107); #endif @@ -336,10 +340,11 @@ void BufferGLTest::mapRange() { Buffer buffer; buffer.setData(data, BufferUsage::StaticDraw); - char* contents = buffer.map(1, 4, Buffer::MapFlag::Read|Buffer::MapFlag::Write); + Containers::ArrayView contents = buffer.map(1, 4, Buffer::MapFlag::Read|Buffer::MapFlag::Write); MAGNUM_VERIFY_NO_ERROR(); CORRADE_VERIFY(contents); + CORRADE_COMPARE(contents.size(), 4); CORRADE_COMPARE(contents[2], 13); contents[3] = 107; @@ -348,7 +353,7 @@ void BufferGLTest::mapRange() { /** @todo How to verify the contents in ES? */ #ifndef MAGNUM_TARGET_GLES - Containers::Array changedContents = buffer.data(); + Containers::Array changedContents = buffer.data(); CORRADE_COMPARE(changedContents.size(), 5); CORRADE_COMPARE(changedContents[4], 107); #endif @@ -368,7 +373,7 @@ void BufferGLTest::mapRangeExplicitFlush() { buffer.setData(data, BufferUsage::StaticDraw); /* Map, set byte, don't flush and unmap */ - char* contents = buffer.map(1, 4, Buffer::MapFlag::Write|Buffer::MapFlag::FlushExplicit); + Containers::ArrayView contents = buffer.map(1, 4, Buffer::MapFlag::Write|Buffer::MapFlag::FlushExplicit); CORRADE_VERIFY(contents); contents[2] = 99; CORRADE_VERIFY(buffer.unmap()); @@ -377,7 +382,7 @@ void BufferGLTest::mapRangeExplicitFlush() { /* Unflushed range _might_ not be changed, thus nothing to test */ /* Map, set byte, flush and unmap */ - contents = buffer.map(1, 4, Buffer::MapFlag::Write|Buffer::MapFlag::FlushExplicit); + contents = buffer.map(1, 4, Buffer::MapFlag::Write|Buffer::MapFlag::FlushExplicit); CORRADE_VERIFY(contents); contents[3] = 107; buffer.flushMappedRange(3, 1); @@ -388,7 +393,7 @@ void BufferGLTest::mapRangeExplicitFlush() { /* Flushed range should be changed */ /** @todo How to verify the contents in ES? */ #ifndef MAGNUM_TARGET_GLES - Containers::Array changedContents = buffer.data(); + Containers::Array changedContents = buffer.data(); CORRADE_COMPARE(changedContents.size(), 5); CORRADE_COMPARE(changedContents[4], 107); #endif @@ -408,7 +413,7 @@ void BufferGLTest::copy() { /** @todo How to verify the contents in ES? */ #ifndef MAGNUM_TARGET_GLES - const Containers::Array subContents = buffer2.subData(2, 3); + const Containers::Array subContents = buffer2.subData(2, 3); CORRADE_COMPARE_AS(subContents, Containers::arrayView(data).slice(1, 4), TestSuite::Compare::Container); #endif diff --git a/src/Magnum/Test/BufferImageGLTest.cpp b/src/Magnum/Test/BufferImageGLTest.cpp index 7a0a5e0f2..e1fc79612 100644 --- a/src/Magnum/Test/BufferImageGLTest.cpp +++ b/src/Magnum/Test/BufferImageGLTest.cpp @@ -23,6 +23,7 @@ DEALINGS IN THE SOFTWARE. */ +#include #include #include "Magnum/BufferImage.h" @@ -287,7 +288,7 @@ void BufferImageGLTest::setData() { a.setData(PixelFormat::RGBA, PixelType::UnsignedShort, {1, 2}, data2, BufferUsage::StaticDraw); #ifndef MAGNUM_TARGET_GLES - const auto imageData = a.buffer().data(); + const auto imageData = a.buffer().data(); #endif MAGNUM_VERIFY_NO_ERROR(); @@ -299,7 +300,8 @@ void BufferImageGLTest::setData() { /** @todo How to verify the contents in ES? */ #ifndef MAGNUM_TARGET_GLES - CORRADE_COMPARE_AS(imageData, Containers::arrayView(data2), + CORRADE_COMPARE_AS(Containers::arrayCast(imageData), + Containers::arrayView(data2), TestSuite::Compare::Container); #endif } diff --git a/src/Magnum/Test/CubeMapTextureArrayGLTest.cpp b/src/Magnum/Test/CubeMapTextureArrayGLTest.cpp index 785851c17..86069654f 100644 --- a/src/Magnum/Test/CubeMapTextureArrayGLTest.cpp +++ b/src/Magnum/Test/CubeMapTextureArrayGLTest.cpp @@ -616,12 +616,12 @@ void CubeMapTextureArrayGLTest::imageBuffer() { #ifndef MAGNUM_TARGET_GLES BufferImage3D image = texture.image(0, {PixelStorageData[testCaseInstanceId()].storage, PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead); - const auto imageData = image.buffer().data(); + const auto imageData = image.buffer().data(); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector3i(2, 2, 6)); - CORRADE_COMPARE_AS(imageData.suffix(PixelStorageData[testCaseInstanceId()].offset), + CORRADE_COMPARE_AS(Containers::arrayCast(imageData).suffix(PixelStorageData[testCaseInstanceId()].offset), PixelStorageData[testCaseInstanceId()].data, TestSuite::Compare::Container); #endif @@ -699,12 +699,12 @@ void CubeMapTextureArrayGLTest::compressedImageBuffer() { /** @todo How to test this on ES? */ #ifndef MAGNUM_TARGET_GLES CompressedBufferImage3D image = texture.compressedImage(0, {CompressedPixelStorageData[testCaseInstanceId()].storage}, BufferUsage::StaticRead); - const auto imageData = image.buffer().data(); + const auto imageData = image.buffer().data(); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), (Vector3i{4, 4, 6})); - CORRADE_COMPARE_AS(imageData.suffix(CompressedPixelStorageData[testCaseInstanceId()].offset), + CORRADE_COMPARE_AS(Containers::arrayCast(imageData).suffix(CompressedPixelStorageData[testCaseInstanceId()].offset), CompressedPixelStorageData[testCaseInstanceId()].data, TestSuite::Compare::Container); #endif @@ -803,12 +803,13 @@ void CubeMapTextureArrayGLTest::subImageBuffer() { /** @todo How to test this on ES? */ #ifndef MAGNUM_TARGET_GLES BufferImage3D image = texture.image(0, {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead); - const auto imageData = image.buffer().data(); + const auto imageData = image.buffer().data(); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector3i(4, 4, 6)); - CORRADE_COMPARE_AS(imageData, Containers::arrayView(SubDataComplete), + CORRADE_COMPARE_AS(Containers::arrayCast(imageData), + Containers::arrayView(SubDataComplete), TestSuite::Compare::Container); #endif } @@ -857,12 +858,12 @@ void CubeMapTextureArrayGLTest::subImageQueryBuffer() { BufferImage3D image = texture.subImage(0, Range3Di::fromSize(Vector3i{1}, {2, 2, 4}), {SubPixelStorageData[testCaseInstanceId()].storage, PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead); - const auto imageData = image.buffer().data(); + const auto imageData = image.buffer().data(); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector3i(2, 2, 4)); - CORRADE_COMPARE_AS(imageData.suffix(SubPixelStorageData[testCaseInstanceId()].offset), + CORRADE_COMPARE_AS(Containers::arrayCast(imageData).suffix(SubPixelStorageData[testCaseInstanceId()].offset), SubPixelStorageData[testCaseInstanceId()].data, TestSuite::Compare::Container); } @@ -1016,12 +1017,12 @@ void CubeMapTextureArrayGLTest::compressedSubImageBuffer() { /** @todo How to test this on ES? */ #ifndef MAGNUM_TARGET_GLES CompressedBufferImage3D image = texture.compressedImage(0, {}, BufferUsage::StaticRead); - const auto imageData = image.buffer().data(); + const auto imageData = image.buffer().data(); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), (Vector3i{12, 12, 6})); - CORRADE_COMPARE_AS(imageData, Containers::arrayView(CompressedSubDataComplete), + CORRADE_COMPARE_AS(Containers::arrayCast(imageData), Containers::arrayView(CompressedSubDataComplete), TestSuite::Compare::Container); #endif } @@ -1078,12 +1079,12 @@ void CubeMapTextureArrayGLTest::compressedSubImageQueryBuffer() { MAGNUM_VERIFY_NO_ERROR(); CompressedBufferImage3D image = texture.compressedSubImage(0, Range3Di::fromSize({4, 4, 1}, Vector3i{4}), {CompressedSubPixelStorageData[testCaseInstanceId()].storage}, BufferUsage::StaticRead); - const auto imageData = image.buffer().data(); + const auto imageData = image.buffer().data(); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector3i{4}); - CORRADE_COMPARE_AS(imageData.suffix(CompressedSubPixelStorageData[testCaseInstanceId()].offset), + CORRADE_COMPARE_AS(Containers::arrayCast(imageData).suffix(CompressedSubPixelStorageData[testCaseInstanceId()].offset), CompressedSubPixelStorageData[testCaseInstanceId()].data, TestSuite::Compare::Container); } diff --git a/src/Magnum/Test/CubeMapTextureGLTest.cpp b/src/Magnum/Test/CubeMapTextureGLTest.cpp index 74295baed..5802a8611 100644 --- a/src/Magnum/Test/CubeMapTextureGLTest.cpp +++ b/src/Magnum/Test/CubeMapTextureGLTest.cpp @@ -642,12 +642,12 @@ void CubeMapTextureGLTest::imageBuffer() { #ifndef MAGNUM_TARGET_GLES BufferImage2D image = texture.image(CubeMapCoordinate::PositiveX, 0, {PixelStorageData[testCaseInstanceId()].storage, PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead); - const auto imageData = image.buffer().data(); + const auto imageData = image.buffer().data(); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector2i(2)); - CORRADE_COMPARE_AS(imageData.suffix(PixelStorageData[testCaseInstanceId()].offset), + CORRADE_COMPARE_AS(Containers::arrayCast(imageData).suffix(PixelStorageData[testCaseInstanceId()].offset), PixelStorageData[testCaseInstanceId()].data, TestSuite::Compare::Container); #endif @@ -733,12 +733,13 @@ void CubeMapTextureGLTest::subImageBuffer() { /** @todo How to test this on ES? */ #ifndef MAGNUM_TARGET_GLES BufferImage2D image = texture.image(CubeMapCoordinate::PositiveX, 0, {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead); - const auto imageData = image.buffer().data(); + const auto imageData = image.buffer().data(); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector2i(4)); - CORRADE_COMPARE_AS(imageData, Containers::arrayView(SubDataComplete), + CORRADE_COMPARE_AS(Containers::arrayCast(imageData), + Containers::arrayView(SubDataComplete), TestSuite::Compare::Container); #endif } @@ -790,12 +791,12 @@ void CubeMapTextureGLTest::subImageQueryBuffer() { BufferImage3D image = texture.subImage(0, Range3Di::fromSize({1, 1, 0}, {2, 2, 1}), {PixelStorageData[testCaseInstanceId()].storage, PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead); - const auto imageData = image.buffer().data(); + const auto imageData = image.buffer().data(); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector3i(2, 2, 1)); - CORRADE_COMPARE_AS(imageData.suffix(PixelStorageData[testCaseInstanceId()].offset), + CORRADE_COMPARE_AS(Containers::arrayCast(imageData).suffix(PixelStorageData[testCaseInstanceId()].offset), PixelStorageData[testCaseInstanceId()].data, TestSuite::Compare::Container); } @@ -884,12 +885,12 @@ void CubeMapTextureGLTest::compressedImageBuffer() { #ifndef MAGNUM_TARGET_GLES CompressedBufferImage2D image = texture.compressedImage(CubeMapCoordinate::PositiveX, 0, {CompressedPixelStorageData[testCaseInstanceId()].storage}, BufferUsage::StaticRead); - const auto imageData = image.buffer().data(); + const auto imageData = image.buffer().data(); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector2i{4}); - CORRADE_COMPARE_AS(imageData.suffix(CompressedPixelStorageData[testCaseInstanceId()].offset), + CORRADE_COMPARE_AS(Containers::arrayCast(imageData).suffix(CompressedPixelStorageData[testCaseInstanceId()].offset), CompressedPixelStorageData[testCaseInstanceId()].data, TestSuite::Compare::Container); #endif @@ -1079,12 +1080,13 @@ void CubeMapTextureGLTest::compressedSubImageBuffer() { #ifndef MAGNUM_TARGET_GLES CompressedBufferImage2D image = texture.compressedImage(CubeMapCoordinate::PositiveX, 0, {}, BufferUsage::StaticRead); - const auto imageData = image.buffer().data(); + const auto imageData = image.buffer().data(); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector2i{12}); - CORRADE_COMPARE_AS(imageData, Containers::arrayView(CompressedSubDataComplete), + CORRADE_COMPARE_AS(Containers::arrayCast(imageData), + Containers::arrayView(CompressedSubDataComplete), TestSuite::Compare::Container); #endif } @@ -1144,12 +1146,13 @@ void CubeMapTextureGLTest::compressedSubImageQueryBuffer() { MAGNUM_VERIFY_NO_ERROR(); CompressedBufferImage3D image = texture.compressedSubImage(0, Range3Di::fromSize({4, 4, 0}, {4, 4, 1}), {CompressedPixelStorageData[testCaseInstanceId()].storage}, BufferUsage::StaticRead); - const auto imageData = image.buffer().data(); + const auto imageData = image.buffer().data(); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), (Vector3i{4, 4, 1})); - CORRADE_COMPARE_AS(imageData.suffix(CompressedPixelStorageData[testCaseInstanceId()].offset), + CORRADE_COMPARE_AS( + Containers::arrayCast(imageData).suffix(CompressedPixelStorageData[testCaseInstanceId()].offset), CompressedPixelStorageData[testCaseInstanceId()].data, TestSuite::Compare::Container); } @@ -1203,8 +1206,8 @@ void CubeMapTextureGLTest::fullImageQueryBuffer() { MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector3i(2, 2, 6)); - const auto imageData = image.buffer().data(); - CORRADE_COMPARE_AS(imageData.suffix(FullPixelStorageData[testCaseInstanceId()].offset), + const auto imageData = image.buffer().data(); + CORRADE_COMPARE_AS(Containers::arrayCast(imageData).suffix(FullPixelStorageData[testCaseInstanceId()].offset), FullPixelStorageData[testCaseInstanceId()].data, TestSuite::Compare::Container); } @@ -1260,8 +1263,8 @@ void CubeMapTextureGLTest::compressedFullImageQueryBuffer() { MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), (Vector3i{4, 4, 6})); - const auto imageData = image.buffer().data(); - CORRADE_COMPARE_AS(imageData.suffix(CompressedFullPixelStorageData[testCaseInstanceId()].offset), + const auto imageData = image.buffer().data(); + CORRADE_COMPARE_AS(Containers::arrayCast(imageData).suffix(CompressedFullPixelStorageData[testCaseInstanceId()].offset), CompressedFullPixelStorageData[testCaseInstanceId()].data, TestSuite::Compare::Container); } diff --git a/src/Magnum/Test/FramebufferGLTest.cpp b/src/Magnum/Test/FramebufferGLTest.cpp index fc65ef31d..f39397942 100644 --- a/src/Magnum/Test/FramebufferGLTest.cpp +++ b/src/Magnum/Test/FramebufferGLTest.cpp @@ -1209,9 +1209,9 @@ void FramebufferGLTest::readBuffer() { MAGNUM_VERIFY_NO_ERROR(); /** @todo How to test this on ES? */ #ifndef MAGNUM_TARGET_GLES - const auto colorData = colorImage.buffer().data(); - CORRADE_COMPARE(colorData.size(), DataOffset + 8*16); - CORRADE_COMPARE(colorData[DataOffset], Color4ub(128, 64, 32, 17)); + auto colorData = colorImage.buffer().data(); + CORRADE_COMPARE(colorData.size(), (DataOffset + 8*16)*sizeof(Color4ub)); + CORRADE_COMPARE(Containers::arrayCast(colorData)[DataOffset], Color4ub(128, 64, 32, 17)); #endif } #endif diff --git a/src/Magnum/Test/RectangleTextureGLTest.cpp b/src/Magnum/Test/RectangleTextureGLTest.cpp index 0cd80ab1c..ad438db17 100644 --- a/src/Magnum/Test/RectangleTextureGLTest.cpp +++ b/src/Magnum/Test/RectangleTextureGLTest.cpp @@ -339,12 +339,12 @@ void RectangleTextureGLTest::imageBuffer() { BufferImage2D image = texture.image({PixelStorageData[testCaseInstanceId()].storage, PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead); - const auto imageData = image.buffer().data(); + const auto imageData = image.buffer().data(); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector2i(2)); - CORRADE_COMPARE_AS(imageData.suffix(PixelStorageData[testCaseInstanceId()].offset), + CORRADE_COMPARE_AS(Containers::arrayCast(imageData).suffix(PixelStorageData[testCaseInstanceId()].offset), PixelStorageData[testCaseInstanceId()].data, TestSuite::Compare::Container); } @@ -402,12 +402,13 @@ void RectangleTextureGLTest::subImageBuffer() { MAGNUM_VERIFY_NO_ERROR(); BufferImage2D image = texture.image({PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead); - const auto imageData = image.buffer().data(); + const auto imageData = image.buffer().data(); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector2i(4)); - CORRADE_COMPARE_AS(imageData, Containers::arrayView(SubDataComplete), + CORRADE_COMPARE_AS(Containers::arrayCast(imageData), + Containers::arrayView(SubDataComplete), TestSuite::Compare::Container); } @@ -454,12 +455,12 @@ void RectangleTextureGLTest::subImageQueryBuffer() { BufferImage2D image = texture.subImage(Range2Di::fromSize(Vector2i{1}, Vector2i{2}), {PixelStorageData[testCaseInstanceId()].storage, PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead); - const auto imageData = image.buffer().data(); + const auto imageData = image.buffer().data(); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector2i{2}); - CORRADE_COMPARE_AS(imageData.suffix(PixelStorageData[testCaseInstanceId()].offset), + CORRADE_COMPARE_AS(Containers::arrayCast(imageData).suffix(PixelStorageData[testCaseInstanceId()].offset), PixelStorageData[testCaseInstanceId()].data, TestSuite::Compare::Container); } diff --git a/src/Magnum/Test/TextureArrayGLTest.cpp b/src/Magnum/Test/TextureArrayGLTest.cpp index c2d4c08c1..2a6bb3365 100644 --- a/src/Magnum/Test/TextureArrayGLTest.cpp +++ b/src/Magnum/Test/TextureArrayGLTest.cpp @@ -848,12 +848,12 @@ void TextureArrayGLTest::image1DBuffer() { BufferImage2D image = texture.image(0, {PixelStorage1DData[testCaseInstanceId()].storage, PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead); - const auto imageData = image.buffer().data(); + auto imageData = image.buffer().data(); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector2i(2)); - CORRADE_COMPARE_AS(imageData.suffix(PixelStorage1DData[testCaseInstanceId()].offset), + CORRADE_COMPARE_AS(Containers::arrayCast(imageData).suffix(PixelStorage1DData[testCaseInstanceId()].offset), PixelStorage1DData[testCaseInstanceId()].data, TestSuite::Compare::Container); } @@ -911,12 +911,13 @@ void TextureArrayGLTest::subImage1DBuffer() { MAGNUM_VERIFY_NO_ERROR(); BufferImage2D image = texture.image(0, {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead); - const auto imageData = image.buffer().data(); + auto imageData = image.buffer().data(); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector2i(4)); - CORRADE_COMPARE_AS(imageData, Containers::arrayView(SubData1DComplete), + CORRADE_COMPARE_AS(Containers::arrayCast(imageData), + Containers::arrayView(SubData1DComplete), TestSuite::Compare::Container); } @@ -963,12 +964,12 @@ void TextureArrayGLTest::subImage1DQueryBuffer() { BufferImage2D image = texture.subImage(0, Range2Di::fromSize(Vector2i{1}, Vector2i{2}), {PixelStorage1DData[testCaseInstanceId()].storage, PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead); - const auto imageData = image.buffer().data(); + auto imageData = image.buffer().data(); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector2i{2}); - CORRADE_COMPARE_AS(imageData.suffix(PixelStorage1DData[testCaseInstanceId()].offset), + CORRADE_COMPARE_AS(Containers::arrayCast(imageData).suffix(PixelStorage1DData[testCaseInstanceId()].offset), PixelStorage1DData[testCaseInstanceId()].data, TestSuite::Compare::Container); } @@ -1049,12 +1050,12 @@ void TextureArrayGLTest::image2DBuffer() { #ifndef MAGNUM_TARGET_GLES BufferImage3D image = texture.image(0, {PixelStorage2DData[testCaseInstanceId()].storage, PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead); - const auto imageData = image.buffer().data(); + auto imageData = image.buffer().data(); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector3i(2)); - CORRADE_COMPARE_AS(imageData.suffix(PixelStorage2DData[testCaseInstanceId()].offset), + CORRADE_COMPARE_AS(Containers::arrayCast(imageData).suffix(PixelStorage2DData[testCaseInstanceId()].offset), PixelStorage2DData[testCaseInstanceId()].data, TestSuite::Compare::Container); #endif @@ -1139,12 +1140,13 @@ void TextureArrayGLTest::subImage2DBuffer() { /** @todo How to test this on ES? */ #ifndef MAGNUM_TARGET_GLES BufferImage3D image = texture.image(0, {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead); - const auto imageData = image.buffer().data(); + const auto imageData = image.buffer().data(); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector3i(4)); - CORRADE_COMPARE_AS(imageData, Containers::arrayView(SubData2DComplete), + CORRADE_COMPARE_AS(Containers::arrayCast(imageData), + Containers::arrayView(SubData2DComplete), TestSuite::Compare::Container); #endif } @@ -1193,12 +1195,12 @@ void TextureArrayGLTest::subImage2DQueryBuffer() { BufferImage3D image = texture.subImage(0, Range3Di::fromSize(Vector3i{1}, Vector3i{2}), {PixelStorage2DData[testCaseInstanceId()].storage, PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead); - const auto imageData = image.buffer().data(); + const auto imageData = image.buffer().data(); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector3i{2}); - CORRADE_COMPARE_AS(imageData.suffix(PixelStorage2DData[testCaseInstanceId()].offset), + CORRADE_COMPARE_AS(Containers::arrayCast(imageData).suffix(PixelStorage2DData[testCaseInstanceId()].offset), PixelStorage2DData[testCaseInstanceId()].data, TestSuite::Compare::Container); } @@ -1279,12 +1281,12 @@ void TextureArrayGLTest::compressedImage2DBuffer() { #ifndef MAGNUM_TARGET_GLES CompressedBufferImage3D image = texture.compressedImage(0, {CompressedPixelStorage2DData[testCaseInstanceId()].storage}, BufferUsage::StaticRead); - const auto imageData = image.buffer().data(); + const auto imageData = image.buffer().data(); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), (Vector3i{4, 4, 2})); - CORRADE_COMPARE_AS(imageData.suffix(CompressedPixelStorage2DData[testCaseInstanceId()].offset), + CORRADE_COMPARE_AS(Containers::arrayCast(imageData).suffix(CompressedPixelStorage2DData[testCaseInstanceId()].offset), CompressedPixelStorage2DData[testCaseInstanceId()].data, TestSuite::Compare::Container); #endif @@ -1411,12 +1413,12 @@ void TextureArrayGLTest::compressedSubImage2DBuffer() { #ifndef MAGNUM_TARGET_GLES CompressedBufferImage3D image = texture.compressedImage(0, {}, BufferUsage::StaticRead); - const auto imageData = image.buffer().data(); + const auto imageData = image.buffer().data(); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), (Vector3i{12, 4, 4})); - CORRADE_COMPARE_AS(imageData, + CORRADE_COMPARE_AS(Containers::arrayCast(imageData), Containers::arrayView(CompressedSubData2DComplete), TestSuite::Compare::Container); #endif @@ -1480,12 +1482,12 @@ void TextureArrayGLTest::compressedSubImage2DQueryBuffer() { CompressedPixelStorage2DData[testCaseInstanceId()].storage #endif }, BufferUsage::StaticRead); - const auto imageData = image.buffer().data(); + const auto imageData = image.buffer().data(); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), (Vector3i{4, 4, 2})); - CORRADE_COMPARE_AS(imageData.suffix(CompressedPixelStorage2DData[testCaseInstanceId()].offset), + CORRADE_COMPARE_AS(Containers::arrayCast(imageData).suffix(CompressedPixelStorage2DData[testCaseInstanceId()].offset), CompressedPixelStorage2DData[testCaseInstanceId()].data, TestSuite::Compare::Container); } diff --git a/src/Magnum/Test/TextureGLTest.cpp b/src/Magnum/Test/TextureGLTest.cpp index 6e4759d54..ad9eef264 100644 --- a/src/Magnum/Test/TextureGLTest.cpp +++ b/src/Magnum/Test/TextureGLTest.cpp @@ -1245,12 +1245,12 @@ void TextureGLTest::image1DBuffer() { BufferImage1D image = texture.image(0, {PixelStorage1DData[testCaseInstanceId()].storage, PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticDraw); - const auto imageData = image.buffer().data(); + const auto imageData = image.buffer().data(); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), 2); - CORRADE_COMPARE_AS(imageData.suffix(PixelStorage1DData[testCaseInstanceId()].offset), + CORRADE_COMPARE_AS(Containers::arrayCast(imageData).suffix(PixelStorage1DData[testCaseInstanceId()].offset), PixelStorage1DData[testCaseInstanceId()].data, TestSuite::Compare::Container); } @@ -1300,12 +1300,12 @@ void TextureGLTest::subImage1DBuffer() { MAGNUM_VERIFY_NO_ERROR(); BufferImage1D image = texture.image(0, {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead); - const auto imageData = image.buffer().data(); + const auto imageData = image.buffer().data(); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), 4); - CORRADE_COMPARE_AS(imageData, Containers::arrayView(SubData1DComplete), + CORRADE_COMPARE_AS(Containers::arrayCast(imageData), Containers::arrayView(SubData1DComplete), TestSuite::Compare::Container); } @@ -1348,12 +1348,12 @@ void TextureGLTest::subImage1DQueryBuffer() { BufferImage1D image = texture.subImage(0, Range1Di::fromSize(1, 2), {PixelStorage1DData[testCaseInstanceId()].storage, PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead); - const auto imageData = image.buffer().data(); + const auto imageData = image.buffer().data(); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), 2); - CORRADE_COMPARE_AS(imageData.suffix(PixelStorage1DData[testCaseInstanceId()].offset), + CORRADE_COMPARE_AS(Containers::arrayCast(imageData).suffix(PixelStorage1DData[testCaseInstanceId()].offset), PixelStorage1DData[testCaseInstanceId()].data, TestSuite::Compare::Container); } @@ -1431,12 +1431,12 @@ void TextureGLTest::image2DBuffer() { BufferImage2D image = texture.image(0, {PixelStorage2DData[testCaseInstanceId()].storage, PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead); - const auto imageData = image.buffer().data(); + const auto imageData = image.buffer().data(); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector2i(2)); - CORRADE_COMPARE_AS(imageData.suffix(PixelStorage2DData[testCaseInstanceId()].offset), + CORRADE_COMPARE_AS(Containers::arrayCast(imageData).suffix(PixelStorage2DData[testCaseInstanceId()].offset), PixelStorage2DData[testCaseInstanceId()].data, TestSuite::Compare::Container); #endif @@ -1501,12 +1501,12 @@ void TextureGLTest::subImage2DBuffer() { /** @todo How to test this on ES? */ #ifndef MAGNUM_TARGET_GLES BufferImage2D image = texture.image(0, {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead); - const auto imageData = image.buffer().data(); + const auto imageData = image.buffer().data(); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector2i(4)); - CORRADE_COMPARE_AS(imageData, Containers::arrayView(SubData2DComplete), + CORRADE_COMPARE_AS(Containers::arrayCast(imageData), Containers::arrayView(SubData2DComplete), TestSuite::Compare::Container); #endif } @@ -1552,12 +1552,12 @@ void TextureGLTest::subImage2DQueryBuffer() { BufferImage2D image = texture.subImage(0, Range2Di::fromSize(Vector2i{1}, Vector2i{2}), {PixelStorage2DData[testCaseInstanceId()].storage, PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead); - const auto imageData = image.buffer().data(); + const auto imageData = image.buffer().data(); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector2i{2}); - CORRADE_COMPARE_AS(imageData.suffix(PixelStorage2DData[testCaseInstanceId()].offset), + CORRADE_COMPARE_AS(Containers::arrayCast(imageData).suffix(PixelStorage2DData[testCaseInstanceId()].offset), PixelStorage2DData[testCaseInstanceId()].data, TestSuite::Compare::Container); } @@ -1632,12 +1632,12 @@ void TextureGLTest::compressedImage2DBuffer() { #ifndef MAGNUM_TARGET_GLES CompressedBufferImage2D image = texture.compressedImage(0, {CompressedPixelStorage2DData[testCaseInstanceId()].storage}, BufferUsage::StaticRead); - const auto imageData = image.buffer().data(); + const auto imageData = image.buffer().data(); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector2i{4}); - CORRADE_COMPARE_AS(imageData.suffix(CompressedPixelStorage2DData[testCaseInstanceId()].offset), + CORRADE_COMPARE_AS(Containers::arrayCast(imageData).suffix(CompressedPixelStorage2DData[testCaseInstanceId()].offset), CompressedPixelStorage2DData[testCaseInstanceId()].data, TestSuite::Compare::Container); #endif @@ -1731,12 +1731,12 @@ void TextureGLTest::compressedSubImage2DBuffer() { #ifndef MAGNUM_TARGET_GLES CompressedBufferImage2D image = texture.compressedImage(0, {}, BufferUsage::StaticRead); - const auto imageData = image.buffer().data(); + const auto imageData = image.buffer().data(); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), (Vector2i{12, 4})); - CORRADE_COMPARE_AS(imageData, + CORRADE_COMPARE_AS(Containers::arrayCast(imageData), Containers::arrayView(CompressedSubData2DComplete), TestSuite::Compare::Container); #endif @@ -1793,12 +1793,12 @@ void TextureGLTest::compressedSubImage2DQueryBuffer() { CompressedBufferImage2D image = texture.compressedSubImage(0, Range2Di::fromSize({4, 0}, Vector2i{4}), {CompressedPixelStorage2DData[testCaseInstanceId()].storage}, BufferUsage::StaticRead); - const auto imageData = image.buffer().data(); + const auto imageData = image.buffer().data(); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector2i{4}); - CORRADE_COMPARE_AS(imageData.suffix(CompressedPixelStorage2DData[testCaseInstanceId()].offset), + CORRADE_COMPARE_AS(Containers::arrayCast(imageData).suffix(CompressedPixelStorage2DData[testCaseInstanceId()].offset), CompressedPixelStorage2DData[testCaseInstanceId()].data, TestSuite::Compare::Container); } @@ -1854,12 +1854,12 @@ void TextureGLTest::image3DBuffer() { BufferImage3D image = texture.image(0, {PixelStorage3DData[testCaseInstanceId()].storage, PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead); - const auto imageData = image.buffer().data(); + const auto imageData = image.buffer().data(); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector3i(2)); - CORRADE_COMPARE_AS(imageData.suffix(PixelStorage3DData[testCaseInstanceId()].offset), + CORRADE_COMPARE_AS(Containers::arrayCast(imageData).suffix(PixelStorage3DData[testCaseInstanceId()].offset), PixelStorage3DData[testCaseInstanceId()].data, TestSuite::Compare::Container); #endif @@ -1942,12 +1942,13 @@ void TextureGLTest::subImage3DBuffer() { /** @todo How to test this on ES? */ #ifndef MAGNUM_TARGET_GLES BufferImage3D image = texture.image(0, {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead); - const auto imageData = image.buffer().data(); + const auto imageData = image.buffer().data(); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector3i(4)); - CORRADE_COMPARE_AS(imageData, Containers::arrayView(SubData3DComplete), + CORRADE_COMPARE_AS(Containers::arrayCast(imageData), + Containers::arrayView(SubData3DComplete), TestSuite::Compare::Container); #endif } @@ -1993,12 +1994,12 @@ void TextureGLTest::subImage3DQueryBuffer() { BufferImage3D image = texture.subImage(0, Range3Di::fromSize(Vector3i{1}, Vector3i{2}), {PixelStorage3DData[testCaseInstanceId()].storage, PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead); - const auto imageData = image.buffer().data(); + const auto imageData = image.buffer().data(); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector3i{2}); - CORRADE_COMPARE_AS(imageData.suffix(PixelStorage3DData[testCaseInstanceId()].offset), + CORRADE_COMPARE_AS(Containers::arrayCast(imageData).suffix(PixelStorage3DData[testCaseInstanceId()].offset), PixelStorage3DData[testCaseInstanceId()].data, TestSuite::Compare::Container); } @@ -2058,12 +2059,12 @@ void TextureGLTest::compressedImage3DBuffer() { MAGNUM_VERIFY_NO_ERROR(); CompressedBufferImage3D image = texture.compressedImage(0, {CompressedPixelStorage3DData[testCaseInstanceId()].storage}, BufferUsage::StaticRead); - const auto imageData = image.buffer().data(); + const auto imageData = image.buffer().data(); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector3i{4}); - CORRADE_COMPARE_AS(imageData.suffix(CompressedPixelStorage3DData[testCaseInstanceId()].offset), + CORRADE_COMPARE_AS(Containers::arrayCast(imageData).suffix(CompressedPixelStorage3DData[testCaseInstanceId()].offset), CompressedPixelStorage3DData[testCaseInstanceId()].data, TestSuite::Compare::Container); #endif @@ -2175,7 +2176,7 @@ void TextureGLTest::compressedSubImage3DBuffer() { MAGNUM_VERIFY_NO_ERROR(); CompressedBufferImage3D image = texture.compressedImage(0, {}, BufferUsage::StaticRead); - const auto imageData = image.buffer().data(); + const auto imageData = image.buffer().data(); MAGNUM_VERIFY_NO_ERROR(); @@ -2185,7 +2186,7 @@ void TextureGLTest::compressedSubImage3DBuffer() { CORRADE_EXPECT_FAIL_IF(CompressedPixelStorage3DData[testCaseInstanceId()].storage == CompressedPixelStorage{} && (Context::current().detectedDriver() & Context::DetectedDriver::NVidia), "Default compressed pixel storage behaves weirdly with BPTC compression on NVidia."); - CORRADE_COMPARE_AS(imageData, + CORRADE_COMPARE_AS(Containers::arrayCast(imageData), Containers::arrayView(CompressedSubData3DComplete), TestSuite::Compare::Container); } @@ -2249,7 +2250,7 @@ void TextureGLTest::compressedSubImage3DQueryBuffer() { CompressedBufferImage3D image = texture.compressedSubImage(0, Range3Di::fromSize({4, 0, 0}, Vector3i{4}), {CompressedPixelStorage3DData[testCaseInstanceId()].storage}, BufferUsage::StaticRead); - const auto imageData = image.buffer().data(); + const auto imageData = image.buffer().data(); MAGNUM_VERIFY_NO_ERROR(); @@ -2259,7 +2260,7 @@ void TextureGLTest::compressedSubImage3DQueryBuffer() { CORRADE_EXPECT_FAIL_IF(CompressedPixelStorage3DData[testCaseInstanceId()].storage == CompressedPixelStorage{} && (Context::current().detectedDriver() & Context::DetectedDriver::NVidia), "Default compressed pixel storage behaves weirdly with BPTC compression on NVidia."); - CORRADE_COMPARE_AS(imageData.suffix(CompressedPixelStorage3DData[testCaseInstanceId()].offset), + CORRADE_COMPARE_AS(Containers::arrayCast(imageData).suffix(CompressedPixelStorage3DData[testCaseInstanceId()].offset), CompressedPixelStorage3DData[testCaseInstanceId()].data, TestSuite::Compare::Container); } diff --git a/src/Magnum/Test/TransformFeedbackGLTest.cpp b/src/Magnum/Test/TransformFeedbackGLTest.cpp index 4b059ea36..8cd3c9c3a 100644 --- a/src/Magnum/Test/TransformFeedbackGLTest.cpp +++ b/src/Magnum/Test/TransformFeedbackGLTest.cpp @@ -282,7 +282,7 @@ void TransformFeedbackGLTest::attachBase() { MAGNUM_VERIFY_NO_ERROR(); - Vector2* data = output.map(0, 2*sizeof(Vector2), Buffer::MapFlag::Read); + auto data = Containers::arrayCast(output.mapRead(0, 2*sizeof(Vector2))); CORRADE_COMPARE(data[0], Vector2(1.0f, -1.0f)); CORRADE_COMPARE(data[1], Vector2(0.0f, 0.0f)); output.unmap(); @@ -325,7 +325,7 @@ void TransformFeedbackGLTest::attachRange() { MAGNUM_VERIFY_NO_ERROR(); - Vector2* data = output.map(256, 2*sizeof(Vector2), Buffer::MapFlag::Read); + auto data = Containers::arrayCast(output.mapRead(256, 2*sizeof(Vector2))); CORRADE_COMPARE(data[0], Vector2(1.0f, -1.0f)); CORRADE_COMPARE(data[1], Vector2(0.0f, 0.0f)); output.unmap(); @@ -415,12 +415,12 @@ void TransformFeedbackGLTest::attachBases() { MAGNUM_VERIFY_NO_ERROR(); - Vector2* data1 = output1.map(0, 2*sizeof(Vector2), Buffer::MapFlag::Read); + auto data1 = Containers::arrayCast(output1.mapRead(0, 2*sizeof(Vector2))); CORRADE_COMPARE(data1[0], Vector2(1.0f, -1.0f)); CORRADE_COMPARE(data1[1], Vector2(0.0f, 0.0f)); output1.unmap(); - Float* data2 = output2.map(0, 2*sizeof(Float), Buffer::MapFlag::Read); + auto data2 = Containers::arrayCast(output2.mapRead(0, 2*sizeof(Float))); CORRADE_COMPARE(data2[0], 0.0f); CORRADE_COMPARE(data2[1], -2.0f); output2.unmap(); @@ -467,12 +467,12 @@ void TransformFeedbackGLTest::attachRanges() { MAGNUM_VERIFY_NO_ERROR(); - Vector2* data1 = output1.map(256, 2*sizeof(Vector2), Buffer::MapFlag::Read); + auto data1 = Containers::arrayCast(output1.mapRead(256, 2*sizeof(Vector2))); CORRADE_COMPARE(data1[0], Vector2(1.0f, -1.0f)); CORRADE_COMPARE(data1[1], Vector2(0.0f, 0.0f)); output1.unmap(); - Float* data2 = output2.map(512, 2*sizeof(Float), Buffer::MapFlag::Read); + auto data2 = Containers::arrayCast(output2.mapRead(512, 2*sizeof(Float))); CORRADE_COMPARE(data2[0], 0.0f); CORRADE_COMPARE(data2[1], -2.0f); output2.unmap(); @@ -542,7 +542,7 @@ void TransformFeedbackGLTest::interleaved() { MAGNUM_VERIFY_NO_ERROR(); - Vector2* data = output.map(0, 4*sizeof(Vector2), Buffer::MapFlag::Read); + auto data = Containers::arrayCast(output.mapRead(0, 4*sizeof(Vector2))); CORRADE_COMPARE(data[0], Vector2(1.0f, -1.0f)); CORRADE_COMPARE(data[1].y(), 5.0f); CORRADE_COMPARE(data[2], Vector2(0.0f, 0.0f)); diff --git a/src/Magnum/Text/Renderer.cpp b/src/Magnum/Text/Renderer.cpp index de0e882d6..46cf815e0 100644 --- a/src/Magnum/Text/Renderer.cpp +++ b/src/Magnum/Text/Renderer.cpp @@ -25,6 +25,8 @@ #include "Renderer.h" +#include + #include "Magnum/Context.h" #include "Magnum/Extensions.h" #include "Magnum/Mesh.h" diff --git a/src/Magnum/Text/Renderer.h b/src/Magnum/Text/Renderer.h index 3442bc3a8..086e4ce03 100644 --- a/src/Magnum/Text/Renderer.h +++ b/src/Magnum/Text/Renderer.h @@ -41,6 +41,10 @@ #include "Magnum/Text/Alignment.h" #include "Magnum/Text/visibility.h" +#ifdef CORRADE_TARGET_EMSCRIPTEN +#include +#endif + namespace Magnum { namespace Text { /** diff --git a/src/Magnum/Text/Test/RendererGLTest.cpp b/src/Magnum/Text/Test/RendererGLTest.cpp index 2065645eb..a37f0ea7b 100644 --- a/src/Magnum/Text/Test/RendererGLTest.cpp +++ b/src/Magnum/Text/Test/RendererGLTest.cpp @@ -23,6 +23,9 @@ DEALINGS IN THE SOFTWARE. */ +#include +#include + #include "Magnum/Context.h" #include "Magnum/Extensions.h" #include "Magnum/OpenGLTester.h" @@ -190,32 +193,32 @@ void RendererGLTest::renderMesh() { /** @todo How to verify this on ES? */ #ifndef MAGNUM_TARGET_GLES /* Vertex buffer contents */ - const Containers::Array vertices = vertexBuffer.data(); - CORRADE_COMPARE(vertices.size(), 3*4*(2 + 2)); - CORRADE_COMPARE(std::vector(vertices.begin(), vertices.end()), (std::vector{ - 0.0f + offset.x(), 0.5f + offset.y(), 0.0f, 10.0f, - 0.0f + offset.x(), 0.0f + offset.y(), 0.0f, 0.0f, - 0.75f + offset.x(), 0.5f + offset.y(), 6.0f, 10.0f, - 0.75f + offset.x(), 0.0f + offset.y(), 6.0f, 0.0f, - - 1.0f + offset.x(), 0.75f + offset.y(), 6.0f, 10.0f, - 1.0f + offset.x(), -0.25f + offset.y(), 6.0f, 0.0f, - 2.5f + offset.x(), 0.75f + offset.y(), 12.0f, 10.0f, - 2.5f + offset.x(), -0.25f + offset.y(), 12.0f, 0.0f, - - 2.75f + offset.x(), 1.0f + offset.y(), 12.0f, 10.0f, - 2.75f + offset.x(), -0.5f + offset.y(), 12.0f, 0.0f, - 5.0f + offset.x(), 1.0f + offset.y(), 18.0f, 10.0f, - 5.0f + offset.x(), -0.5f + offset.y(), 18.0f, 0.0f - })); - - const Containers::Array indices = indexBuffer.data(); - CORRADE_COMPARE(indices.size(), 3*6); - CORRADE_COMPARE(std::vector(indices.begin(), indices.end()), (std::vector{ - 0, 1, 2, 1, 3, 2, - 4, 5, 6, 5, 7, 6, - 8, 9, 10, 9, 11, 10 - })); + Containers::Array vertices = vertexBuffer.data(); + CORRADE_COMPARE_AS(Containers::arrayCast(vertices), + (Containers::Array{Containers::InPlaceInit, { + 0.0f + offset.x(), 0.5f + offset.y(), 0.0f, 10.0f, + 0.0f + offset.x(), 0.0f + offset.y(), 0.0f, 0.0f, + 0.75f + offset.x(), 0.5f + offset.y(), 6.0f, 10.0f, + 0.75f + offset.x(), 0.0f + offset.y(), 6.0f, 0.0f, + + 1.0f + offset.x(), 0.75f + offset.y(), 6.0f, 10.0f, + 1.0f + offset.x(), -0.25f + offset.y(), 6.0f, 0.0f, + 2.5f + offset.x(), 0.75f + offset.y(), 12.0f, 10.0f, + 2.5f + offset.x(), -0.25f + offset.y(), 12.0f, 0.0f, + + 2.75f + offset.x(), 1.0f + offset.y(), 12.0f, 10.0f, + 2.75f + offset.x(), -0.5f + offset.y(), 12.0f, 0.0f, + 5.0f + offset.x(), 1.0f + offset.y(), 18.0f, 10.0f, + 5.0f + offset.x(), -0.5f + offset.y(), 18.0f, 0.0f + }}), TestSuite::Compare::Container); + + Containers::Array indices = indexBuffer.data(); + CORRADE_COMPARE_AS(Containers::arrayCast(indices), + (Containers::Array{Containers::InPlaceInit, { + 0, 1, 2, 1, 3, 2, + 4, 5, 6, 5, 7, 6, + 8, 9, 10, 9, 11, 10 + }}), TestSuite::Compare::Container); #endif } @@ -232,27 +235,29 @@ void RendererGLTest::renderMeshIndexType() { std::tie(mesh, std::ignore) = Text::Renderer3D::render(font, nullGlyphCache, 1.0f, std::string(64, 'a'), vertexBuffer, indexBuffer, BufferUsage::StaticDraw); MAGNUM_VERIFY_NO_ERROR(); - Containers::Array indicesByte = indexBuffer.data(); + Containers::Array indicesByte = indexBuffer.data(); CORRADE_COMPARE(vertexBuffer.size(), 256*(2 + 2)*4); CORRADE_COMPARE(indicesByte.size(), 64*6); - CORRADE_COMPARE(std::vector(indicesByte.begin(), indicesByte.begin()+18), (std::vector{ - 0, 1, 2, 1, 3, 2, - 4, 5, 6, 5, 7, 6, - 8, 9, 10, 9, 11, 10 - })); + CORRADE_COMPARE_AS(Containers::arrayCast(indicesByte).prefix(18), + (Containers::Array{Containers::InPlaceInit, { + 0, 1, 2, 1, 3, 2, + 4, 5, 6, 5, 7, 6, + 8, 9, 10, 9, 11, 10 + }}), TestSuite::Compare::Container); /* 16-bit indices (260 vertices) */ std::tie(mesh, std::ignore) = Text::Renderer3D::render(font, nullGlyphCache, 1.0f, std::string(65, 'a'), vertexBuffer, indexBuffer, BufferUsage::StaticDraw); MAGNUM_VERIFY_NO_ERROR(); - Containers::Array indicesShort = indexBuffer.data(); + Containers::Array indicesShort = indexBuffer.data(); CORRADE_COMPARE(vertexBuffer.size(), 260*(2 + 2)*4); - CORRADE_COMPARE(indicesShort.size(), 65*6); - CORRADE_COMPARE(std::vector(indicesShort.begin(), indicesShort.begin()+18), (std::vector{ - 0, 1, 2, 1, 3, 2, - 4, 5, 6, 5, 7, 6, - 8, 9, 10, 9, 11, 10 - })); + CORRADE_COMPARE(indicesShort.size(), 65*6*2); + CORRADE_COMPARE_AS(Containers::arrayCast(indicesShort).prefix(18), + (Containers::Array{Containers::InPlaceInit, { + 0, 1, 2, 1, 3, 2, + 4, 5, 6, 5, 7, 6, + 8, 9, 10, 9, 11, 10 + }}), TestSuite::Compare::Container); #else CORRADE_SKIP("Can't verify buffer contents on OpenGL ES."); #endif @@ -285,13 +290,14 @@ void RendererGLTest::mutableText() { CORRADE_COMPARE(renderer.capacity(), 4); /** @todo How to verify this on ES? */ #ifndef MAGNUM_TARGET_GLES - Containers::Array indices = renderer.indexBuffer().data(); - CORRADE_COMPARE(std::vector(indices.begin(), indices.end()), (std::vector{ - 0, 1, 2, 1, 3, 2, - 4, 5, 6, 5, 7, 6, - 8, 9, 10, 9, 11, 10, - 12, 13, 14, 13, 15, 14 - })); + Containers::Array indices = renderer.indexBuffer().data(); + CORRADE_COMPARE_AS(Containers::arrayCast(indices).prefix(24), + (Containers::Array{Containers::InPlaceInit, { + 0, 1, 2, 1, 3, 2, + 4, 5, 6, 5, 7, 6, + 8, 9, 10, 9, 11, 10, + 12, 13, 14, 13, 15, 14 + }}), TestSuite::Compare::Container); #endif /* Render text */ @@ -305,23 +311,24 @@ void RendererGLTest::mutableText() { /** @todo How to verify this on ES? */ #ifndef MAGNUM_TARGET_GLES - Containers::Array vertices = renderer.vertexBuffer().subData(0, 48); - CORRADE_COMPARE(std::vector(vertices.begin(), vertices.end()), (std::vector{ - 0.0f, 0.5f, 0.0f, 10.0f, - 0.0f, 0.0f, 0.0f, 0.0f, - 0.75f, 0.5f, 6.0f, 10.0f, - 0.75f, 0.0f, 6.0f, 0.0f, - - 1.0f, 0.75f, 6.0f, 10.0f, - 1.0f, -0.25f, 6.0f, 0.0f, - 2.5f, 0.75f, 12.0f, 10.0f, - 2.5f, -0.25f, 12.0f, 0.0f, - - 2.75f, 1.0f, 12.0f, 10.0f, - 2.75f, -0.5f, 12.0f, 0.0f, - 5.0f, 1.0f, 18.0f, 10.0f, - 5.0f, -0.5f, 18.0f, 0.0f - })); + Containers::Array vertices = renderer.vertexBuffer().data(); + CORRADE_COMPARE_AS(Containers::arrayCast(vertices).prefix(48), + (Containers::Array{Containers::InPlaceInit, { + 0.0f, 0.5f, 0.0f, 10.0f, + 0.0f, 0.0f, 0.0f, 0.0f, + 0.75f, 0.5f, 6.0f, 10.0f, + 0.75f, 0.0f, 6.0f, 0.0f, + + 1.0f, 0.75f, 6.0f, 10.0f, + 1.0f, -0.25f, 6.0f, 0.0f, + 2.5f, 0.75f, 12.0f, 10.0f, + 2.5f, -0.25f, 12.0f, 0.0f, + + 2.75f, 1.0f, 12.0f, 10.0f, + 2.75f, -0.5f, 12.0f, 0.0f, + 5.0f, 1.0f, 18.0f, 10.0f, + 5.0f, -0.5f, 18.0f, 0.0f + }}), TestSuite::Compare::Container); #endif }