From 0ee88d6705852df81eb1bf0b0869e65d60c3352e Mon Sep 17 00:00:00 2001 From: "Andrii Doroshenko (Xrayez)" Date: Tue, 29 Sep 2020 17:27:13 +0300 Subject: Describe `ImageTexture`, `Image` creation and usage --- scene/resources/texture.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'scene/resources') 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 &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 &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); -- cgit v1.2.3