summaryrefslogtreecommitdiffstats
path: root/scene/resources/texture.cpp
diff options
context:
space:
mode:
authorAndrii Doroshenko (Xrayez) <xrayez@gmail.com>2020-09-29 17:27:13 +0300
committerAndrii Doroshenko (Xrayez) <xrayez@gmail.com>2020-11-17 16:00:41 +0200
commit0ee88d6705852df81eb1bf0b0869e65d60c3352e (patch)
treeef79d4f1636a288c694669379e59fbfce6c34a07 /scene/resources/texture.cpp
parent408effa68822c1a861daf78b9e10414bee24225b (diff)
downloadredot-engine-0ee88d6705852df81eb1bf0b0869e65d60c3352e.tar.gz
Describe `ImageTexture`, `Image` creation and usage
Diffstat (limited to 'scene/resources/texture.cpp')
-rw-r--r--scene/resources/texture.cpp15
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);