diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-11-17 16:17:33 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-17 16:17:33 +0100 |
commit | c56a071d0c6e282dbb82aa7e69691e33f6c2fd7e (patch) | |
tree | d96e6a7bf59b9f059b4212a0d36f8f6963e0cb62 /scene/resources | |
parent | b59a6fc40e70e435821734429fab0df571475172 (diff) | |
parent | 0ee88d6705852df81eb1bf0b0869e65d60c3352e (diff) |
Merge pull request #42412 from Xrayez/doc-image-texture
Describe `ImageTexture`, `Image` creation and usage
Diffstat (limited to 'scene/resources')
-rw-r--r-- | scene/resources/texture.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp index 07de202cc8..1507537cd0 100644 --- a/scene/resources/texture.cpp +++ b/scene/resources/texture.cpp @@ -151,7 +151,7 @@ void ImageTexture::_reload_hook(const RID &p_hook) { } void ImageTexture::create_from_image(const Ref<Image> &p_image) { - ERR_FAIL_COND(p_image.is_null()); + ERR_FAIL_COND_MSG(p_image.is_null(), "Invalid image"); w = p_image->get_width(); h = p_image->get_height(); format = p_image->get_format(); @@ -174,11 +174,14 @@ Image::Format ImageTexture::get_format() const { } void ImageTexture::update(const Ref<Image> &p_image, bool p_immediate) { - ERR_FAIL_COND(p_image.is_null()); - ERR_FAIL_COND(texture.is_null()); - ERR_FAIL_COND(p_image->get_width() != w || p_image->get_height() != h); - ERR_FAIL_COND(p_image->get_format() != format); - ERR_FAIL_COND(mipmaps != p_image->has_mipmaps()); + ERR_FAIL_COND_MSG(p_image.is_null(), "Invalid image"); + ERR_FAIL_COND_MSG(texture.is_null(), "Texture is not initialized."); + ERR_FAIL_COND_MSG(p_image->get_width() != w || p_image->get_height() != h, + "The new image dimensions must match the texture size."); + ERR_FAIL_COND_MSG(p_image->get_format() != format, + "The new image format must match the texture's image format."); + ERR_FAIL_COND_MSG(mipmaps != p_image->has_mipmaps(), + "The new image mipmaps configuration must match the texture's image mipmaps configuration"); if (p_immediate) { RenderingServer::get_singleton()->texture_2d_update_immediate(texture, p_image); |