Browse Source

Deprecate the weird Magnum::Array class.

Its only use was for specifying N-dimensional SamplerWrapping because,
compared to a Math::Vector, it had an implicit constructor from a single
value (whereas the Vector has it explicit). I solved that by simply
adding a few single-value overloads where it mattered. There, done. No
need for this weird thing and confusion with Containers::Array anymore.

All places that used it now use Math::VectorN<SamplerWrapping>, but the
class is still included for backwards compatibility purposes, together
with providing implicit conversion from and to a Vector.
euler-xxx
Vladimír Vondruš 5 years ago
parent
commit
cc5f2d7862
  1. 12
      doc/changelog.dox
  2. 68
      src/Magnum/Array.h
  3. 5
      src/Magnum/CMakeLists.txt
  4. 9
      src/Magnum/GL/AbstractTexture.cpp
  5. 6
      src/Magnum/GL/AbstractTexture.h
  6. 26
      src/Magnum/GL/CubeMapTexture.h
  7. 26
      src/Magnum/GL/CubeMapTextureArray.h
  8. 26
      src/Magnum/GL/RectangleTexture.h
  9. 11
      src/Magnum/GL/Sampler.h
  10. 8
      src/Magnum/GL/Test/SamplerTest.cpp
  11. 26
      src/Magnum/GL/Texture.h
  12. 26
      src/Magnum/GL/TextureArray.h
  13. 14
      src/Magnum/Magnum.h
  14. 2
      src/Magnum/Test/ArrayTest.cpp
  15. 7
      src/Magnum/Test/CMakeLists.txt
  16. 6
      src/Magnum/Trade/Test/TextureDataTest.cpp
  17. 21
      src/Magnum/Trade/TextureData.h
  18. 12
      src/Magnum/Vk/Enums.h
  19. 2
      src/Magnum/Vk/Test/EnumsTest.cpp

12
doc/changelog.dox

@ -380,6 +380,18 @@ See also:
@subsection changelog-latest-deprecated Deprecated APIs @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 - Markup styling for Emscripten application was switched to prefer using
CSS classes instead of the @cb{.css} #container @ce, @cb{.css} #sizer @ce, 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, @cb{.css} #expander @ce, @cb{.css} #listener @ce, @cb{.css} #canvas @ce,

68
src/Magnum/Array.h

@ -25,15 +25,26 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
*/ */
#ifdef MAGNUM_BUILD_DEPRECATED
/** @file /** @file
* @brief Class @ref Magnum::Array, @ref Magnum::Array1D, @ref Magnum::Array2D, @ref Magnum::Array3D * @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 <type_traits> #include <type_traits>
#include <Corrade/Containers/sequenceHelpers.h> #include <Corrade/Containers/sequenceHelpers.h>
#include <Corrade/Utility/Debug.h> #include <Corrade/Utility/Debug.h>
#include <Corrade/Utility/Macros.h>
#include "Magnum/Magnum.h" #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 { namespace Magnum {
@ -45,13 +56,12 @@ namespace Implementation {
@brief Array @brief Array
@tparam dimensions Dimension count @tparam dimensions Dimension count
@tparam T Data type @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 Unlike @ref Math::Vector this class has implicit constructor from one value.
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.
@see @ref Array1D, @ref Array2D, @ref Array3D @see @ref Array1D, @ref Array2D, @ref Array3D
*/ */
template<UnsignedInt dimensions, class T> class Array { template<UnsignedInt dimensions, class T> class CORRADE_DEPRECATED("use Math::Vector instead") Array {
public: public:
typedef T Type; /**< @brief Data type */ typedef T Type; /**< @brief Data type */
@ -85,6 +95,12 @@ template<UnsignedInt dimensions, class T> class Array {
constexpr /*implicit*/ Array(U value): Array(typename Containers::Implementation::GenerateSequence<dimensions>::Type{}, value) {} constexpr /*implicit*/ Array(U value): Array(typename Containers::Implementation::GenerateSequence<dimensions>::Type{}, value) {}
#endif #endif
/** @brief Convert to a vector */
/*implicit*/ operator Math::Vector<dimensions, T>() const {
return Math::Vector<dimensions, T>::from(_data);
}
CORRADE_IGNORE_DEPRECATED_PUSH
/** @brief Equality */ /** @brief Equality */
bool operator==(const Array<dimensions, T>& other) const { bool operator==(const Array<dimensions, T>& other) const {
for(UnsignedInt i = 0; i != dimensions; ++i) for(UnsignedInt i = 0; i != dimensions; ++i)
@ -96,6 +112,7 @@ template<UnsignedInt dimensions, class T> class Array {
bool operator!=(const Array<dimensions, T>& other) const { bool operator!=(const Array<dimensions, T>& other) const {
return !operator==(other); return !operator==(other);
} }
CORRADE_IGNORE_DEPRECATED_POP
/** @brief Value at given position */ /** @brief Value at given position */
T& operator[](UnsignedInt pos) { return _data[pos]; } T& operator[](UnsignedInt pos) { return _data[pos]; }
@ -120,11 +137,13 @@ template<UnsignedInt dimensions, class T> class Array {
template<std::size_t ...sequence> constexpr explicit Array(Containers::Implementation::Sequence<sequence...>, T value): _data{Implementation::repeat(value, sequence)...} {} template<std::size_t ...sequence> constexpr explicit Array(Containers::Implementation::Sequence<sequence...>, T value): _data{Implementation::repeat(value, sequence)...} {}
}; };
CORRADE_IGNORE_DEPRECATED_PUSH
/** /**
@brief One-dimensional array @brief One-dimensional array
@tparam T Data type @tparam T Data type
@m_deprecated_since_latest Use @ref Math::Vector instead.
*/ */
template<class T> class Array1D: public Array<1, T> { template<class T> class CORRADE_DEPRECATED("use Math::Vector instead") Array1D: public Array<1, T> {
public: public:
/** @copydoc Array::Array() */ /** @copydoc Array::Array() */
constexpr /*implicit*/ Array1D() = default; constexpr /*implicit*/ Array1D() = default;
@ -135,6 +154,9 @@ template<class T> class Array1D: public Array<1, T> {
*/ */
constexpr /*implicit*/ Array1D(T x): Array<1, T>(x) {} 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 */ T& x() { return Array<1, T>::_data[0]; } /**< @brief X component */
constexpr T x() const { return Array<1, T>::_data[0]; } /**< @overload */ constexpr T x() const { return Array<1, T>::_data[0]; } /**< @overload */
}; };
@ -142,8 +164,9 @@ template<class T> class Array1D: public Array<1, T> {
/** /**
@brief Two-dimensional array @brief Two-dimensional array
@tparam T Data type @tparam T Data type
@m_deprecated_since_latest Use @ref Math::Vector2 instead.
*/ */
template<class T> class Array2D: public Array<2, T> { template<class T> class CORRADE_DEPRECATED("use Math::Vector2 instead") Array2D: public Array<2, T> {
public: public:
/** @copydoc Array::Array() */ /** @copydoc Array::Array() */
constexpr /*implicit*/ Array2D() = default; constexpr /*implicit*/ Array2D() = default;
@ -155,6 +178,9 @@ template<class T> class Array2D: public Array<2, T> {
*/ */
constexpr /*implicit*/ Array2D(T x, T y): Array<2, T>(x, y) {} constexpr /*implicit*/ Array2D(T x, T y): Array<2, T>(x, y) {}
/** @brief Construct from a vector */
constexpr /*implicit*/ Array2D(const Math::Vector2<T>& vector): Array2D{vector.x(), vector.y()} {}
/** @brief Initializer-list constructor */ /** @brief Initializer-list constructor */
constexpr /*implicit*/ Array2D(T value): Array<2, T>(value, value) {} constexpr /*implicit*/ Array2D(T value): Array<2, T>(value, value) {}
@ -167,8 +193,9 @@ template<class T> class Array2D: public Array<2, T> {
/** /**
@brief Three-dimensional array @brief Three-dimensional array
@tparam T Data type @tparam T Data type
@m_deprecated_since_latest Use @ref Math::Vector3 instead.
*/ */
template<class T> class Array3D: public Array<3, T> { template<class T> class CORRADE_DEPRECATED("use Math::Vector3 instead") Array3D: public Array<3, T> {
public: public:
/** @copydoc Array::Array() */ /** @copydoc Array::Array() */
constexpr /*implicit*/ Array3D() {} constexpr /*implicit*/ Array3D() {}
@ -181,6 +208,9 @@ template<class T> class Array3D: public Array<3, T> {
*/ */
constexpr /*implicit*/ Array3D(T x, T y, T z): Array<3, T>(x, y, z) {} 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<T>& vector): Array3D{vector.x(), vector.y(), vector.z()} {}
/** @brief Initializer-list constructor */ /** @brief Initializer-list constructor */
constexpr /*implicit*/ Array3D(T value): Array<3, T>(value, value, value) {} constexpr /*implicit*/ Array3D(T value): Array<3, T>(value, value, value) {}
@ -201,7 +231,10 @@ template<class T> class Array3D: public Array<3, T> {
} /**< @overload */ } /**< @overload */
}; };
/** @debugoperator{Array} */ /**
@debugoperator{Array}
@m_deprecated_since_latest Use @ref Math::Vector instead.
*/
template<UnsignedInt dimensions, class T> Debug& operator<<(Debug& debug, const Array<dimensions, T>& value) { template<UnsignedInt dimensions, class T> Debug& operator<<(Debug& debug, const Array<dimensions, T>& value) {
debug << "Array(" << Debug::nospace; debug << "Array(" << Debug::nospace;
for(UnsignedInt i = 0; i != dimensions; ++i) { for(UnsignedInt i = 0; i != dimensions; ++i) {
@ -211,21 +244,34 @@ template<UnsignedInt dimensions, class T> Debug& operator<<(Debug& debug, const
return debug << Debug::nospace << ")"; return debug << Debug::nospace << ")";
} }
/** @debugoperator{Array1D} */ /**
@debugoperator{Array1D}
@m_deprecated_since_latest Use @ref Math::Vector instead.
*/
template<class T> inline Debug& operator<<(Debug& debug, const Array1D<T>& value) { template<class T> inline Debug& operator<<(Debug& debug, const Array1D<T>& value) {
return debug << static_cast<const Array<1, T>&>(value); return debug << static_cast<const Array<1, T>&>(value);
} }
/** @debugoperator{Array2D} */ /**
@debugoperator{Array2D}
@m_deprecated_since_latest Use @ref Math::Vector2 instead.
*/
template<class T> inline Debug& operator<<(Debug& debug, const Array2D<T>& value) { template<class T> inline Debug& operator<<(Debug& debug, const Array2D<T>& value) {
return debug << static_cast<const Array<2, T>&>(value); return debug << static_cast<const Array<2, T>&>(value);
} }
/** @debugoperator{Array3D} */ /**
@debugoperator{Array3D}
@m_deprecated_since_latest Use @ref Math::Vector3 instead.
*/
template<class T> inline Debug& operator<<(Debug& debug, const Array3D<T>& value) { template<class T> inline Debug& operator<<(Debug& debug, const Array3D<T>& value) {
return debug << static_cast<const Array<3, T>&>(value); return debug << static_cast<const Array<3, T>&>(value);
} }
CORRADE_IGNORE_DEPRECATED_POP
} }
#else
#error use Magnum/Math/Vector3.h instead
#endif
#endif #endif

5
src/Magnum/CMakeLists.txt

@ -75,7 +75,6 @@ set(Magnum_GracefulAssert_SRCS
set(Magnum_HEADERS set(Magnum_HEADERS
AbstractResourceLoader.h AbstractResourceLoader.h
Array.h
British.h British.h
DimensionTraits.h DimensionTraits.h
FileCallback.h FileCallback.h
@ -104,6 +103,10 @@ set(Magnum_PRIVATE_HEADERS
Implementation/pixelFormatMapping.hpp Implementation/pixelFormatMapping.hpp
Implementation/vertexFormatMapping.hpp) Implementation/vertexFormatMapping.hpp)
if(MAGNUM_BUILD_DEPRECATED)
list(APPEND Magnum_HEADERS Array.h)
endif()
# Functionality specific to static Windows builds # Functionality specific to static Windows builds
if(CORRADE_TARGET_WINDOWS AND NOT CORRADE_TARGET_WINDOWS_RT AND MAGNUM_BUILD_STATIC) if(CORRADE_TARGET_WINDOWS AND NOT CORRADE_TARGET_WINDOWS_RT AND MAGNUM_BUILD_STATIC)
list(APPEND Magnum_SRCS Implementation/WindowsWeakSymbol.cpp) list(APPEND Magnum_SRCS Implementation/WindowsWeakSymbol.cpp)

9
src/Magnum/GL/AbstractTexture.cpp

@ -28,7 +28,6 @@
#include <tuple> #include <tuple>
#include <Corrade/Containers/Array.h> #include <Corrade/Containers/Array.h>
#include "Magnum/Array.h"
#include "Magnum/Image.h" #include "Magnum/Image.h"
#include "Magnum/ImageView.h" #include "Magnum/ImageView.h"
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
@ -2354,12 +2353,12 @@ void AbstractTexture::DataHelper<3>::invalidateSubImage(AbstractTexture& texture
} }
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void AbstractTexture::DataHelper<1>::setWrapping(AbstractTexture& texture, const Array1D<SamplerWrapping>& wrapping) { 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.x())); (texture.*Context::current().state().texture.parameteriImplementation)(GL_TEXTURE_WRAP_S, GLint(wrapping[0]));
} }
#endif #endif
void AbstractTexture::DataHelper<2>::setWrapping(AbstractTexture& texture, const Array2D<SamplerWrapping>& wrapping) { void AbstractTexture::DataHelper<2>::setWrapping(AbstractTexture& texture, const Math::Vector2<SamplerWrapping>& wrapping) {
const Implementation::TextureState& state = Context::current().state().texture; const Implementation::TextureState& state = Context::current().state().texture;
(texture.*state.parameteriImplementation)(GL_TEXTURE_WRAP_S, GLint(wrapping.x())); (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)) #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
void AbstractTexture::DataHelper<3>::setWrapping(AbstractTexture& texture, const Array3D<SamplerWrapping>& wrapping) { void AbstractTexture::DataHelper<3>::setWrapping(AbstractTexture& texture, const Math::Vector3<SamplerWrapping>& wrapping) {
const Implementation::TextureState& state = Context::current().state().texture; const Implementation::TextureState& state = Context::current().state().texture;
(texture.*state.parameteriImplementation)(GL_TEXTURE_WRAP_S, GLint(wrapping.x())); (texture.*state.parameteriImplementation)(GL_TEXTURE_WRAP_S, GLint(wrapping.x()));

6
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> compressedBlockSize(GLenum target, TextureFormat format);
static Math::Vector<1, GLint> imageSize(AbstractTexture& texture, GLint level); static Math::Vector<1, GLint> imageSize(AbstractTexture& texture, GLint level);
static void setWrapping(AbstractTexture& texture, const Array1D<SamplerWrapping>& 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); 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); static Vector2i imageSize(AbstractTexture& texture, GLint level);
#endif #endif
static void setWrapping(AbstractTexture& texture, const Array2D<SamplerWrapping>& wrapping); static void setWrapping(AbstractTexture& texture, const Math::Vector2<SamplerWrapping>& wrapping);
static void setStorage(AbstractTexture& texture, GLsizei levels, TextureFormat internalFormat, const Vector2i& size); 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); static Vector3i imageSize(AbstractTexture& texture, GLint level);
#endif #endif
static void setWrapping(AbstractTexture& texture, const Array3D<SamplerWrapping>& wrapping); static void setWrapping(AbstractTexture& texture, const Math::Vector3<SamplerWrapping>& wrapping);
static void setStorage(AbstractTexture& texture, GLsizei levels, TextureFormat internalFormat, const Vector3i& size); static void setStorage(AbstractTexture& texture, GLsizei levels, TextureFormat internalFormat, const Vector3i& size);

26
src/Magnum/GL/CubeMapTexture.h

@ -29,12 +29,16 @@
* @brief Class @ref Magnum::GL::CubeMapTexture, enum @ref Magnum::GL::CubeMapCoordinate * @brief Class @ref Magnum::GL::CubeMapTexture, enum @ref Magnum::GL::CubeMapCoordinate
*/ */
#include "Magnum/Array.h"
#include "Magnum/Sampler.h" #include "Magnum/Sampler.h"
#include "Magnum/GL/AbstractTexture.h" #include "Magnum/GL/AbstractTexture.h"
#include "Magnum/GL/Sampler.h" #include "Magnum/GL/Sampler.h"
#include "Magnum/Math/Vector2.h" #include "Magnum/Math/Vector2.h"
#ifdef MAGNUM_BUILD_DEPRECATED
/* For implicit conversions to Vector<SamplerWrapping>, not used otherwise */
#include "Magnum/Array.h"
#endif
namespace Magnum { namespace GL { namespace Magnum { namespace GL {
/** /**
@ -348,16 +352,32 @@ class MAGNUM_GL_EXPORT CubeMapTexture: public AbstractTexture {
* *
* See @ref Texture::setWrapping() for more information. * See @ref Texture::setWrapping() for more information.
*/ */
CubeMapTexture& setWrapping(const Array2D<SamplerWrapping>& wrapping) { CubeMapTexture& setWrapping(const Math::Vector2<SamplerWrapping>& wrapping) {
DataHelper<2>::setWrapping(*this, wrapping); DataHelper<2>::setWrapping(*this, wrapping);
return *this; return *this;
} }
/** @overload */ /** @overload */
CubeMapTexture& setWrapping(const Array2D<Magnum::SamplerWrapping>& wrapping) { CubeMapTexture& setWrapping(const Math::Vector2<Magnum::SamplerWrapping>& wrapping) {
return setWrapping(samplerWrapping(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<SamplerWrapping>&)
* with the same value for all dimensions.
*/
CubeMapTexture& setWrapping(SamplerWrapping wrapping) {
return setWrapping(Math::Vector2<SamplerWrapping>{wrapping});
}
/** @overload */
CubeMapTexture& setWrapping(Magnum::SamplerWrapping wrapping) {
return setWrapping(Math::Vector2<Magnum::SamplerWrapping>{wrapping});
}
#ifndef MAGNUM_TARGET_WEBGL #ifndef MAGNUM_TARGET_WEBGL
/** /**
* @brief @copybrief Texture::setBorderColor(const Color4&) * @brief @copybrief Texture::setBorderColor(const Color4&)

26
src/Magnum/GL/CubeMapTextureArray.h

@ -31,12 +31,16 @@
*/ */
#endif #endif
#include "Magnum/Array.h"
#include "Magnum/Sampler.h" #include "Magnum/Sampler.h"
#include "Magnum/GL/AbstractTexture.h" #include "Magnum/GL/AbstractTexture.h"
#include "Magnum/GL/Sampler.h" #include "Magnum/GL/Sampler.h"
#include "Magnum/Math/Vector3.h" #include "Magnum/Math/Vector3.h"
#ifdef MAGNUM_BUILD_DEPRECATED
/* For implicit conversions to Vector<SamplerWrapping>, not used otherwise */
#include "Magnum/Array.h"
#endif
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
namespace Magnum { namespace GL { namespace Magnum { namespace GL {
@ -313,16 +317,32 @@ class MAGNUM_GL_EXPORT CubeMapTextureArray: public AbstractTexture {
* *
* See @ref Texture::setWrapping() for more information. * See @ref Texture::setWrapping() for more information.
*/ */
CubeMapTextureArray& setWrapping(const Array2D<SamplerWrapping>& wrapping) { CubeMapTextureArray& setWrapping(const Math::Vector2<SamplerWrapping>& wrapping) {
DataHelper<2>::setWrapping(*this, wrapping); DataHelper<2>::setWrapping(*this, wrapping);
return *this; return *this;
} }
/** @overload */ /** @overload */
CubeMapTextureArray& setWrapping(const Array2D<Magnum::SamplerWrapping>& wrapping) { CubeMapTextureArray& setWrapping(const Math::Vector2<Magnum::SamplerWrapping>& wrapping) {
return setWrapping(samplerWrapping(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<SamplerWrapping>&)
* with the same value for all dimensions.
*/
CubeMapTextureArray& setWrapping(SamplerWrapping wrapping) {
return setWrapping(Math::Vector2<SamplerWrapping>{wrapping});
}
/** @overload */
CubeMapTextureArray& setWrapping(Magnum::SamplerWrapping wrapping) {
return setWrapping(Math::Vector2<Magnum::SamplerWrapping>{wrapping});
}
/** /**
* @brief @copybrief Texture::setBorderColor(const Color4&) * @brief @copybrief Texture::setBorderColor(const Color4&)
* @return Reference to self (for method chaining) * @return Reference to self (for method chaining)

26
src/Magnum/GL/RectangleTexture.h

@ -31,12 +31,16 @@
*/ */
#endif #endif
#include "Magnum/Array.h"
#include "Magnum/Sampler.h" #include "Magnum/Sampler.h"
#include "Magnum/GL/AbstractTexture.h" #include "Magnum/GL/AbstractTexture.h"
#include "Magnum/GL/Sampler.h" #include "Magnum/GL/Sampler.h"
#include "Magnum/Math/Vector2.h" #include "Magnum/Math/Vector2.h"
#ifdef MAGNUM_BUILD_DEPRECATED
/* For implicit conversions to Vector<SamplerWrapping>, not used otherwise */
#include "Magnum/Array.h"
#endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
namespace Magnum { namespace GL { namespace Magnum { namespace GL {
@ -214,16 +218,32 @@ class MAGNUM_GL_EXPORT RectangleTexture: public AbstractTexture {
* @ref SamplerWrapping::ClampToBorder is supported on this * @ref SamplerWrapping::ClampToBorder is supported on this
* texture type. * texture type.
*/ */
RectangleTexture& setWrapping(const Array2D<SamplerWrapping>& wrapping) { RectangleTexture& setWrapping(const Math::Vector2<SamplerWrapping>& wrapping) {
DataHelper<2>::setWrapping(*this, wrapping); DataHelper<2>::setWrapping(*this, wrapping);
return *this; return *this;
} }
/** @overload */ /** @overload */
RectangleTexture& setWrapping(const Array2D<Magnum::SamplerWrapping>& wrapping) { RectangleTexture& setWrapping(const Math::Vector2<Magnum::SamplerWrapping>& wrapping) {
return setWrapping(samplerWrapping(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<SamplerWrapping>&)
* with the same value for all dimensions.
*/
RectangleTexture& setWrapping(SamplerWrapping wrapping) {
return setWrapping(Math::Vector2<SamplerWrapping>{wrapping});
}
/** @overload */
RectangleTexture& setWrapping(Magnum::SamplerWrapping wrapping) {
return setWrapping(Math::Vector2<Magnum::SamplerWrapping>{wrapping});
}
/** /**
* @brief @copybrief Texture::setBorderColor(const Color4&) * @brief @copybrief Texture::setBorderColor(const Color4&)
* @return Reference to self (for method chaining) * @return Reference to self (for method chaining)

11
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() * @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/Magnum.h"
#include "Magnum/GL/OpenGL.h" #include "Magnum/GL/OpenGL.h"
#include "Magnum/GL/visibility.h" #include "Magnum/GL/visibility.h"
#include "Magnum/Math/Vector3.h"
#ifdef MAGNUM_BUILD_DEPRECATED
/* For implicit conversions to Vector<SamplerWrapping>, not used otherwise */
#include "Magnum/Array.h"
#endif
namespace Magnum { namespace GL { 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); MAGNUM_GL_EXPORT SamplerWrapping samplerWrapping(Magnum::SamplerWrapping wrapping);
/** @overload */ /** @overload */
template<UnsignedInt dimensions> Array<dimensions, SamplerWrapping> samplerWrapping(const Array<dimensions, Magnum::SamplerWrapping>& wrapping) { template<std::size_t dimensions> Math::Vector<dimensions, SamplerWrapping> samplerWrapping(const Math::Vector<dimensions, Magnum::SamplerWrapping>& wrapping) {
Array<dimensions, SamplerWrapping> out; /** @todo NoInit */ Math::Vector<dimensions, SamplerWrapping> out{NoInit};
for(std::size_t i = 0; i != dimensions; ++i) for(std::size_t i = 0; i != dimensions; ++i)
out[i] = samplerWrapping(wrapping[i]); out[i] = samplerWrapping(wrapping[i]);
return out; return out;

8
src/Magnum/GL/Test/SamplerTest.cpp

@ -40,7 +40,7 @@ struct SamplerTest: TestSuite::Tester {
void mapMipmap(); void mapMipmap();
void mapMipmapInvalid(); void mapMipmapInvalid();
void mapWrapping(); void mapWrapping();
void mapWrappingArray(); void mapWrappingVector();
void mapWrappingInvalid(); void mapWrappingInvalid();
void mapWrappingUnsupported(); void mapWrappingUnsupported();
@ -62,7 +62,7 @@ SamplerTest::SamplerTest() {
&SamplerTest::mapMipmap, &SamplerTest::mapMipmap,
&SamplerTest::mapMipmapInvalid, &SamplerTest::mapMipmapInvalid,
&SamplerTest::mapWrapping, &SamplerTest::mapWrapping,
&SamplerTest::mapWrappingArray, &SamplerTest::mapWrappingVector,
&SamplerTest::mapWrappingInvalid, &SamplerTest::mapWrappingInvalid,
&SamplerTest::mapWrappingUnsupported, &SamplerTest::mapWrappingUnsupported,
@ -137,8 +137,8 @@ void SamplerTest::mapWrapping() {
#endif #endif
} }
void SamplerTest::mapWrappingArray() { void SamplerTest::mapWrappingVector() {
CORRADE_COMPARE(samplerWrapping<2>({Magnum::SamplerWrapping::Repeat, Magnum::SamplerWrapping::ClampToEdge}), (Array2D<SamplerWrapping>{SamplerWrapping::Repeat, SamplerWrapping::ClampToEdge})); CORRADE_COMPARE(samplerWrapping<2>({Magnum::SamplerWrapping::Repeat, Magnum::SamplerWrapping::ClampToEdge}), (Math::Vector2<SamplerWrapping>{SamplerWrapping::Repeat, SamplerWrapping::ClampToEdge}));
} }
void SamplerTest::mapWrappingInvalid() { void SamplerTest::mapWrappingInvalid() {

26
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 * @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/Sampler.h"
#include "Magnum/DimensionTraits.h" #include "Magnum/DimensionTraits.h"
#include "Magnum/GL/AbstractTexture.h" #include "Magnum/GL/AbstractTexture.h"
#include "Magnum/GL/Sampler.h" #include "Magnum/GL/Sampler.h"
#include "Magnum/Math/Vector3.h" #include "Magnum/Math/Vector3.h"
#ifdef MAGNUM_BUILD_DEPRECATED
/* For implicit conversions to Vector<SamplerWrapping>, not used otherwise */
#include "Magnum/Array.h"
#endif
namespace Magnum { namespace GL { namespace Magnum { namespace GL {
namespace Implementation { namespace Implementation {
@ -468,16 +472,32 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* @fn_gl_keyword{TexParameter} with @def_gl_keyword{TEXTURE_WRAP_S}, * @fn_gl_keyword{TexParameter} with @def_gl_keyword{TEXTURE_WRAP_S},
* @def_gl_keyword{TEXTURE_WRAP_T}, @def_gl_keyword{TEXTURE_WRAP_R} * @def_gl_keyword{TEXTURE_WRAP_T}, @def_gl_keyword{TEXTURE_WRAP_R}
*/ */
Texture<dimensions>& setWrapping(const Array<dimensions, SamplerWrapping>& wrapping) { Texture<dimensions>& setWrapping(const Math::Vector<dimensions, SamplerWrapping>& wrapping) {
DataHelper<dimensions>::setWrapping(*this, wrapping); DataHelper<dimensions>::setWrapping(*this, wrapping);
return *this; return *this;
} }
/** @overload */ /** @overload */
Texture<dimensions>& setWrapping(const Array<dimensions, Magnum::SamplerWrapping>& wrapping) { Texture<dimensions>& setWrapping(const Math::Vector<dimensions, Magnum::SamplerWrapping>& wrapping) {
return setWrapping(samplerWrapping(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<dimensions, SamplerWrapping>&)
* with the same value for all dimensions.
*/
Texture<dimensions>& setWrapping(SamplerWrapping wrapping) {
return setWrapping(Math::Vector<dimensions, SamplerWrapping>{wrapping});
}
/** @overload */
Texture<dimensions>& setWrapping(Magnum::SamplerWrapping wrapping) {
return setWrapping(Math::Vector<dimensions, Magnum::SamplerWrapping>{wrapping});
}
#ifndef MAGNUM_TARGET_WEBGL #ifndef MAGNUM_TARGET_WEBGL
/** /**
* @brief Set border color * @brief Set border color

26
src/Magnum/GL/TextureArray.h

@ -31,13 +31,17 @@
*/ */
#endif #endif
#include "Magnum/Array.h"
#include "Magnum/Sampler.h" #include "Magnum/Sampler.h"
#include "Magnum/DimensionTraits.h" #include "Magnum/DimensionTraits.h"
#include "Magnum/GL/AbstractTexture.h" #include "Magnum/GL/AbstractTexture.h"
#include "Magnum/GL/Sampler.h" #include "Magnum/GL/Sampler.h"
#include "Magnum/Math/Vector3.h" #include "Magnum/Math/Vector3.h"
#ifdef MAGNUM_BUILD_DEPRECATED
/* For implicit conversions to Vector<SamplerWrapping>, not used otherwise */
#include "Magnum/Array.h"
#endif
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
namespace Magnum { namespace GL { namespace Magnum { namespace GL {
@ -333,16 +337,32 @@ template<UnsignedInt dimensions> class TextureArray: public AbstractTexture {
* *
* See @ref Texture::setWrapping() for more information. * See @ref Texture::setWrapping() for more information.
*/ */
TextureArray<dimensions>& setWrapping(const Array<dimensions, SamplerWrapping>& wrapping) { TextureArray<dimensions>& setWrapping(const Math::Vector<dimensions, SamplerWrapping>& wrapping) {
DataHelper<dimensions>::setWrapping(*this, wrapping); DataHelper<dimensions>::setWrapping(*this, wrapping);
return *this; return *this;
} }
/** @overload */ /** @overload */
TextureArray<dimensions>& setWrapping(const Array<dimensions, Magnum::SamplerWrapping>& wrapping) { TextureArray<dimensions>& setWrapping(const Math::Vector<dimensions, Magnum::SamplerWrapping>& wrapping) {
return setWrapping(samplerWrapping(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<dimensions, SamplerWrapping>&)
* with the same value for all dimensions.
*/
TextureArray<dimensions>& setWrapping(SamplerWrapping wrapping) {
return setWrapping(Math::Vector<dimensions, SamplerWrapping>{wrapping});
}
/** @overload */
TextureArray<dimensions>& setWrapping(Magnum::SamplerWrapping wrapping) {
return setWrapping(Math::Vector<dimensions, Magnum::SamplerWrapping>{wrapping});
}
#ifndef MAGNUM_TARGET_WEBGL #ifndef MAGNUM_TARGET_WEBGL
/** /**
* @brief @copybrief Texture::setBorderColor(const Color4&) * @brief @copybrief Texture::setBorderColor(const Color4&)

14
src/Magnum/Magnum.h

@ -34,6 +34,10 @@
#include "Magnum/Types.h" #include "Magnum/Types.h"
#include "Magnum/Math/Math.h" #include "Magnum/Math/Math.h"
#ifdef MAGNUM_BUILD_DEPRECATED
#include <Corrade/Utility/Macros.h>
#endif
namespace Magnum { namespace Magnum {
/* Bring whole Corrade namespace */ /* Bring whole Corrade namespace */
@ -1129,10 +1133,12 @@ typedef Math::Frustum<Double> Frustumd;
*/ */
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
template<UnsignedInt, class T> class Array; #ifdef MAGNUM_BUILD_DEPRECATED
template<class T> class Array1D; template<UnsignedInt, class T> class CORRADE_DEPRECATED("use Math::Vector instead") Array;
template<class T> class Array2D; template<class T> class CORRADE_DEPRECATED("use Math::Vector instead") Array1D;
template<class T> class Array3D; template<class T> class CORRADE_DEPRECATED("use Math::Vector2 instead") Array2D;
template<class T> class CORRADE_DEPRECATED("use Math::Vector3 instead") Array3D;
#endif
enum class InputFileCallbackPolicy: UnsignedByte; enum class InputFileCallbackPolicy: UnsignedByte;

2
src/Magnum/Test/ArrayTest.cpp

@ -41,6 +41,7 @@ struct ArrayTest: TestSuite::Tester {
void debug(); void debug();
}; };
CORRADE_IGNORE_DEPRECATED_PUSH
typedef Magnum::Array1D<Int> Array1D; typedef Magnum::Array1D<Int> Array1D;
typedef Magnum::Array2D<Int> Array2D; typedef Magnum::Array2D<Int> Array2D;
typedef Magnum::Array3D<Int> Array3D; typedef Magnum::Array3D<Int> 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}; 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_COMPARE(out.str(), "Array(5, 6, 7, 8) Array(13) Array(71, 2) Array(1, 2, 3)\n");
} }
CORRADE_IGNORE_DEPRECATED_POP
}}} }}}

7
src/Magnum/Test/CMakeLists.txt

@ -23,7 +23,6 @@
# DEALINGS IN THE SOFTWARE. # DEALINGS IN THE SOFTWARE.
# #
corrade_add_test(ArrayTest ArrayTest.cpp LIBRARIES Magnum)
corrade_add_test(FileCallbackTest FileCallbackTest.cpp LIBRARIES Magnum) corrade_add_test(FileCallbackTest FileCallbackTest.cpp LIBRARIES Magnum)
corrade_add_test(ImageTest ImageTest.cpp LIBRARIES MagnumTestLib) corrade_add_test(ImageTest ImageTest.cpp LIBRARIES MagnumTestLib)
corrade_add_test(ImageViewTest ImageViewTest.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) corrade_add_test(VertexFormatTest VertexFormatTest.cpp LIBRARIES MagnumTestLib)
set_target_properties( set_target_properties(
ArrayTest
ImageTest ImageTest
ImageViewTest ImageViewTest
MeshTest MeshTest
@ -54,6 +52,11 @@ set_target_properties(
VertexFormatTest VertexFormatTest
PROPERTIES FOLDER "Magnum/Test") 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 set_property(TARGET
MeshTest MeshTest
PixelFormatTest PixelFormatTest

6
src/Magnum/Trade/Test/TextureDataTest.cpp

@ -64,7 +64,7 @@ void TextureDataTest::construct() {
CORRADE_COMPARE(data.minificationFilter(), SamplerFilter::Linear); CORRADE_COMPARE(data.minificationFilter(), SamplerFilter::Linear);
CORRADE_COMPARE(data.magnificationFilter(), SamplerFilter::Nearest); CORRADE_COMPARE(data.magnificationFilter(), SamplerFilter::Nearest);
CORRADE_COMPARE(data.mipmapFilter(), SamplerMipmap::Nearest); CORRADE_COMPARE(data.mipmapFilter(), SamplerMipmap::Nearest);
CORRADE_COMPARE(data.wrapping(), (Array3D<SamplerWrapping>{SamplerWrapping::Repeat, SamplerWrapping::ClampToEdge, SamplerWrapping::MirroredRepeat})); CORRADE_COMPARE(data.wrapping(), (Math::Vector3<SamplerWrapping>{SamplerWrapping::Repeat, SamplerWrapping::ClampToEdge, SamplerWrapping::MirroredRepeat}));
CORRADE_COMPARE(data.image(), 42); CORRADE_COMPARE(data.image(), 42);
CORRADE_COMPARE(data.importerState(), &a); CORRADE_COMPARE(data.importerState(), &a);
} }
@ -90,7 +90,7 @@ void TextureDataTest::constructMove() {
CORRADE_COMPARE(b.minificationFilter(), SamplerFilter::Linear); CORRADE_COMPARE(b.minificationFilter(), SamplerFilter::Linear);
CORRADE_COMPARE(b.magnificationFilter(), SamplerFilter::Nearest); CORRADE_COMPARE(b.magnificationFilter(), SamplerFilter::Nearest);
CORRADE_COMPARE(b.mipmapFilter(), SamplerMipmap::Nearest); CORRADE_COMPARE(b.mipmapFilter(), SamplerMipmap::Nearest);
CORRADE_COMPARE(b.wrapping(), (Array3D<SamplerWrapping>{SamplerWrapping::Repeat, SamplerWrapping::ClampToEdge, SamplerWrapping::MirroredRepeat})); CORRADE_COMPARE(b.wrapping(), (Math::Vector3<SamplerWrapping>{SamplerWrapping::Repeat, SamplerWrapping::ClampToEdge, SamplerWrapping::MirroredRepeat}));
CORRADE_COMPARE(b.image(), 42); CORRADE_COMPARE(b.image(), 42);
CORRADE_COMPARE(b.importerState(), &a); CORRADE_COMPARE(b.importerState(), &a);
@ -108,7 +108,7 @@ void TextureDataTest::constructMove() {
CORRADE_COMPARE(d.minificationFilter(), SamplerFilter::Linear); CORRADE_COMPARE(d.minificationFilter(), SamplerFilter::Linear);
CORRADE_COMPARE(d.magnificationFilter(), SamplerFilter::Nearest); CORRADE_COMPARE(d.magnificationFilter(), SamplerFilter::Nearest);
CORRADE_COMPARE(d.mipmapFilter(), SamplerMipmap::Nearest); CORRADE_COMPARE(d.mipmapFilter(), SamplerMipmap::Nearest);
CORRADE_COMPARE(d.wrapping(), (Array3D<SamplerWrapping>{SamplerWrapping::Repeat, SamplerWrapping::ClampToEdge, SamplerWrapping::MirroredRepeat})); CORRADE_COMPARE(d.wrapping(), (Math::Vector3<SamplerWrapping>{SamplerWrapping::Repeat, SamplerWrapping::ClampToEdge, SamplerWrapping::MirroredRepeat}));
CORRADE_COMPARE(d.image(), 42); CORRADE_COMPARE(d.image(), 42);
CORRADE_COMPARE(d.importerState(), &a); CORRADE_COMPARE(d.importerState(), &a);

21
src/Magnum/Trade/TextureData.h

@ -29,10 +29,15 @@
* @brief Class @ref Magnum::Trade::TextureData * @brief Class @ref Magnum::Trade::TextureData
*/ */
#include "Magnum/Array.h"
#include "Magnum/Sampler.h" #include "Magnum/Sampler.h"
#include "Magnum/Math/Vector3.h"
#include "Magnum/Trade/visibility.h" #include "Magnum/Trade/visibility.h"
#ifdef MAGNUM_BUILD_DEPRECATED
/* For implicit conversions to Vector<SamplerWrapping>, not used otherwise */
#include "Magnum/Array.h"
#endif
namespace Magnum { namespace Trade { namespace Magnum { namespace Trade {
/** /**
@ -64,7 +69,15 @@ class TextureData {
* @param image Texture image ID * @param image Texture image ID
* @param importerState Importer-specific state * @param importerState Importer-specific state
*/ */
explicit TextureData(Type type, SamplerFilter minificationFilter, SamplerFilter magnificationFilter, SamplerMipmap mipmapFilter, Array3D<SamplerWrapping> 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<SamplerWrapping>& 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<SamplerWrapping>&, 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 */ /** @brief Copying is not allowed */
TextureData(const TextureData&) = delete; TextureData(const TextureData&) = delete;
@ -91,7 +104,7 @@ class TextureData {
SamplerMipmap mipmapFilter() const { return _mipmapFilter; } SamplerMipmap mipmapFilter() const { return _mipmapFilter; }
/** @brief Wrapping */ /** @brief Wrapping */
Array3D<SamplerWrapping> wrapping() const { return _wrapping; } Math::Vector3<SamplerWrapping> wrapping() const { return _wrapping; }
/** /**
* @brief Image ID * @brief Image ID
@ -115,7 +128,7 @@ class TextureData {
Type _type; Type _type;
SamplerFilter _minificationFilter, _magnificationFilter; SamplerFilter _minificationFilter, _magnificationFilter;
SamplerMipmap _mipmapFilter; SamplerMipmap _mipmapFilter;
Array3D<SamplerWrapping> _wrapping; Math::Vector3<SamplerWrapping> _wrapping;
UnsignedInt _image; UnsignedInt _image;
const void* _importerState; const void* _importerState;
}; };

12
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() * @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/Vulkan.h"
#include "Magnum/Vk/visibility.h" #include "Magnum/Vk/visibility.h"
@ -37,6 +38,11 @@
#include <Corrade/Utility/Macros.h> #include <Corrade/Utility/Macros.h>
#endif #endif
#ifdef MAGNUM_BUILD_DEPRECATED
/* For implicit conversions to Vector<SamplerWrapping>, not used otherwise */
#include "Magnum/Array.h"
#endif
namespace Magnum { namespace Vk { namespace Magnum { namespace Vk {
#ifdef MAGNUM_BUILD_DEPRECATED #ifdef MAGNUM_BUILD_DEPRECATED
@ -147,8 +153,8 @@ to query availability of given mode.
MAGNUM_VK_EXPORT VkSamplerAddressMode vkSamplerAddressMode(Magnum::SamplerWrapping wrapping); MAGNUM_VK_EXPORT VkSamplerAddressMode vkSamplerAddressMode(Magnum::SamplerWrapping wrapping);
/** @overload */ /** @overload */
template<UnsignedInt dimensions> Array<dimensions, VkSamplerAddressMode> vkSamplerAddressMode(const Array<dimensions, Magnum::SamplerWrapping>& wrapping) { template<std::size_t dimensions> Math::Vector<dimensions, VkSamplerAddressMode> vkSamplerAddressMode(const Math::Vector<dimensions, Magnum::SamplerWrapping>& wrapping) {
Array<dimensions, VkSamplerAddressMode> out; /** @todo NoInit */ Math::Vector<dimensions, VkSamplerAddressMode> out{NoInit};
for(std::size_t i = 0; i != dimensions; ++i) for(std::size_t i = 0; i != dimensions; ++i)
out[i] = vkSamplerAddressMode(wrapping[i]); out[i] = vkSamplerAddressMode(wrapping[i]);
return out; return out;

2
src/Magnum/Vk/Test/EnumsTest.cpp

@ -115,7 +115,7 @@ void EnumsTest::mapVkSamplerAddressMode() {
} }
void EnumsTest::mapVkSamplerAddressModeArray() { void EnumsTest::mapVkSamplerAddressModeArray() {
CORRADE_COMPARE(vkSamplerAddressMode<2>({SamplerWrapping::Repeat, SamplerWrapping::ClampToBorder}), (Array2D<VkSamplerAddressMode>{VK_SAMPLER_ADDRESS_MODE_REPEAT, VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER})); CORRADE_COMPARE(vkSamplerAddressMode<2>({SamplerWrapping::Repeat, SamplerWrapping::ClampToBorder}), (Math::Vector2<VkSamplerAddressMode>{VK_SAMPLER_ADDRESS_MODE_REPEAT, VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER}));
} }
void EnumsTest::mapVkSamplerAddressModeUnsupported() { void EnumsTest::mapVkSamplerAddressModeUnsupported() {

Loading…
Cancel
Save