1
0
Fork 0
mirror of https://github.com/bjornbytes/lovr.git synced 2024-07-02 12:33:52 +00:00

Materials refcount their Textures properly;

This commit is contained in:
bjorn 2017-10-31 01:49:45 -07:00
parent cc019e5783
commit 60d25b2e11

View file

@ -42,5 +42,15 @@ Texture* lovrMaterialGetTexture(Material* material, MaterialTexture textureType)
} }
void lovrMaterialSetTexture(Material* material, MaterialTexture textureType, Texture* texture) { 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);
}
}
} }