From 476e8285cd08e3e56afa77aa03883312b32ae45d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 19 Feb 2012 17:04:39 +0100 Subject: [PATCH] Simplified massive repeated code in CubeMapTexture.h. --- src/CubeMapTexture.h | 232 ++++++------------------------------------- 1 file changed, 29 insertions(+), 203 deletions(-) diff --git a/src/CubeMapTexture.h b/src/CubeMapTexture.h index 8f9279a81..63a863df0 100644 --- a/src/CubeMapTexture.h +++ b/src/CubeMapTexture.h @@ -46,6 +46,16 @@ See Texture documentation for more information about usage. */ class CubeMapTexture: public Texture2D { public: + /** @brief Cube map coordinate */ + enum Coordinate: GLenum { + PositiveX = GL_TEXTURE_CUBE_MAP_POSITIVE_X, + NegativeX = GL_TEXTURE_CUBE_MAP_NEGATIVE_X, + PositiveY = GL_TEXTURE_CUBE_MAP_POSITIVE_Y, + NegativeY = GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, + PositiveZ = GL_TEXTURE_CUBE_MAP_POSITIVE_Z, + NegativeZ = GL_TEXTURE_CUBE_MAP_NEGATIVE_Z + }; + /** * @brief Constructor * @param layer Texture layer (number between 0 and 31) @@ -54,232 +64,48 @@ class CubeMapTexture: public Texture2D { */ inline CubeMapTexture(GLint layer = 0): Texture2D(layer, GL_TEXTURE_CUBE_MAP) {} - /** @brief Deleted. Use @ref setDataPositiveX(GLint, InternalFormat, const Math::Vector&, ColorFormat, const T*) "setDataPositiveX()" and others instead. */ + /** @brief Deleted. Use setData(Coordinate, GLint, InternalFormat, const Math::Vector&, ColorFormat, const T*) instead. */ template inline void setData(GLint mipLevel, InternalFormat internalFormat, const Math::Vector& _dimensions, ColorFormat colorFormat, const T* data) = delete; - /** @brief Deleted. Use @ref setDataPositiveX(GLint, InternalFormat, const Trade::Image*) "setDataPositiveX()" and others instead. */ + /** @brief Deleted. Use setData(Coordinate, GLint, InternalFormat, const Trade::Image*) instead. */ void setData(GLint mipLevel, InternalFormat internalFormat, const Trade::Image* image) = delete; - /** @brief Deleted. Use @ref setSubDataPositiveX(GLint, const Math::Vector&, const Math::Vector&, ColorFormat, const T*) "setSubDataPositiveX()" and others instead. */ + /** @brief Deleted. Use @ref setSubData(Coordinate, GLint, const Math::Vector&, const Math::Vector&, ColorFormat, const T*) "setSubDataPositiveX()" and others instead. */ template inline void setSubData(GLint mipLevel, const Math::Vector& offset, const Math::Vector& _dimensions, ColorFormat colorFormat, const T* data) = delete; - /** @brief Deleted. Use @ref setSubDataPositiveX(GLint, const Math::Vector&, const Trade::Image*) "setSubDataPositiveX()" and others instead. */ + /** @brief Deleted. Use @ref setSubData(Coordinate, GLint, const Math::Vector&, const Trade::Image*) "setSubDataPositiveX()" and others instead. */ void setSubData(GLint mipLevel, const Math::Vector& offset, const Trade::Image* image) = delete; /** - * @brief Set texture data for positive X - * - * @copydetails Texture::setData(GLint, InternalFormat, const Math::Vector&, ColorFormat, const T*) - */ - template inline void setDataPositiveX(GLint mipLevel, InternalFormat internalFormat, const Math::Vector& _dimensions, ColorFormat colorFormat, const T* data) { - setData(GL_TEXTURE_CUBE_MAP_POSITIVE_X, mipLevel, internalFormat, _dimensions, colorFormat, TypeTraits::TextureType>::glType(), data); - } - - /** - * @brief Set texture data for positive X - * - * @copydetails Texture::setData(GLint, InternalFormat, const Trade::Image*) - */ - inline void setDataPositiveX(GLint mipLevel, InternalFormat internalFormat, const Trade::Image* image) { - setData(GL_TEXTURE_CUBE_MAP_POSITIVE_X, mipLevel, internalFormat, image->dimensions(), image->colorFormat(), image->type(), image->data()); - } - - /** - * @brief Set texture subdata for positive X - * - * @copydetails Texture::setSubData(GLint, const Math::Vector&, const Math::Vector&, ColorFormat, const T*) - */ - template inline void setSubDataPositiveX(GLint mipLevel, const Math::Vector& offset, const Math::Vector& _dimensions, ColorFormat colorFormat, const T* data) { - setSubData(GL_TEXTURE_CUBE_MAP_POSITIVE_X, mipLevel, offset, _dimensions, colorFormat, TypeTraits::TextureType>::glType(), data); - } - - /** - * @brief Set texture subdata for positive X - * - * @copydetails Texture::setSubData(GLint, const Math::Vector&, const Trade::Image*) - */ - inline void setSubDataPositiveX(GLint mipLevel, const Math::Vector& offset, const Trade::Image* image) { - setSubData(GL_TEXTURE_CUBE_MAP_POSITIVE_X, mipLevel, offset, image->dimensions(), image->colorFormat(), image->type(), image->data()); - } - - /** - * @brief Set texture data for negative X - * - * @copydetails Texture::setData(GLint, InternalFormat, const Math::Vector&, ColorFormat, const T*) - */ - template inline void setDataNegativeX(GLint mipLevel, InternalFormat internalFormat, const Math::Vector& _dimensions, ColorFormat colorFormat, const T* data) { - setData(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, mipLevel, internalFormat, _dimensions, colorFormat, TypeTraits::TextureType>::glType(), data); - } - - /** - * @brief Set texture data for negative X - * - * @copydetails Texture::setData(GLint, InternalFormat, const Trade::Image*) - */ - inline void setDataNegativeX(GLint mipLevel, InternalFormat internalFormat, const Trade::Image* image) { - setData(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, mipLevel, internalFormat, image->dimensions(), image->colorFormat(), image->type(), image->data()); - } - - /** - * @brief Set texture subdata for negative X - * - * @copydetails Texture::setSubData(GLint, const Math::Vector&, const Math::Vector&, ColorFormat, const T*) - */ - template inline void setSubDataNegativeX(GLint mipLevel, const Math::Vector& offset, const Math::Vector& _dimensions, ColorFormat colorFormat, const T* data) { - setSubData(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, mipLevel, offset, _dimensions, colorFormat, TypeTraits::TextureType>::glType(), data); - } - - /** - * @brief Set texture subdata for negative X - * - * @copydetails Texture::setSubData(GLint, const Math::Vector&, const Trade::Image*) - */ - inline void setSubDataNegativeX(GLint mipLevel, const Math::Vector& offset, const Trade::Image* image) { - setSubData(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, mipLevel, offset, image->dimensions(), image->colorFormat(), image->type(), image->data()); - } - - /** - * @brief Set texture data for positive Y - * - * @copydetails Texture::setData(GLint, InternalFormat, const Math::Vector&, ColorFormat, const T*) - */ - template inline void setDataPositiveY(GLint mipLevel, InternalFormat internalFormat, const Math::Vector& _dimensions, ColorFormat colorFormat, const T* data) { - setData(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, mipLevel, internalFormat, _dimensions, colorFormat, TypeTraits::TextureType>::glType(), data); - } - - /** - * @brief Set texture data for positive Y - * - * @copydetails Texture::setData(GLint, InternalFormat, const Trade::Image*) - */ - inline void setDataPositiveY(GLint mipLevel, InternalFormat internalFormat, const Trade::Image* image) { - setData(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, mipLevel, internalFormat, image->dimensions(), image->colorFormat(), image->type(), image->data()); - } - - /** - * @brief Set texture subdata for positive Y - * - * @copydetails Texture::setSubData(GLint, const Math::Vector&, const Math::Vector&, ColorFormat, const T*) - */ - template inline void setSubDataPositiveY(GLint mipLevel, const Math::Vector& offset, const Math::Vector& _dimensions, ColorFormat colorFormat, const T* data) { - setSubData(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, mipLevel, offset, _dimensions, colorFormat, TypeTraits::TextureType>::glType(), data); - } - - /** - * @brief Set texture subdata for positive Y - * - * @copydetails Texture::setSubData(GLint, const Math::Vector&, const Trade::Image*) - */ - inline void setSubDataPositiveY(GLint mipLevel, const Math::Vector& offset, const Trade::Image* image) { - setSubData(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, mipLevel, offset, image->dimensions(), image->colorFormat(), image->type(), image->data()); - } - - /** - * @brief Set texture data for negative Y - * - * @copydetails Texture::setData(GLint, InternalFormat, const Math::Vector&, ColorFormat, const T*) + * @copydoc Texture::setData(GLint, InternalFormat, const Math::Vector&, ColorFormat, const T*) + * @param coordinate Coordinate */ - template inline void setDataNegativeY(GLint mipLevel, InternalFormat internalFormat, const Math::Vector& _dimensions, ColorFormat colorFormat, const T* data) { - setData(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, mipLevel, internalFormat, _dimensions, colorFormat, TypeTraits::TextureType>::glType(), data); + template inline void setData(Coordinate coordinate, GLint mipLevel, InternalFormat internalFormat, const Math::Vector& _dimensions, ColorFormat colorFormat, const T* data) { + setData(coordinate, mipLevel, internalFormat, _dimensions, colorFormat, TypeTraits::TextureType>::glType(), data); } /** - * @brief Set texture data for negative Y - * * @copydetails Texture::setData(GLint, InternalFormat, const Trade::Image*) + * @param coordinate Coordinate */ - inline void setDataNegativeY(GLint mipLevel, InternalFormat internalFormat, const Trade::Image* image) { - setData(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, mipLevel, internalFormat, image->dimensions(), image->colorFormat(), image->type(), image->data()); - } - - /** - * @brief Set texture subdata for negative Y - * - * @copydetails Texture::setSubData(GLint, const Math::Vector&, const Math::Vector&, ColorFormat, const T*) - */ - template inline void setSubDataNegativeY(GLint mipLevel, const Math::Vector& offset, const Math::Vector& _dimensions, ColorFormat colorFormat, const T* data) { - setSubData(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, mipLevel, offset, _dimensions, colorFormat, TypeTraits::TextureType>::glType(), data); - } - - /** - * @brief Set texture subdata for negative Y - * - * @copydetails Texture::setSubData(GLint, const Math::Vector&, const Trade::Image*) - */ - inline void setSubDataNegativeY(GLint mipLevel, const Math::Vector& offset, const Trade::Image* image) { - setSubData(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, mipLevel, offset, image->dimensions(), image->colorFormat(), image->type(), image->data()); + inline void setData(Coordinate coordinate, GLint mipLevel, InternalFormat internalFormat, const Trade::Image* image) { + setData(coordinate, mipLevel, internalFormat, image->dimensions(), image->colorFormat(), image->type(), image->data()); } /** - * @brief Set texture data for positive Z - * - * @copydetails Texture::setData(GLint, InternalFormat, const Math::Vector&, ColorFormat, const T*) - */ - template inline void setDataPositiveZ(GLint mipLevel, InternalFormat internalFormat, const Math::Vector& _dimensions, ColorFormat colorFormat, const T* data) { - setData(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, mipLevel, internalFormat, _dimensions, colorFormat, TypeTraits::TextureType>::glType(), data); - } - - /** - * @brief Set texture data for positive Z - * - * @copydetails Texture::setData(GLint, InternalFormat, const Trade::Image*) + * @copydoc Texture::setSubData(GLint, const Math::Vector&, const Math::Vector&, ColorFormat, const T*) + * @param coordinate Coordinate */ - inline void setDataPositiveZ(GLint mipLevel, InternalFormat internalFormat, const Trade::Image* image) { - setData(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, mipLevel, internalFormat, image->dimensions(), image->colorFormat(), image->type(), image->data()); + template inline void setSubData(Coordinate coordinate, GLint mipLevel, const Math::Vector& offset, const Math::Vector& _dimensions, ColorFormat colorFormat, const T* data) { + setSubData(coordinate, mipLevel, offset, _dimensions, colorFormat, TypeTraits::TextureType>::glType(), data); } /** - * @brief Set texture subdata for positive Z - * - * @copydetails Texture::setSubData(GLint, const Math::Vector&, const Math::Vector&, ColorFormat, const T*) - */ - template inline void setSubDataPositiveZ(GLint mipLevel, const Math::Vector& offset, const Math::Vector& _dimensions, ColorFormat colorFormat, const T* data) { - setSubData(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, mipLevel, offset, _dimensions, colorFormat, TypeTraits::TextureType>::glType(), data); - } - - /** - * @brief Set texture subdata for positive Z - * - * @copydetails Texture::setSubData(GLint, const Math::Vector&, const Trade::Image*) - */ - inline void setSubDataPositiveZ(GLint mipLevel, const Math::Vector& offset, const Trade::Image* image) { - setSubData(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, mipLevel, offset, image->dimensions(), image->colorFormat(), image->type(), image->data()); - } - - /** - * @brief Set texture data for negative Z - * - * @copydetails Texture::setData(GLint, InternalFormat, const Math::Vector&, ColorFormat, const T*) - */ - template inline void setDataNegativeZ(GLint mipLevel, InternalFormat internalFormat, const Math::Vector& _dimensions, ColorFormat colorFormat, const T* data) { - setData(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, mipLevel, internalFormat, _dimensions, colorFormat, TypeTraits::TextureType>::glType(), data); - } - - /** - * @brief Set texture data for negative Z - * - * @copydetails Texture::setData(GLint, InternalFormat, const Trade::Image*) - */ - inline void setDataNegativeZ(GLint mipLevel, InternalFormat internalFormat, const Trade::Image* image) { - setData(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, mipLevel, internalFormat, image->dimensions(), image->colorFormat(), image->type(), image->data()); - } - - /** - * @brief Set texture subdata for negative Z - * - * @copydetails Texture::setSubData(GLint, const Math::Vector&, const Math::Vector&, ColorFormat, const T*) - */ - template inline void setSubDataNegativeZ(GLint mipLevel, const Math::Vector& offset, const Math::Vector& _dimensions, ColorFormat colorFormat, const T* data) { - setSubData(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, mipLevel, offset, _dimensions, colorFormat, TypeTraits::TextureType>::glType(), data); - } - - /** - * @brief Set texture subdata for negative Z - * - * @copydetails Texture::setSubData(GLint, const Math::Vector&, const Trade::Image*) + * @copydoc Texture::setSubData(GLint, const Math::Vector&, const Trade::Image*) + * @param coordinate Coordinate */ - inline void setSubDataNegativeZ(GLint mipLevel, const Math::Vector& offset, const Trade::Image* image) { - setSubData(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, mipLevel, offset, image->dimensions(), image->colorFormat(), image->type(), image->data()); + inline void setSubData(Coordinate coordinate, GLint mipLevel, const Math::Vector& offset, const Trade::Image* image) { + setSubData(coordinate, mipLevel, offset, image->dimensions(), image->colorFormat(), image->type(), image->data()); } private: