diff --git a/src/CubeMapTexture.h b/src/CubeMapTexture.h index 36fb462dd..f028e0d93 100644 --- a/src/CubeMapTexture.h +++ b/src/CubeMapTexture.h @@ -55,120 +55,234 @@ class CubeMapTexture: public Texture2D { inline CubeMapTexture(GLint layer = 0): Texture2D(layer, GL_TEXTURE_CUBE_MAP) {} protected: - /** @brief Deleted. Use setDataPositiveX() and others instead. */ + /** @brief Deleted. Use @ref setDataPositiveX(GLint, InternalFormat, const Math::Vector&, ColorFormat, const T*) "setDataPositiveX()" and others instead. */ template inline void setData(GLint mipLevel, InternalFormat internalFormat, const Math::Vector& _dimensions, ColorFormat colorFormat, const T* data) = delete; - /** @brief Deleted. Use setSubDataPositiveX() and others instead. */ + /** @brief Deleted. Use @ref setDataPositiveX(GLint, InternalFormat, const Image*) "setDataPositiveX()" and others instead. */ + void setData(GLint mipLevel, InternalFormat internalFormat, const Image* image) = delete; + + /** @brief Deleted. Use @ref setSubDataPositiveX(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 Image*) "setSubDataPositiveX()" and others instead. */ + void setSubData(GLint mipLevel, const Math::Vector& offset, const Image* image) = delete; + /** * @brief Set texture data for positive X * - * @copydetails Texture::setData() + * @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 Image*) + */ + inline void setDataPositiveX(GLint mipLevel, InternalFormat internalFormat, const 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() + * @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 Image*) + */ + inline void setSubDataPositiveX(GLint mipLevel, const Math::Vector& offset, const 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() + * @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 Image*) + */ + inline void setDataNegativeX(GLint mipLevel, InternalFormat internalFormat, const 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() + * @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 Image*) + */ + inline void setSubDataNegativeX(GLint mipLevel, const Math::Vector& offset, const 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() + * @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 Image*) + */ + inline void setDataPositiveY(GLint mipLevel, InternalFormat internalFormat, const 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() + * @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 Image*) + */ + inline void setSubDataPositiveY(GLint mipLevel, const Math::Vector& offset, const 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() + * @copydetails Texture::setData(GLint, InternalFormat, const Math::Vector&, ColorFormat, const T*) */ 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); } + /** + * @brief Set texture data for negative Y + * + * @copydetails Texture::setData(GLint, InternalFormat, const Image*) + */ + inline void setDataNegativeY(GLint mipLevel, InternalFormat internalFormat, const 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() + * @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 Image*) + */ + inline void setSubDataNegativeY(GLint mipLevel, const Math::Vector& offset, const Image* image) { + setSubData(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, mipLevel, offset, image->dimensions(), image->colorFormat(), image->type(), image->data()); + } + /** * @brief Set texture data for positive Z * - * @copydetails Texture::setData() + * @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 Image*) + */ + inline void setDataPositiveZ(GLint mipLevel, InternalFormat internalFormat, const Image* image) { + setData(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, mipLevel, internalFormat, image->dimensions(), image->colorFormat(), image->type(), image->data()); + } + /** * @brief Set texture subdata for positive Z * - * @copydetails Texture::setSubData() + * @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 Image*) + */ + inline void setSubDataPositiveZ(GLint mipLevel, const Math::Vector& offset, const 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() + * @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 Image*) + */ + inline void setDataNegativeZ(GLint mipLevel, InternalFormat internalFormat, const 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() + * @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 Image*) + */ + inline void setSubDataNegativeZ(GLint mipLevel, const Math::Vector& offset, const Image* image) { + setSubData(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, mipLevel, offset, image->dimensions(), image->colorFormat(), image->type(), image->data()); + } + private: void setData(GLenum target, GLint mipLevel, InternalFormat internalFormat, const Math::Vector& _dimensions, ColorFormat colorFormat, GLenum type, const void* data) { bind(); diff --git a/src/Texture.h b/src/Texture.h index d6d44ae5c..af58a7877 100644 --- a/src/Texture.h +++ b/src/Texture.h @@ -91,6 +91,18 @@ template class Texture: public AbstractTexture { unbind(); } + /** + * @brief Set texture data + * @param mipLevel Mip level + * @param internalFormat Internal texture format + * @param image Image + */ + inline void setData(GLint mipLevel, InternalFormat internalFormat, const Image* image) { + bind(); + DataHelper::set(target, mipLevel, internalFormat, image->dimensions(), image->colorFormat(), image->type(), image->data()); + unbind(); + } + /** * @brief Set texture subdata * @param mipLevel Mip level @@ -105,6 +117,18 @@ template class Texture: public AbstractTexture { DataHelper::setSub(target, mipLevel, offset, _dimensions, colorFormat, TypeTraits::TextureType>::glType(), data); unbind(); } + + /** + * @brief Set texture subdata + * @param mipLevel Mip level + * @param offset Offset where to put data in the texture + * @param image Image + */ + inline void setSubData(GLint mipLevel, const Math::Vector& offset, const Image* image) { + bind(); + DataHelper::setSub(target, mipLevel, offset, image->dimensions(), image->colorFormat(), image->type(), image->data()); + unbind(); + } }; /** @brief One-dimensional texture */