Free brushes

Blitz3D Forums/Blitz3D Programming/Free brushes

b32(Posted 2007) [#1]
I wrote a program that allows people to edit textures.
However, when a brush is saved under the same name, and then reloaded, the old version is loaded.
It seems that when you reload a new instance of the same brush, it returns the previous loaded brush.
A way around this is to free the old brush, and then free any object that is using this brush. However, this is not a suitable solution for my program.
I have some code here that demonstrates this:

It creates a first brush (with ovals), and then it creates a second one (with squares). However, only the first brush is shown.
I commented out the quick fix. When I CopyEntity() or CopyMesh() the original mesh, the brush still remains resident.
Does anybody know a way to force the reloading of the texture ?


b32(Posted 2007) [#2]
Ow .. it seems that with using LoadImage, you can work around this:



jfk EO-11110(Posted 2007) [#3]
It's Blitz3D's internal automatic memory usage optimation: when you load a texture twice, it will use only one copy of it in VRAM and create pseudo instances for every further handle, AS LONG AS it has the same flags and everything. As you suggested, there are some workarounds, like creating a texture using CreateTexture and then CopyRect a LoadImage-ed image to the texture buffer. Alpha and/or Mask information will have to be recreated with this method, there are some examples in the code archive (eg: optimize alpha/mask). Also, unfort. this won't work with DDS textures.
An other workaround is to save or copy the texture using a new, individual name. This temporary file may then be deleted instantly.