freetexture
BlitzMax Forums/MiniB3D Module/freetexture
| ||
when i use freeentity, does it free any textures i have set on that entity using entitytexture? or will i need to explicitly call freetexture? I should clarify that i don't want to free the original texture, as i'll be using that again. Cheers Charlie |
| ||
As long as a reference to the texture exists, it is kept in memory. EntityTexture copies the texture reference into the brush field of an entity. That means, in order to remove the texture, you should remove/replace both the entity (or it's brush) and the original texture. Beside that, the texture is also added to an internal list called tex_list by CreateTexture/LoadTexture. I'm not entirely sure what this list is used for, but as long as the texture is on this list, it will not be removed. FreeTexture seems to remove textures from this list. |
| ||
Yes you need to use FreeTexture with every texture. FreeEntity doesn't free any textures. I should clarify that i don't want to free the original texture, as i'll be using that again. What do you mean by original texture? Every texture is in effect 'original' - you can use one texture as many times as you like, and you only need to free it when you've finished with it completely. |
| ||
Ok, further clarification. I have a texture that i create at the start of the program e.g. Global myTexture:ttexture=loadtexture(blahblah) during the program, i use this texture on some entities using entitytexture(entity,myTexture). My query is, does the entitytexture() function create a copy of myTexture that needs to be freed once i've finished with the entity? Cheers Charlie |
| ||
No it directly copies this textures handle into a field of the entities brush. So it is the same texture. However, when you free the original texture, and set it's pointer to Null, still the texture will exist, because a reference to the texture exists in the entity. |
| ||
ok, thanks. Cheers Charlie |
| ||
On a further investigation, things are different than I thought. A texture contains a Pixmap, that is cleared when FreeTexture is used. So, after freeing a texture, you can't use it anymore. If it is applied to anything in the scene, RenderWorld gives an error. |