From d0fa28c3318f46bf2ba337404b22e7bc83be7295 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 26 Jun 2020 13:01:57 +0200 Subject: [PATCH] Use the new half/packed typedefs where appropriate. Had this in a stash for a while, not sure why it wasn't commited already. --- doc/snippets/MagnumMath.cpp | 20 ++++++++++---------- src/Magnum/GL/Test/MeshGLTest.cpp | 22 +++++++++++----------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/doc/snippets/MagnumMath.cpp b/doc/snippets/MagnumMath.cpp index 0b9ae7438..70452f810 100644 --- a/doc/snippets/MagnumMath.cpp +++ b/doc/snippets/MagnumMath.cpp @@ -716,7 +716,7 @@ if(!(b < a - epsilon || a + epsilon < b)) { { /* [Color3-fromSrgb] */ -Math::Vector3 srgb; +Vector3ub srgb; auto rgb = Color3::fromSrgb(srgb); /* [Color3-fromSrgb] */ static_cast(rgb); @@ -744,7 +744,7 @@ static_cast(bFromSrgb); { /* [Color3-toSrgb] */ Color3 color; -Math::Vector3 srgb = color.toSrgb(); +Vector3ub srgb = color.toSrgb(); /* [Color3-toSrgb] */ static_cast(srgb); } @@ -761,7 +761,7 @@ static_cast(bSrgb); { /* [Color4-fromSrgbAlpha] */ -Math::Vector4 srgbAlpha; +Vector4ub srgbAlpha; auto rgba = Color4::fromSrgbAlpha(srgbAlpha); /* [Color4-fromSrgbAlpha] */ static_cast(rgba); @@ -789,7 +789,7 @@ static_cast(bFromSrgb); { /* [Color4-toSrgbAlpha] */ Color4 color; -Math::Vector4 srgbAlpha = color.toSrgbAlpha(); +Vector4ub srgbAlpha = color.toSrgbAlpha(); /* [Color4-toSrgbAlpha] */ static_cast(srgbAlpha); } @@ -830,7 +830,7 @@ static_cast(a); { /* [_srgb] */ using namespace Math::Literals; -Math::Vector3 a = 0x33b27f_srgb; // {0x33, 0xb2, 0x7f} +Vector3ub a = 0x33b27f_srgb; // {0x33, 0xb2, 0x7f} /* [_srgb] */ static_cast(a); } @@ -846,7 +846,7 @@ static_cast(a); { /* [_srgba] */ using namespace Math::Literals; -Math::Vector4 a = 0x33b27fcc_srgba; // {0x33, 0xb2, 0x7f, 0xcc} +Vector4ub a = 0x33b27fcc_srgba; // {0x33, 0xb2, 0x7f, 0xcc} /* [_srgba] */ static_cast(a); } @@ -960,10 +960,10 @@ Debug{} << UnsignedShort(a); // Prints 25675 { /* [Half-usage-vector] */ -Math::Vector3 a{3.14159_h, -1.4142_h, 1.618_h}; -Vector3 b{a}; // converts to 32-bit floats -Debug{} << a; // prints {3.14159, -1.4142, 1.618} -Debug{} << Math::Vector3{a}; // prints {16968, 48552, 15993} +Vector3h a{3.14159_h, -1.4142_h, 1.618_h}; +Vector3 b{a}; // converts to 32-bit floats +Debug{} << a; // prints {3.14159, -1.4142, 1.618} +Debug{} << Vector3us{a}; // prints {16968, 48552, 15993} /* [Half-usage-vector] */ } diff --git a/src/Magnum/GL/Test/MeshGLTest.cpp b/src/Magnum/GL/Test/MeshGLTest.cpp index 43f6b2a83..e3146b10f 100644 --- a/src/Magnum/GL/Test/MeshGLTest.cpp +++ b/src/Magnum/GL/Test/MeshGLTest.cpp @@ -939,7 +939,7 @@ void MeshGLTest::addVertexBufferVectorNd() { const Vector4d data[] = { {}, {0.0, -0.9, 1.0, 1.25}, - Math::unpack(Math::Vector4(315, 65201, 2576, 12)) + Math::unpack(Vector4us{315, 65201, 2576, 12}) }; Buffer buffer; buffer.setData(data, BufferUsage::StaticDraw); @@ -961,10 +961,10 @@ void MeshGLTest::addVertexBufferVectorNd() { MAGNUM_VERIFY_NO_GL_ERROR(); const auto value = Checker(DoubleShader("dvec4", "vec4", "vec4(value)"), - RenderbufferFormat::RGBA16, mesh).get>(PixelFormat::RGBA, PixelType::UnsignedShort); + RenderbufferFormat::RGBA16, mesh).get(PixelFormat::RGBA, PixelType::UnsignedShort); MAGNUM_VERIFY_NO_GL_ERROR(); - CORRADE_COMPARE(value, Math::Vector4(315, 65201, 2576, 12)); + CORRADE_COMPARE(value, (Vector4us{315, 65201, 2576, 12})); } #endif @@ -1027,7 +1027,7 @@ void MeshGLTest::addVertexBufferMatrixNxNd() { const Matrix3x3d data[] = { {}, Matrix3x3d::fromDiagonal({0.0, -0.9, 1.0}), - Matrix3x3d::fromDiagonal(Math::unpack(Math::Vector3(315, 65201, 2576))) + Matrix3x3d::fromDiagonal(Math::unpack(Vector3us{315, 65201, 2576})) }; Buffer buffer; buffer.setData(data, BufferUsage::StaticDraw); @@ -1050,7 +1050,7 @@ void MeshGLTest::addVertexBufferMatrixNxNd() { const auto value = Checker(DoubleShader("dmat3", "vec4", "vec4(value[0][0], value[1][1], value[2][2], 0.0)"), - RenderbufferFormat::RGBA16, mesh).get>(PixelFormat::RGBA, PixelType::UnsignedShort); + RenderbufferFormat::RGBA16, mesh).get(PixelFormat::RGBA, PixelType::UnsignedShort); MAGNUM_VERIFY_NO_GL_ERROR(); @@ -1058,13 +1058,13 @@ void MeshGLTest::addVertexBufferMatrixNxNd() { /* Used to be a problem on Intel Windows drivers 23, not a problem on 26 anymore */ CORRADE_EXPECT_FAIL_IF(Context::current().detectedDriver() & (Context::DetectedDriver::Amd|Context::DetectedDriver::NVidia), "Somehow only first two values are extracted on AMD and NVidia drivers."); - CORRADE_COMPARE(value.xyz(), Math::Vector3(315, 65201, 2576)); + CORRADE_COMPARE(value.xyz(), (Vector3us{315, 65201, 2576})); } /* This is wrong, but check if it's still the right wrong. Fails on AMD 15.201.1151 but seems to be fixed in 15.300.1025.0 */ if(Context::current().detectedDriver() & (Context::DetectedDriver::Amd|Context::DetectedDriver::NVidia)) - CORRADE_COMPARE(value.xyz(), Math::Vector3(315, 65201, 0)); + CORRADE_COMPARE(value.xyz(), (Vector3us{315, 65201, 0})); } #endif @@ -1111,7 +1111,7 @@ void MeshGLTest::addVertexBufferMatrixMxNd() { const Matrix3x4d data[] = { {}, Matrix3x4d::fromDiagonal({0.0, -0.9, 1.0}), - Matrix3x4d::fromDiagonal(Math::unpack(Math::Vector3(315, 65201, 2576))) + Matrix3x4d::fromDiagonal(Math::unpack(Vector3us{315, 65201, 2576})) }; Buffer buffer; buffer.setData(data, BufferUsage::StaticDraw); @@ -1134,7 +1134,7 @@ void MeshGLTest::addVertexBufferMatrixMxNd() { const auto value = Checker(DoubleShader("dmat3x4", "vec4", "vec4(value[0][0], value[1][1], value[2][2], 0.0)"), - RenderbufferFormat::RGBA16, mesh).get>(PixelFormat::RGBA, PixelType::UnsignedShort); + RenderbufferFormat::RGBA16, mesh).get(PixelFormat::RGBA, PixelType::UnsignedShort); MAGNUM_VERIFY_NO_GL_ERROR(); @@ -1142,13 +1142,13 @@ void MeshGLTest::addVertexBufferMatrixMxNd() { /* Used to be a problem on Intel Windows drivers 23, not a problem on 26 anymore */ CORRADE_EXPECT_FAIL_IF(Context::current().detectedDriver() & (Context::DetectedDriver::Amd|Context::DetectedDriver::NVidia), "Somehow only first two values are extracted on AMD and NVidia drivers."); - CORRADE_COMPARE(value.xyz(), Math::Vector3(315, 65201, 2576)); + CORRADE_COMPARE(value.xyz(), (Vector3us{315, 65201, 2576})); } /* This is wrong, but check if it's still the right wrong. Fails on AMD 15.201.1151 but seems to be fixed in 15.300.1025.0 */ if(Context::current().detectedDriver() & (Context::DetectedDriver::Amd|Context::DetectedDriver::NVidia)) - CORRADE_COMPARE(value.xyz(), Math::Vector3(315, 65201, 0)); + CORRADE_COMPARE(value.xyz(), (Vector3us{315, 65201, 0})); } #endif