Materials refcount their Textures properly;

This commit is contained in:
bjorn 2017-10-31 01:49:45 -07:00
parent cc019e5783
commit 60d25b2e11
1 changed files with 11 additions and 1 deletions

View File

@ -42,5 +42,15 @@ Texture* lovrMaterialGetTexture(Material* material, MaterialTexture textureType)
}
void lovrMaterialSetTexture(Material* material, MaterialTexture textureType, Texture* texture) {
material->textures[textureType] = texture;
if (texture != material->textures[textureType]) {
if (material->textures[textureType]) {
lovrRelease(&material->textures[textureType]->ref);
}
material->textures[textureType] = texture;
if (texture) {
lovrRetain(&texture->ref);
}
}
}