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 ?
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:
Graphics3D 800, 600, 0, 2 SetBuffer BackBuffer() ;setup camera camera = CreateCamera() MoveEntity camera, 0, 0, -10 ;setup cube cube = CreateCube() ;create image image = CreateImage(64, 64) ;---------------------- ;1. Create First Image (ovals) ;---------------------- Cls Oval 0, 0, 64, 64 GrabImage image, 0, 0 SaveImage image, "test1.bmp" ;---------------------- ;2. Apply Image ;---------------------- tex = LoadBrush("test1.bmp") PaintMesh cube, tex ; ;---------------------- ; ;3. Remove 1st brush from memory ; ;---------------------- ; ;remove cube, because it contains brush ; FreeEntity cube ; cube = CreateCube() ; ;remove brush itself ; FreeBrush tex ;---------------------- ;4. Create Second Image (rectangles) ;---------------------- Cls Rect 0, 0, 64, 64, 0 Rect 8, 8, 48, 48, 0 GrabImage image, 0, 0 SaveImage image, "test1.bmp" ;---------------------- ;5. Apply 2nd Image ;---------------------- brush = LoadBrush("test1.bmp") PaintMesh cube, brush ;---------------------- ;6. Test ;---------------------- RenderWorld() Flip ;cleanup DeleteFile "test1.bmp" WaitKey() End
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 ?