From c591902feacf39e17b85149a8a9685e34217cd1a Mon Sep 17 00:00:00 2001 From: Michael Fabian 'Xaymar' Dirks Date: Fri, 28 Sep 2018 23:34:43 +0200 Subject: [PATCH] gs-texture: Allow texture creation without data This is a valid operation and allows for creation of uninitialized textures, which can be copied to but should not be read from until that moment. --- source/gs-texture.cpp | 6 ------ source/gs-texture.h | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/source/gs-texture.cpp b/source/gs-texture.cpp index ca9725b..d78078b 100644 --- a/source/gs-texture.cpp +++ b/source/gs-texture.cpp @@ -40,8 +40,6 @@ gs::texture::texture(uint32_t width, uint32_t height, gs_color_format format, ui throw std::logic_error("height must be at least 1"); if (mip_levels == 0) throw std::logic_error("mip_levels must be at least 1"); - if (!mip_data) - throw std::logic_error("mip_data is invalid"); if (mip_levels > 1 || ((texture_flags & flags::BuildMipMaps) == flags::BuildMipMaps)) { bool isPOT = util::math::is_power_of_two(width) && util::math::is_power_of_two(height); @@ -73,8 +71,6 @@ gs::texture::texture(uint32_t width, uint32_t height, uint32_t depth, gs_color_f throw std::logic_error("depth must be at least 1"); if (mip_levels == 0) throw std::logic_error("mip_levels must be at least 1"); - if (!mip_data) - throw std::logic_error("mip_data is invalid"); if (mip_levels > 1 || ((texture_flags & flags::BuildMipMaps) == flags::BuildMipMaps)) { bool isPOT = (pow(2, (int64_t)floor(log(width) / log(2))) == width) @@ -104,8 +100,6 @@ gs::texture::texture(uint32_t size, gs_color_format format, uint32_t mip_levels, throw std::logic_error("size must be at least 1"); if (mip_levels == 0) throw std::logic_error("mip_levels must be at least 1"); - if (!mip_data) - throw std::logic_error("mip_data is invalid"); if (mip_levels > 1 || ((texture_flags & flags::BuildMipMaps) == flags::BuildMipMaps)) { bool isPOT = (pow(2, (int64_t)floor(log(size) / log(2))) == size); diff --git a/source/gs-texture.h b/source/gs-texture.h index f6212a6..6143e35 100644 --- a/source/gs-texture.h +++ b/source/gs-texture.h @@ -103,7 +103,7 @@ namespace gs { * \brief Create a texture from an existing gs_texture_t object. */ texture(gs_texture_t* tex, bool takeOwnership = false) : m_texture(tex), m_isOwner(takeOwnership) {} - + void load(int unit); gs_texture_t* get_object();