diff --git a/doc/changelog.dox b/doc/changelog.dox index 83e76ba72..e897d255b 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -380,6 +380,18 @@ See also: @subsection changelog-latest-deprecated Deprecated APIs +- The @cpp Array @ce, @cpp Array1D @ce, @cpp Array2D @ce and + @cpp Array3D @ce types that were used exclusively for specifying + @ref SamplerWrapping in various texture APIs are deprecated in favor of + @ref Math::Vector and its subclasses and all existing APIs were switched to + it. The only advantage of this type compared to @ref Math::Vector was that + it provided an implicit constructor from a single value (whereas + @ref Math::Vector has it @cpp explicit @ce), and that's now solved by + simply providing an overload with just a single value where it matters. + It was also commonly confused with @relativeref{Corrade,Containers::Array}, + which is a type with totally different semantics. To avoid breaking + existing code, conversion from and to @ref Math::Vector is now provided and + this type is included in all places where it was originally used. - Markup styling for Emscripten application was switched to prefer using CSS classes instead of the @cb{.css} #container @ce, @cb{.css} #sizer @ce, @cb{.css} #expander @ce, @cb{.css} #listener @ce, @cb{.css} #canvas @ce, diff --git a/src/Magnum/Array.h b/src/Magnum/Array.h index 1fb2a771c..842222af4 100644 --- a/src/Magnum/Array.h +++ b/src/Magnum/Array.h @@ -25,15 +25,26 @@ DEALINGS IN THE SOFTWARE. */ +#ifdef MAGNUM_BUILD_DEPRECATED /** @file * @brief Class @ref Magnum::Array, @ref Magnum::Array1D, @ref Magnum::Array2D, @ref Magnum::Array3D + * @m_deprecated_since_latest Use @ref Magnum/Math/Vector3.h instead. */ +#endif + +#include "Magnum/configure.h" +#ifdef MAGNUM_BUILD_DEPRECATED #include #include #include +#include #include "Magnum/Magnum.h" +#include "Magnum/Math/Vector3.h" + +/* No CORRADE_DEPRECATED_FILE() as a lot of other headers include this for + implicit conversions */ namespace Magnum { @@ -45,13 +56,12 @@ namespace Implementation { @brief Array @tparam dimensions Dimension count @tparam T Data type +@m_deprecated_since_latest Use @ref Math::Vector instead. -Similar to @ref Math::Vector, but more suitable for storing enum values which -don't need any math operations and fuzzy comparison (e.g. enum values). Unlike -@ref Math::Vector this class has implicit constructor from one value. +Unlike @ref Math::Vector this class has implicit constructor from one value. @see @ref Array1D, @ref Array2D, @ref Array3D */ -template class Array { +template class CORRADE_DEPRECATED("use Math::Vector instead") Array { public: typedef T Type; /**< @brief Data type */ @@ -85,6 +95,12 @@ template class Array { constexpr /*implicit*/ Array(U value): Array(typename Containers::Implementation::GenerateSequence::Type{}, value) {} #endif + /** @brief Convert to a vector */ + /*implicit*/ operator Math::Vector() const { + return Math::Vector::from(_data); + } + + CORRADE_IGNORE_DEPRECATED_PUSH /** @brief Equality */ bool operator==(const Array& other) const { for(UnsignedInt i = 0; i != dimensions; ++i) @@ -96,6 +112,7 @@ template class Array { bool operator!=(const Array& other) const { return !operator==(other); } + CORRADE_IGNORE_DEPRECATED_POP /** @brief Value at given position */ T& operator[](UnsignedInt pos) { return _data[pos]; } @@ -120,11 +137,13 @@ template class Array { template constexpr explicit Array(Containers::Implementation::Sequence, T value): _data{Implementation::repeat(value, sequence)...} {} }; +CORRADE_IGNORE_DEPRECATED_PUSH /** @brief One-dimensional array @tparam T Data type +@m_deprecated_since_latest Use @ref Math::Vector instead. */ -template class Array1D: public Array<1, T> { +template class CORRADE_DEPRECATED("use Math::Vector instead") Array1D: public Array<1, T> { public: /** @copydoc Array::Array() */ constexpr /*implicit*/ Array1D() = default; @@ -135,6 +154,9 @@ template class Array1D: public Array<1, T> { */ constexpr /*implicit*/ Array1D(T x): Array<1, T>(x) {} + /** @brief Construct from a vector */ + constexpr /*implicit*/ Array1D(const Math::Vector<1, T>& vector): Array1D{vector[0]} {} + T& x() { return Array<1, T>::_data[0]; } /**< @brief X component */ constexpr T x() const { return Array<1, T>::_data[0]; } /**< @overload */ }; @@ -142,8 +164,9 @@ template class Array1D: public Array<1, T> { /** @brief Two-dimensional array @tparam T Data type +@m_deprecated_since_latest Use @ref Math::Vector2 instead. */ -template class Array2D: public Array<2, T> { +template class CORRADE_DEPRECATED("use Math::Vector2 instead") Array2D: public Array<2, T> { public: /** @copydoc Array::Array() */ constexpr /*implicit*/ Array2D() = default; @@ -155,6 +178,9 @@ template class Array2D: public Array<2, T> { */ constexpr /*implicit*/ Array2D(T x, T y): Array<2, T>(x, y) {} + /** @brief Construct from a vector */ + constexpr /*implicit*/ Array2D(const Math::Vector2& vector): Array2D{vector.x(), vector.y()} {} + /** @brief Initializer-list constructor */ constexpr /*implicit*/ Array2D(T value): Array<2, T>(value, value) {} @@ -167,8 +193,9 @@ template class Array2D: public Array<2, T> { /** @brief Three-dimensional array @tparam T Data type +@m_deprecated_since_latest Use @ref Math::Vector3 instead. */ -template class Array3D: public Array<3, T> { +template class CORRADE_DEPRECATED("use Math::Vector3 instead") Array3D: public Array<3, T> { public: /** @copydoc Array::Array() */ constexpr /*implicit*/ Array3D() {} @@ -181,6 +208,9 @@ template class Array3D: public Array<3, T> { */ constexpr /*implicit*/ Array3D(T x, T y, T z): Array<3, T>(x, y, z) {} + /** @brief Construct from a vector */ + constexpr /*implicit*/ Array3D(const Math::Vector3& vector): Array3D{vector.x(), vector.y(), vector.z()} {} + /** @brief Initializer-list constructor */ constexpr /*implicit*/ Array3D(T value): Array<3, T>(value, value, value) {} @@ -201,7 +231,10 @@ template class Array3D: public Array<3, T> { } /**< @overload */ }; -/** @debugoperator{Array} */ +/** +@debugoperator{Array} +@m_deprecated_since_latest Use @ref Math::Vector instead. +*/ template Debug& operator<<(Debug& debug, const Array& value) { debug << "Array(" << Debug::nospace; for(UnsignedInt i = 0; i != dimensions; ++i) { @@ -211,21 +244,34 @@ template Debug& operator<<(Debug& debug, const return debug << Debug::nospace << ")"; } -/** @debugoperator{Array1D} */ +/** +@debugoperator{Array1D} +@m_deprecated_since_latest Use @ref Math::Vector instead. +*/ template inline Debug& operator<<(Debug& debug, const Array1D& value) { return debug << static_cast&>(value); } -/** @debugoperator{Array2D} */ +/** +@debugoperator{Array2D} +@m_deprecated_since_latest Use @ref Math::Vector2 instead. +*/ template inline Debug& operator<<(Debug& debug, const Array2D& value) { return debug << static_cast&>(value); } -/** @debugoperator{Array3D} */ +/** +@debugoperator{Array3D} +@m_deprecated_since_latest Use @ref Math::Vector3 instead. +*/ template inline Debug& operator<<(Debug& debug, const Array3D& value) { return debug << static_cast&>(value); } +CORRADE_IGNORE_DEPRECATED_POP } +#else +#error use Magnum/Math/Vector3.h instead +#endif #endif diff --git a/src/Magnum/CMakeLists.txt b/src/Magnum/CMakeLists.txt index 8b3216be0..befc8e7fe 100644 --- a/src/Magnum/CMakeLists.txt +++ b/src/Magnum/CMakeLists.txt @@ -75,7 +75,6 @@ set(Magnum_GracefulAssert_SRCS set(Magnum_HEADERS AbstractResourceLoader.h - Array.h British.h DimensionTraits.h FileCallback.h @@ -104,6 +103,10 @@ set(Magnum_PRIVATE_HEADERS Implementation/pixelFormatMapping.hpp Implementation/vertexFormatMapping.hpp) +if(MAGNUM_BUILD_DEPRECATED) + list(APPEND Magnum_HEADERS Array.h) +endif() + # Functionality specific to static Windows builds if(CORRADE_TARGET_WINDOWS AND NOT CORRADE_TARGET_WINDOWS_RT AND MAGNUM_BUILD_STATIC) list(APPEND Magnum_SRCS Implementation/WindowsWeakSymbol.cpp) diff --git a/src/Magnum/GL/AbstractTexture.cpp b/src/Magnum/GL/AbstractTexture.cpp index 4efa513ae..e016256b9 100644 --- a/src/Magnum/GL/AbstractTexture.cpp +++ b/src/Magnum/GL/AbstractTexture.cpp @@ -28,7 +28,6 @@ #include #include -#include "Magnum/Array.h" #include "Magnum/Image.h" #include "Magnum/ImageView.h" #ifndef MAGNUM_TARGET_GLES2 @@ -2354,12 +2353,12 @@ void AbstractTexture::DataHelper<3>::invalidateSubImage(AbstractTexture& texture } #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::DataHelper<1>::setWrapping(AbstractTexture& texture, const Array1D& wrapping) { - (texture.*Context::current().state().texture.parameteriImplementation)(GL_TEXTURE_WRAP_S, GLint(wrapping.x())); +void AbstractTexture::DataHelper<1>::setWrapping(AbstractTexture& texture, const Math::Vector<1, SamplerWrapping>& wrapping) { + (texture.*Context::current().state().texture.parameteriImplementation)(GL_TEXTURE_WRAP_S, GLint(wrapping[0])); } #endif -void AbstractTexture::DataHelper<2>::setWrapping(AbstractTexture& texture, const Array2D& wrapping) { +void AbstractTexture::DataHelper<2>::setWrapping(AbstractTexture& texture, const Math::Vector2& wrapping) { const Implementation::TextureState& state = Context::current().state().texture; (texture.*state.parameteriImplementation)(GL_TEXTURE_WRAP_S, GLint(wrapping.x())); @@ -2367,7 +2366,7 @@ void AbstractTexture::DataHelper<2>::setWrapping(AbstractTexture& texture, const } #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) -void AbstractTexture::DataHelper<3>::setWrapping(AbstractTexture& texture, const Array3D& wrapping) { +void AbstractTexture::DataHelper<3>::setWrapping(AbstractTexture& texture, const Math::Vector3& wrapping) { const Implementation::TextureState& state = Context::current().state().texture; (texture.*state.parameteriImplementation)(GL_TEXTURE_WRAP_S, GLint(wrapping.x())); diff --git a/src/Magnum/GL/AbstractTexture.h b/src/Magnum/GL/AbstractTexture.h index 87027a8f2..bcafe5ebe 100644 --- a/src/Magnum/GL/AbstractTexture.h +++ b/src/Magnum/GL/AbstractTexture.h @@ -720,7 +720,7 @@ template<> struct MAGNUM_GL_EXPORT AbstractTexture::DataHelper<1> { static Math::Vector<1, GLint> compressedBlockSize(GLenum target, TextureFormat format); static Math::Vector<1, GLint> imageSize(AbstractTexture& texture, GLint level); - static void setWrapping(AbstractTexture& texture, const Array1D& wrapping); + static void setWrapping(AbstractTexture& texture, const Math::Vector<1, SamplerWrapping>& wrapping); static void setStorage(AbstractTexture& texture, GLsizei levels, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size); @@ -745,7 +745,7 @@ template<> struct MAGNUM_GL_EXPORT AbstractTexture::DataHelper<2> { static Vector2i imageSize(AbstractTexture& texture, GLint level); #endif - static void setWrapping(AbstractTexture& texture, const Array2D& wrapping); + static void setWrapping(AbstractTexture& texture, const Math::Vector2& wrapping); static void setStorage(AbstractTexture& texture, GLsizei levels, TextureFormat internalFormat, const Vector2i& size); @@ -790,7 +790,7 @@ template<> struct MAGNUM_GL_EXPORT AbstractTexture::DataHelper<3> { static Vector3i imageSize(AbstractTexture& texture, GLint level); #endif - static void setWrapping(AbstractTexture& texture, const Array3D& wrapping); + static void setWrapping(AbstractTexture& texture, const Math::Vector3& wrapping); static void setStorage(AbstractTexture& texture, GLsizei levels, TextureFormat internalFormat, const Vector3i& size); diff --git a/src/Magnum/GL/CubeMapTexture.h b/src/Magnum/GL/CubeMapTexture.h index f95e751b2..38aec069b 100644 --- a/src/Magnum/GL/CubeMapTexture.h +++ b/src/Magnum/GL/CubeMapTexture.h @@ -29,12 +29,16 @@ * @brief Class @ref Magnum::GL::CubeMapTexture, enum @ref Magnum::GL::CubeMapCoordinate */ -#include "Magnum/Array.h" #include "Magnum/Sampler.h" #include "Magnum/GL/AbstractTexture.h" #include "Magnum/GL/Sampler.h" #include "Magnum/Math/Vector2.h" +#ifdef MAGNUM_BUILD_DEPRECATED +/* For implicit conversions to Vector, not used otherwise */ +#include "Magnum/Array.h" +#endif + namespace Magnum { namespace GL { /** @@ -348,16 +352,32 @@ class MAGNUM_GL_EXPORT CubeMapTexture: public AbstractTexture { * * See @ref Texture::setWrapping() for more information. */ - CubeMapTexture& setWrapping(const Array2D& wrapping) { + CubeMapTexture& setWrapping(const Math::Vector2& wrapping) { DataHelper<2>::setWrapping(*this, wrapping); return *this; } /** @overload */ - CubeMapTexture& setWrapping(const Array2D& wrapping) { + CubeMapTexture& setWrapping(const Math::Vector2& wrapping) { return setWrapping(samplerWrapping(wrapping)); } + /** + * @brief Set the same wrapping for all dimensions + * @return Reference to self (for method chaining) + * + * Same as calling @ref setWrapping(const Math::Vector2&) + * with the same value for all dimensions. + */ + CubeMapTexture& setWrapping(SamplerWrapping wrapping) { + return setWrapping(Math::Vector2{wrapping}); + } + + /** @overload */ + CubeMapTexture& setWrapping(Magnum::SamplerWrapping wrapping) { + return setWrapping(Math::Vector2{wrapping}); + } + #ifndef MAGNUM_TARGET_WEBGL /** * @brief @copybrief Texture::setBorderColor(const Color4&) diff --git a/src/Magnum/GL/CubeMapTextureArray.h b/src/Magnum/GL/CubeMapTextureArray.h index ba6045da3..22563848a 100644 --- a/src/Magnum/GL/CubeMapTextureArray.h +++ b/src/Magnum/GL/CubeMapTextureArray.h @@ -31,12 +31,16 @@ */ #endif -#include "Magnum/Array.h" #include "Magnum/Sampler.h" #include "Magnum/GL/AbstractTexture.h" #include "Magnum/GL/Sampler.h" #include "Magnum/Math/Vector3.h" +#ifdef MAGNUM_BUILD_DEPRECATED +/* For implicit conversions to Vector, not used otherwise */ +#include "Magnum/Array.h" +#endif + #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) namespace Magnum { namespace GL { @@ -313,16 +317,32 @@ class MAGNUM_GL_EXPORT CubeMapTextureArray: public AbstractTexture { * * See @ref Texture::setWrapping() for more information. */ - CubeMapTextureArray& setWrapping(const Array2D& wrapping) { + CubeMapTextureArray& setWrapping(const Math::Vector2& wrapping) { DataHelper<2>::setWrapping(*this, wrapping); return *this; } /** @overload */ - CubeMapTextureArray& setWrapping(const Array2D& wrapping) { + CubeMapTextureArray& setWrapping(const Math::Vector2& wrapping) { return setWrapping(samplerWrapping(wrapping)); } + /** + * @brief Set the same wrapping for all dimensions + * @return Reference to self (for method chaining) + * + * Same as calling @ref setWrapping(const Math::Vector2&) + * with the same value for all dimensions. + */ + CubeMapTextureArray& setWrapping(SamplerWrapping wrapping) { + return setWrapping(Math::Vector2{wrapping}); + } + + /** @overload */ + CubeMapTextureArray& setWrapping(Magnum::SamplerWrapping wrapping) { + return setWrapping(Math::Vector2{wrapping}); + } + /** * @brief @copybrief Texture::setBorderColor(const Color4&) * @return Reference to self (for method chaining) diff --git a/src/Magnum/GL/RectangleTexture.h b/src/Magnum/GL/RectangleTexture.h index de923e241..719efadf7 100644 --- a/src/Magnum/GL/RectangleTexture.h +++ b/src/Magnum/GL/RectangleTexture.h @@ -31,12 +31,16 @@ */ #endif -#include "Magnum/Array.h" #include "Magnum/Sampler.h" #include "Magnum/GL/AbstractTexture.h" #include "Magnum/GL/Sampler.h" #include "Magnum/Math/Vector2.h" +#ifdef MAGNUM_BUILD_DEPRECATED +/* For implicit conversions to Vector, not used otherwise */ +#include "Magnum/Array.h" +#endif + #ifndef MAGNUM_TARGET_GLES namespace Magnum { namespace GL { @@ -214,16 +218,32 @@ class MAGNUM_GL_EXPORT RectangleTexture: public AbstractTexture { * @ref SamplerWrapping::ClampToBorder is supported on this * texture type. */ - RectangleTexture& setWrapping(const Array2D& wrapping) { + RectangleTexture& setWrapping(const Math::Vector2& wrapping) { DataHelper<2>::setWrapping(*this, wrapping); return *this; } /** @overload */ - RectangleTexture& setWrapping(const Array2D& wrapping) { + RectangleTexture& setWrapping(const Math::Vector2& wrapping) { return setWrapping(samplerWrapping(wrapping)); } + /** + * @brief Set the same wrapping for all dimensions + * @return Reference to self (for method chaining) + * + * Same as calling @ref setWrapping(const Math::Vector2&) + * with the same value for all dimensions. + */ + RectangleTexture& setWrapping(SamplerWrapping wrapping) { + return setWrapping(Math::Vector2{wrapping}); + } + + /** @overload */ + RectangleTexture& setWrapping(Magnum::SamplerWrapping wrapping) { + return setWrapping(Math::Vector2{wrapping}); + } + /** * @brief @copybrief Texture::setBorderColor(const Color4&) * @return Reference to self (for method chaining) diff --git a/src/Magnum/GL/Sampler.h b/src/Magnum/GL/Sampler.h index 412b3bdcd..067e85ae9 100644 --- a/src/Magnum/GL/Sampler.h +++ b/src/Magnum/GL/Sampler.h @@ -29,10 +29,15 @@ * @brief Class @ref Magnum::GL::Sampler, enum @ref Magnum::GL::SamplerFilter, @ref Magnum::GL::SamplerMipmap, @ref Magnum::GL::SamplerWrapping, @ref Magnum::GL::SamplerCompareMode, @ref Magnum::GL::SamplerCompareFunction, @ref Magnum::GL::SamplerDepthStencilMode, function @ref Magnum::GL::samplerFilter(), @ref Magnum::GL::samplerMipmap(), @ref Magnum::GL::hasSamplerWrapping(), @ref Magnum::GL::samplerWrapping() */ -#include "Magnum/Array.h" #include "Magnum/Magnum.h" #include "Magnum/GL/OpenGL.h" #include "Magnum/GL/visibility.h" +#include "Magnum/Math/Vector3.h" + +#ifdef MAGNUM_BUILD_DEPRECATED +/* For implicit conversions to Vector, not used otherwise */ +#include "Magnum/Array.h" +#endif namespace Magnum { namespace GL { @@ -201,8 +206,8 @@ function expects that given format is available on the target. Use MAGNUM_GL_EXPORT SamplerWrapping samplerWrapping(Magnum::SamplerWrapping wrapping); /** @overload */ -template Array samplerWrapping(const Array& wrapping) { - Array out; /** @todo NoInit */ +template Math::Vector samplerWrapping(const Math::Vector& wrapping) { + Math::Vector out{NoInit}; for(std::size_t i = 0; i != dimensions; ++i) out[i] = samplerWrapping(wrapping[i]); return out; diff --git a/src/Magnum/GL/Test/SamplerTest.cpp b/src/Magnum/GL/Test/SamplerTest.cpp index c343b3d7f..b2ccaaec3 100644 --- a/src/Magnum/GL/Test/SamplerTest.cpp +++ b/src/Magnum/GL/Test/SamplerTest.cpp @@ -40,7 +40,7 @@ struct SamplerTest: TestSuite::Tester { void mapMipmap(); void mapMipmapInvalid(); void mapWrapping(); - void mapWrappingArray(); + void mapWrappingVector(); void mapWrappingInvalid(); void mapWrappingUnsupported(); @@ -62,7 +62,7 @@ SamplerTest::SamplerTest() { &SamplerTest::mapMipmap, &SamplerTest::mapMipmapInvalid, &SamplerTest::mapWrapping, - &SamplerTest::mapWrappingArray, + &SamplerTest::mapWrappingVector, &SamplerTest::mapWrappingInvalid, &SamplerTest::mapWrappingUnsupported, @@ -137,8 +137,8 @@ void SamplerTest::mapWrapping() { #endif } -void SamplerTest::mapWrappingArray() { - CORRADE_COMPARE(samplerWrapping<2>({Magnum::SamplerWrapping::Repeat, Magnum::SamplerWrapping::ClampToEdge}), (Array2D{SamplerWrapping::Repeat, SamplerWrapping::ClampToEdge})); +void SamplerTest::mapWrappingVector() { + CORRADE_COMPARE(samplerWrapping<2>({Magnum::SamplerWrapping::Repeat, Magnum::SamplerWrapping::ClampToEdge}), (Math::Vector2{SamplerWrapping::Repeat, SamplerWrapping::ClampToEdge})); } void SamplerTest::mapWrappingInvalid() { diff --git a/src/Magnum/GL/Texture.h b/src/Magnum/GL/Texture.h index ddf5f9d45..96f504f4d 100644 --- a/src/Magnum/GL/Texture.h +++ b/src/Magnum/GL/Texture.h @@ -29,13 +29,17 @@ * @brief Class @ref Magnum::GL::Texture, typedef @ref Magnum::GL::Texture1D, @ref Magnum::GL::Texture2D, @ref Magnum::GL::Texture3D */ -#include "Magnum/Array.h" #include "Magnum/Sampler.h" #include "Magnum/DimensionTraits.h" #include "Magnum/GL/AbstractTexture.h" #include "Magnum/GL/Sampler.h" #include "Magnum/Math/Vector3.h" +#ifdef MAGNUM_BUILD_DEPRECATED +/* For implicit conversions to Vector, not used otherwise */ +#include "Magnum/Array.h" +#endif + namespace Magnum { namespace GL { namespace Implementation { @@ -468,16 +472,32 @@ template class Texture: public AbstractTexture { * @fn_gl_keyword{TexParameter} with @def_gl_keyword{TEXTURE_WRAP_S}, * @def_gl_keyword{TEXTURE_WRAP_T}, @def_gl_keyword{TEXTURE_WRAP_R} */ - Texture& setWrapping(const Array& wrapping) { + Texture& setWrapping(const Math::Vector& wrapping) { DataHelper::setWrapping(*this, wrapping); return *this; } /** @overload */ - Texture& setWrapping(const Array& wrapping) { + Texture& setWrapping(const Math::Vector& wrapping) { return setWrapping(samplerWrapping(wrapping)); } + /** + * @brief Set the same wrapping for all dimensions + * @return Reference to self (for method chaining) + * + * Same as calling @ref setWrapping(const Math::Vector&) + * with the same value for all dimensions. + */ + Texture& setWrapping(SamplerWrapping wrapping) { + return setWrapping(Math::Vector{wrapping}); + } + + /** @overload */ + Texture& setWrapping(Magnum::SamplerWrapping wrapping) { + return setWrapping(Math::Vector{wrapping}); + } + #ifndef MAGNUM_TARGET_WEBGL /** * @brief Set border color diff --git a/src/Magnum/GL/TextureArray.h b/src/Magnum/GL/TextureArray.h index 7c2837e92..a2da58120 100644 --- a/src/Magnum/GL/TextureArray.h +++ b/src/Magnum/GL/TextureArray.h @@ -31,13 +31,17 @@ */ #endif -#include "Magnum/Array.h" #include "Magnum/Sampler.h" #include "Magnum/DimensionTraits.h" #include "Magnum/GL/AbstractTexture.h" #include "Magnum/GL/Sampler.h" #include "Magnum/Math/Vector3.h" +#ifdef MAGNUM_BUILD_DEPRECATED +/* For implicit conversions to Vector, not used otherwise */ +#include "Magnum/Array.h" +#endif + #ifndef MAGNUM_TARGET_GLES2 namespace Magnum { namespace GL { @@ -333,16 +337,32 @@ template class TextureArray: public AbstractTexture { * * See @ref Texture::setWrapping() for more information. */ - TextureArray& setWrapping(const Array& wrapping) { + TextureArray& setWrapping(const Math::Vector& wrapping) { DataHelper::setWrapping(*this, wrapping); return *this; } /** @overload */ - TextureArray& setWrapping(const Array& wrapping) { + TextureArray& setWrapping(const Math::Vector& wrapping) { return setWrapping(samplerWrapping(wrapping)); } + /** + * @brief Set the same wrapping for all dimensions + * @return Reference to self (for method chaining) + * + * Same as calling @ref setWrapping(const Math::Vector&) + * with the same value for all dimensions. + */ + TextureArray& setWrapping(SamplerWrapping wrapping) { + return setWrapping(Math::Vector{wrapping}); + } + + /** @overload */ + TextureArray& setWrapping(Magnum::SamplerWrapping wrapping) { + return setWrapping(Math::Vector{wrapping}); + } + #ifndef MAGNUM_TARGET_WEBGL /** * @brief @copybrief Texture::setBorderColor(const Color4&) diff --git a/src/Magnum/Magnum.h b/src/Magnum/Magnum.h index 310364210..4d68ab0df 100644 --- a/src/Magnum/Magnum.h +++ b/src/Magnum/Magnum.h @@ -34,6 +34,10 @@ #include "Magnum/Types.h" #include "Magnum/Math/Math.h" +#ifdef MAGNUM_BUILD_DEPRECATED +#include +#endif + namespace Magnum { /* Bring whole Corrade namespace */ @@ -1129,10 +1133,12 @@ typedef Math::Frustum Frustumd; */ #ifndef DOXYGEN_GENERATING_OUTPUT -template class Array; -template class Array1D; -template class Array2D; -template class Array3D; +#ifdef MAGNUM_BUILD_DEPRECATED +template class CORRADE_DEPRECATED("use Math::Vector instead") Array; +template class CORRADE_DEPRECATED("use Math::Vector instead") Array1D; +template class CORRADE_DEPRECATED("use Math::Vector2 instead") Array2D; +template class CORRADE_DEPRECATED("use Math::Vector3 instead") Array3D; +#endif enum class InputFileCallbackPolicy: UnsignedByte; diff --git a/src/Magnum/Test/ArrayTest.cpp b/src/Magnum/Test/ArrayTest.cpp index 468c97458..38c8fb9e8 100644 --- a/src/Magnum/Test/ArrayTest.cpp +++ b/src/Magnum/Test/ArrayTest.cpp @@ -41,6 +41,7 @@ struct ArrayTest: TestSuite::Tester { void debug(); }; +CORRADE_IGNORE_DEPRECATED_PUSH typedef Magnum::Array1D Array1D; typedef Magnum::Array2D Array2D; typedef Magnum::Array3D Array3D; @@ -121,6 +122,7 @@ void ArrayTest::debug() { Debug{&out} << Array<4, Int>{5, 6, 7, 8} << Array1D{13} << Array2D{71, 2} << Array3D{1, 2, 3}; CORRADE_COMPARE(out.str(), "Array(5, 6, 7, 8) Array(13) Array(71, 2) Array(1, 2, 3)\n"); } +CORRADE_IGNORE_DEPRECATED_POP }}} diff --git a/src/Magnum/Test/CMakeLists.txt b/src/Magnum/Test/CMakeLists.txt index e2a9cc9d4..30ef374f9 100644 --- a/src/Magnum/Test/CMakeLists.txt +++ b/src/Magnum/Test/CMakeLists.txt @@ -23,7 +23,6 @@ # DEALINGS IN THE SOFTWARE. # -corrade_add_test(ArrayTest ArrayTest.cpp LIBRARIES Magnum) corrade_add_test(FileCallbackTest FileCallbackTest.cpp LIBRARIES Magnum) corrade_add_test(ImageTest ImageTest.cpp LIBRARIES MagnumTestLib) corrade_add_test(ImageViewTest ImageViewTest.cpp LIBRARIES MagnumTestLib) @@ -41,7 +40,6 @@ corrade_add_test(MagnumVersionTest VersionTest.cpp LIBRARIES Magnum) corrade_add_test(VertexFormatTest VertexFormatTest.cpp LIBRARIES MagnumTestLib) set_target_properties( - ArrayTest ImageTest ImageViewTest MeshTest @@ -54,6 +52,11 @@ set_target_properties( VertexFormatTest PROPERTIES FOLDER "Magnum/Test") +if(MAGNUM_BUILD_DEPRECATED) + corrade_add_test(ArrayTest ArrayTest.cpp LIBRARIES Magnum) + set_target_properties(ArrayTest PROPERTIES FOLDER "Magnum/Test") +endif() + set_property(TARGET MeshTest PixelFormatTest diff --git a/src/Magnum/Trade/Test/TextureDataTest.cpp b/src/Magnum/Trade/Test/TextureDataTest.cpp index ce0cd1122..5f7d27be7 100644 --- a/src/Magnum/Trade/Test/TextureDataTest.cpp +++ b/src/Magnum/Trade/Test/TextureDataTest.cpp @@ -64,7 +64,7 @@ void TextureDataTest::construct() { CORRADE_COMPARE(data.minificationFilter(), SamplerFilter::Linear); CORRADE_COMPARE(data.magnificationFilter(), SamplerFilter::Nearest); CORRADE_COMPARE(data.mipmapFilter(), SamplerMipmap::Nearest); - CORRADE_COMPARE(data.wrapping(), (Array3D{SamplerWrapping::Repeat, SamplerWrapping::ClampToEdge, SamplerWrapping::MirroredRepeat})); + CORRADE_COMPARE(data.wrapping(), (Math::Vector3{SamplerWrapping::Repeat, SamplerWrapping::ClampToEdge, SamplerWrapping::MirroredRepeat})); CORRADE_COMPARE(data.image(), 42); CORRADE_COMPARE(data.importerState(), &a); } @@ -90,7 +90,7 @@ void TextureDataTest::constructMove() { CORRADE_COMPARE(b.minificationFilter(), SamplerFilter::Linear); CORRADE_COMPARE(b.magnificationFilter(), SamplerFilter::Nearest); CORRADE_COMPARE(b.mipmapFilter(), SamplerMipmap::Nearest); - CORRADE_COMPARE(b.wrapping(), (Array3D{SamplerWrapping::Repeat, SamplerWrapping::ClampToEdge, SamplerWrapping::MirroredRepeat})); + CORRADE_COMPARE(b.wrapping(), (Math::Vector3{SamplerWrapping::Repeat, SamplerWrapping::ClampToEdge, SamplerWrapping::MirroredRepeat})); CORRADE_COMPARE(b.image(), 42); CORRADE_COMPARE(b.importerState(), &a); @@ -108,7 +108,7 @@ void TextureDataTest::constructMove() { CORRADE_COMPARE(d.minificationFilter(), SamplerFilter::Linear); CORRADE_COMPARE(d.magnificationFilter(), SamplerFilter::Nearest); CORRADE_COMPARE(d.mipmapFilter(), SamplerMipmap::Nearest); - CORRADE_COMPARE(d.wrapping(), (Array3D{SamplerWrapping::Repeat, SamplerWrapping::ClampToEdge, SamplerWrapping::MirroredRepeat})); + CORRADE_COMPARE(d.wrapping(), (Math::Vector3{SamplerWrapping::Repeat, SamplerWrapping::ClampToEdge, SamplerWrapping::MirroredRepeat})); CORRADE_COMPARE(d.image(), 42); CORRADE_COMPARE(d.importerState(), &a); diff --git a/src/Magnum/Trade/TextureData.h b/src/Magnum/Trade/TextureData.h index 1bdd2f270..f84109cb9 100644 --- a/src/Magnum/Trade/TextureData.h +++ b/src/Magnum/Trade/TextureData.h @@ -29,10 +29,15 @@ * @brief Class @ref Magnum::Trade::TextureData */ -#include "Magnum/Array.h" #include "Magnum/Sampler.h" +#include "Magnum/Math/Vector3.h" #include "Magnum/Trade/visibility.h" +#ifdef MAGNUM_BUILD_DEPRECATED +/* For implicit conversions to Vector, not used otherwise */ +#include "Magnum/Array.h" +#endif + namespace Magnum { namespace Trade { /** @@ -64,7 +69,15 @@ class TextureData { * @param image Texture image ID * @param importerState Importer-specific state */ - explicit TextureData(Type type, SamplerFilter minificationFilter, SamplerFilter magnificationFilter, SamplerMipmap mipmapFilter, Array3D wrapping, UnsignedInt image, const void* importerState = nullptr) noexcept: _type{type}, _minificationFilter{minificationFilter}, _magnificationFilter{magnificationFilter}, _mipmapFilter{mipmapFilter}, _wrapping{wrapping}, _image{image}, _importerState{importerState} {} + explicit TextureData(Type type, SamplerFilter minificationFilter, SamplerFilter magnificationFilter, SamplerMipmap mipmapFilter, const Math::Vector3& wrapping, UnsignedInt image, const void* importerState = nullptr) noexcept: _type{type}, _minificationFilter{minificationFilter}, _magnificationFilter{magnificationFilter}, _mipmapFilter{mipmapFilter}, _wrapping{wrapping}, _image{image}, _importerState{importerState} {} + + /** + * @brief Construct with the same wrapping for all dimensions + * + * Same as calling @ref TextureData(Type, SamplerFilter, SamplerFilter, SamplerMipmap, const Math::Vector3&, UnsignedInt, const void*) + * with the same @p wrapping value for all dimensions. + */ + explicit TextureData(Type type, SamplerFilter minificationFilter, SamplerFilter magnificationFilter, SamplerMipmap mipmapFilter, SamplerWrapping wrapping, UnsignedInt image, const void* importerState = nullptr) noexcept: _type{type}, _minificationFilter{minificationFilter}, _magnificationFilter{magnificationFilter}, _mipmapFilter{mipmapFilter}, _wrapping{wrapping}, _image{image}, _importerState{importerState} {} /** @brief Copying is not allowed */ TextureData(const TextureData&) = delete; @@ -91,7 +104,7 @@ class TextureData { SamplerMipmap mipmapFilter() const { return _mipmapFilter; } /** @brief Wrapping */ - Array3D wrapping() const { return _wrapping; } + Math::Vector3 wrapping() const { return _wrapping; } /** * @brief Image ID @@ -115,7 +128,7 @@ class TextureData { Type _type; SamplerFilter _minificationFilter, _magnificationFilter; SamplerMipmap _mipmapFilter; - Array3D _wrapping; + Math::Vector3 _wrapping; UnsignedInt _image; const void* _importerState; }; diff --git a/src/Magnum/Vk/Enums.h b/src/Magnum/Vk/Enums.h index 0d67bc260..838f4f084 100644 --- a/src/Magnum/Vk/Enums.h +++ b/src/Magnum/Vk/Enums.h @@ -29,7 +29,8 @@ * @brief Function @ref Magnum::Vk::hasVkPrimitiveTopology(), @ref Magnum::Vk::vkPrimitiveTopology(), @ref Magnum::Vk::hasVkIndexType(), @ref Magnum::Vk::vkIndexType(), @ref Magnum::Vk::hasVkFormat(), @ref Magnum::Vk::vkFormat(), @ref Magnum::Vk::vkFilter(), @ref Magnum::Vk::vkSamplerMipmapMode(), @ref Magnum::Vk::hasVkSamplerAddressMode(), @ref Magnum::Vk::vkSamplerAddressMode() */ -#include "Magnum/Array.h" +#include "Magnum/Magnum.h" +#include "Magnum/Math/Vector3.h" #include "Magnum/Vk/Vulkan.h" #include "Magnum/Vk/visibility.h" @@ -37,6 +38,11 @@ #include #endif +#ifdef MAGNUM_BUILD_DEPRECATED +/* For implicit conversions to Vector, not used otherwise */ +#include "Magnum/Array.h" +#endif + namespace Magnum { namespace Vk { #ifdef MAGNUM_BUILD_DEPRECATED @@ -147,8 +153,8 @@ to query availability of given mode. MAGNUM_VK_EXPORT VkSamplerAddressMode vkSamplerAddressMode(Magnum::SamplerWrapping wrapping); /** @overload */ -template Array vkSamplerAddressMode(const Array& wrapping) { - Array out; /** @todo NoInit */ +template Math::Vector vkSamplerAddressMode(const Math::Vector& wrapping) { + Math::Vector out{NoInit}; for(std::size_t i = 0; i != dimensions; ++i) out[i] = vkSamplerAddressMode(wrapping[i]); return out; diff --git a/src/Magnum/Vk/Test/EnumsTest.cpp b/src/Magnum/Vk/Test/EnumsTest.cpp index a365fbffc..503f11ef6 100644 --- a/src/Magnum/Vk/Test/EnumsTest.cpp +++ b/src/Magnum/Vk/Test/EnumsTest.cpp @@ -115,7 +115,7 @@ void EnumsTest::mapVkSamplerAddressMode() { } void EnumsTest::mapVkSamplerAddressModeArray() { - CORRADE_COMPARE(vkSamplerAddressMode<2>({SamplerWrapping::Repeat, SamplerWrapping::ClampToBorder}), (Array2D{VK_SAMPLER_ADDRESS_MODE_REPEAT, VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER})); + CORRADE_COMPARE(vkSamplerAddressMode<2>({SamplerWrapping::Repeat, SamplerWrapping::ClampToBorder}), (Math::Vector2{VK_SAMPLER_ADDRESS_MODE_REPEAT, VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER})); } void EnumsTest::mapVkSamplerAddressModeUnsupported() {