mirror of https://github.com/bjornbytes/lovr.git
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) {
|
||||
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 New Issue