From 06e526d7a1bd031b22c4e78e374a17d246672030 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 30 Nov 2012 18:24:31 +0100 Subject: [PATCH] Using Array instead of Vector for *Texture::setWrapping(). Allows simple and convenient call with one value for all axes instead of that unholy mess: texture.setWrapping(Texture2D::Wrapping::ClampToEdge); Previous way (for entertainment purposes): textute.setWrapping(Math::Vector2( Texture2D::Wrapping::ClampToEdge)); --- src/AbstractTexture.cpp | 6 +++--- src/AbstractTexture.h | 10 +++++----- src/CubeMapTexture.h | 2 +- src/CubeMapTextureArray.h | 2 +- src/Texture.h | 4 +--- 5 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/AbstractTexture.cpp b/src/AbstractTexture.cpp index 41fb407e6..e5ef0c416 100644 --- a/src/AbstractTexture.cpp +++ b/src/AbstractTexture.cpp @@ -378,16 +378,16 @@ AbstractTexture::InternalFormat::InternalFormat(AbstractTexture::Components comp #endif #ifndef DOXYGEN_GENERATING_OUTPUT -void AbstractTexture::DataHelper<2>::setWrapping(AbstractTexture* texture, const Math::Vector2& wrapping) { +void AbstractTexture::DataHelper<2>::setWrapping(AbstractTexture* texture, const Array2D& wrapping) { #ifndef MAGNUM_TARGET_GLES - CORRADE_ASSERT(texture->_target != GL_TEXTURE_RECTANGLE || ((wrapping[0] == Wrapping::ClampToEdge || wrapping[0] == Wrapping::ClampToBorder) && (wrapping[0] == Wrapping::ClampToEdge || wrapping[1] == Wrapping::ClampToEdge)), "AbstractTexture: rectangle texture wrapping must either clamp to border or to edge", ); + CORRADE_ASSERT(texture->_target != GL_TEXTURE_RECTANGLE || ((wrapping.x() == Wrapping::ClampToEdge || wrapping.x() == Wrapping::ClampToBorder) && (wrapping.y() == Wrapping::ClampToEdge || wrapping.y() == Wrapping::ClampToEdge)), "AbstractTexture: rectangle texture wrapping must either clamp to border or to edge", ); #endif (texture->*parameteriImplementation)(GL_TEXTURE_WRAP_S, static_cast(wrapping.x())); (texture->*parameteriImplementation)(GL_TEXTURE_WRAP_T, static_cast(wrapping.y())); } -void AbstractTexture::DataHelper<3>::setWrapping(AbstractTexture* texture, const Math::Vector3& wrapping) { +void AbstractTexture::DataHelper<3>::setWrapping(AbstractTexture* texture, const Array3D& wrapping) { (texture->*parameteriImplementation)(GL_TEXTURE_WRAP_S, static_cast(wrapping.x())); (texture->*parameteriImplementation)(GL_TEXTURE_WRAP_T, static_cast(wrapping.y())); #ifndef MAGNUM_TARGET_GLES diff --git a/src/AbstractTexture.h b/src/AbstractTexture.h index 038e4ad5d..12b5a162b 100644 --- a/src/AbstractTexture.h +++ b/src/AbstractTexture.h @@ -19,7 +19,7 @@ * @brief Class Magnum::AbstractTexture */ -#include "Magnum.h" +#include "Array.h" #include "Color.h" #include "AbstractImage.h" @@ -836,8 +836,8 @@ template<> struct AbstractTexture::DataHelper<1> { inline constexpr static Target target() { return Target::Texture1D; } - inline static void setWrapping(AbstractTexture* texture, const Math::Vector<1, Wrapping>& wrapping) { - (texture->*parameteriImplementation)(GL_TEXTURE_WRAP_S, static_cast(wrapping[0])); + inline static void setWrapping(AbstractTexture* texture, const Array1D& wrapping) { + (texture->*parameteriImplementation)(GL_TEXTURE_WRAP_S, static_cast(wrapping.x())); } template inline static typename std::enable_if::type set(AbstractTexture* texture, GLenum target, GLint mipLevel, InternalFormat internalFormat, Image* image) { @@ -861,7 +861,7 @@ template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<2> { inline constexpr static Target target() { return Target::Texture2D; } - static void setWrapping(AbstractTexture* texture, const Math::Vector2& wrapping); + static void setWrapping(AbstractTexture* texture, const Array2D& wrapping); template inline static typename std::enable_if::type set(AbstractTexture* texture, GLenum target, GLint mipLevel, InternalFormat internalFormat, Image* image) { (texture->*image2DImplementation)(target, mipLevel, internalFormat, image->size(), image->components(), image->type(), image->data()); @@ -887,7 +887,7 @@ template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<3> { inline constexpr static Target target() { return Target::Texture3D; } - static void setWrapping(AbstractTexture* texture, const Math::Vector3& wrapping); + static void setWrapping(AbstractTexture* texture, const Array3D& wrapping); template inline static typename std::enable_if::type set(AbstractTexture* texture, GLenum target, GLint mipLevel, InternalFormat internalFormat, Image* image) { (texture->*image3DImplementation)(target, mipLevel, internalFormat, image->size(), image->components(), image->type(), image->data()); diff --git a/src/CubeMapTexture.h b/src/CubeMapTexture.h index 5141f0a24..9c734d80e 100644 --- a/src/CubeMapTexture.h +++ b/src/CubeMapTexture.h @@ -85,7 +85,7 @@ class CubeMapTexture: public AbstractTexture { /** * @copydoc Texture::setWrapping() */ - inline CubeMapTexture* setWrapping(const Math::Vector<3, Wrapping>& wrapping) { + inline CubeMapTexture* setWrapping(const Array3D& wrapping) { DataHelper<3>::setWrapping(this, wrapping); return this; } diff --git a/src/CubeMapTextureArray.h b/src/CubeMapTextureArray.h index fdf55ca79..2d928edc6 100644 --- a/src/CubeMapTextureArray.h +++ b/src/CubeMapTextureArray.h @@ -63,7 +63,7 @@ class CubeMapTextureArray: public AbstractTexture { /** * @copydoc Texture::setWrapping() */ - inline CubeMapTextureArray* setWrapping(const Math::Vector3& wrapping) { + inline CubeMapTextureArray* setWrapping(const Array3D& wrapping) { DataHelper<3>::setWrapping(this, wrapping); return this; } diff --git a/src/Texture.h b/src/Texture.h index 9ca9d60b7..1191b8bc7 100644 --- a/src/Texture.h +++ b/src/Texture.h @@ -132,10 +132,8 @@ template class Texture: public AbstractTexture { * or @fn_gl_extension{TextureParameter,EXT,direct_state_access} * with @def_gl{TEXTURE_WRAP_S}, @def_gl{TEXTURE_WRAP_T}, * @def_gl{TEXTURE_WRAP_R} - * @todo Use something better for this than Vector (mainly something - * that can easily create all values the same) */ - inline Texture* setWrapping(const Math::Vector& wrapping) { + inline Texture* setWrapping(const Array& wrapping) { DataHelper::setWrapping(this, wrapping); return this; }