mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-06 03:21:49 +00:00
fix Image for non-existing textures in atlas
This commit is contained in:
parent
2dffdf757c
commit
71c754b039
4 changed files with 22 additions and 9 deletions
|
|
@ -30,14 +30,17 @@ void Image::draw(const DrawContext* pctx, Assets* assets) {
|
|||
} else {
|
||||
auto atlasName = this->texture.substr(0, separator);
|
||||
if (auto atlas = assets->get<Atlas>(atlasName)) {
|
||||
texture = atlas->getTexture();
|
||||
batch->texture(atlas->getTexture());
|
||||
auto& region = atlas->get(this->texture.substr(separator+1));
|
||||
batch->setRegion(region);
|
||||
if (autoresize) {
|
||||
setSize(glm::vec2(
|
||||
texture->getWidth()*region.getWidth(),
|
||||
texture->getHeight()*region.getHeight()));
|
||||
if (auto region = atlas->getIf(this->texture.substr(separator+1))) {
|
||||
texture = atlas->getTexture();
|
||||
batch->texture(atlas->getTexture());
|
||||
batch->setRegion(*region);
|
||||
if (autoresize) {
|
||||
setSize(glm::vec2(
|
||||
texture->getWidth()*region->getWidth(),
|
||||
texture->getHeight()*region->getHeight()));
|
||||
}
|
||||
} else {
|
||||
batch->texture(nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue