diff options
author | Wuzzy <wuzzy2@mail.ru> | 2021-10-20 19:50:16 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-20 21:50:16 +0200 |
commit | 86b44ecd8280d8304aa26a600fc004d40a970020 (patch) | |
tree | c355bd74f3dd0321094bc03b80b2c010386d916a /src/client/hud.cpp | |
parent | c82ec8b210f613fcd5bb386a14f0a8f88591253a (diff) | |
download | minetest-86b44ecd8280d8304aa26a600fc004d40a970020.tar.gz minetest-86b44ecd8280d8304aa26a600fc004d40a970020.tar.bz2 minetest-86b44ecd8280d8304aa26a600fc004d40a970020.zip |
Add no_texture.png as fallback for unspecified textures
Diffstat (limited to 'src/client/hud.cpp')
-rw-r--r-- | src/client/hud.cpp | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/client/hud.cpp b/src/client/hud.cpp index 0620759da..e08d2ef02 100644 --- a/src/client/hud.cpp +++ b/src/client/hud.cpp @@ -1007,11 +1007,15 @@ void drawItemStack( bool draw_overlay = false; + bool has_mesh = false; + ItemMesh *imesh; + // Render as mesh if animated or no inventory image if ((enable_animations && rotation_kind < IT_ROT_NONE) || def.inventory_image.empty()) { - ItemMesh *imesh = client->idef()->getWieldMesh(def.name, client); - if (!imesh || !imesh->mesh) - return; + imesh = client->idef()->getWieldMesh(def.name, client); + has_mesh = imesh && imesh->mesh; + } + if (has_mesh) { scene::IMesh *mesh = imesh->mesh; driver->clearBuffers(video::ECBF_DEPTH); s32 delta = 0; @@ -1103,10 +1107,17 @@ void drawItemStack( draw_overlay = def.type == ITEM_NODE && def.inventory_image.empty(); } else { // Otherwise just draw as 2D video::ITexture *texture = client->idef()->getInventoryTexture(def.name, client); - if (!texture) - return; - video::SColor color = - client->idef()->getItemstackColor(item, client); + video::SColor color; + if (texture) { + color = client->idef()->getItemstackColor(item, client); + } else { + color = video::SColor(255, 255, 255, 255); + ITextureSource *tsrc = client->getTextureSource(); + texture = tsrc->getTexture("no_texture.png"); + if (!texture) + return; + } + const video::SColor colors[] = { color, color, color, color }; draw2DImageFilterScaled(driver, texture, rect, |