Browse Source

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>(
        Texture2D::Wrapping::ClampToEdge));
pull/7/head
Vladimír Vondruš 14 years ago
parent
commit
06e526d7a1
  1. 6
      src/AbstractTexture.cpp
  2. 10
      src/AbstractTexture.h
  3. 2
      src/CubeMapTexture.h
  4. 2
      src/CubeMapTextureArray.h
  5. 4
      src/Texture.h

6
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>& wrapping) {
void AbstractTexture::DataHelper<2>::setWrapping(AbstractTexture* texture, const Array2D<Wrapping>& 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<GLint>(wrapping.x()));
(texture->*parameteriImplementation)(GL_TEXTURE_WRAP_T, static_cast<GLint>(wrapping.y()));
}
void AbstractTexture::DataHelper<3>::setWrapping(AbstractTexture* texture, const Math::Vector3<Wrapping>& wrapping) {
void AbstractTexture::DataHelper<3>::setWrapping(AbstractTexture* texture, const Array3D<Wrapping>& wrapping) {
(texture->*parameteriImplementation)(GL_TEXTURE_WRAP_S, static_cast<GLint>(wrapping.x()));
(texture->*parameteriImplementation)(GL_TEXTURE_WRAP_T, static_cast<GLint>(wrapping.y()));
#ifndef MAGNUM_TARGET_GLES

10
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<GLint>(wrapping[0]));
inline static void setWrapping(AbstractTexture* texture, const Array1D<Wrapping>& wrapping) {
(texture->*parameteriImplementation)(GL_TEXTURE_WRAP_S, static_cast<GLint>(wrapping.x()));
}
template<class Image> inline static typename std::enable_if<Image::Dimensions == 1, void>::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>& wrapping);
static void setWrapping(AbstractTexture* texture, const Array2D<Wrapping>& wrapping);
template<class Image> inline static typename std::enable_if<Image::Dimensions == 2, void>::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>& wrapping);
static void setWrapping(AbstractTexture* texture, const Array3D<Wrapping>& wrapping);
template<class Image> inline static typename std::enable_if<Image::Dimensions == 3, void>::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());

2
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>& wrapping) {
DataHelper<3>::setWrapping(this, wrapping);
return this;
}

2
src/CubeMapTextureArray.h

@ -63,7 +63,7 @@ class CubeMapTextureArray: public AbstractTexture {
/**
* @copydoc Texture::setWrapping()
*/
inline CubeMapTextureArray* setWrapping(const Math::Vector3<Wrapping>& wrapping) {
inline CubeMapTextureArray* setWrapping(const Array3D<Wrapping>& wrapping) {
DataHelper<3>::setWrapping(this, wrapping);
return this;
}

4
src/Texture.h

@ -132,10 +132,8 @@ template<std::uint8_t dimensions> 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<Dimensions>* setWrapping(const Math::Vector<Dimensions, Wrapping>& wrapping) {
inline Texture<Dimensions>* setWrapping(const Array<Dimensions, Wrapping>& wrapping) {
DataHelper<Dimensions>::setWrapping(this, wrapping);
return this;
}

Loading…
Cancel
Save