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:
parent
cc019e5783
commit
60d25b2e11
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue