GLBasic forum

Main forum => GLBasic - en => Topic started by: fuzzy70 on 2013-Jun-04

Title: How to free a generated sprite?
Post by: fuzzy70 on 2013-Jun-04
The answer to this is probably easy & obvious but it is eluding me at the moment & driving me nuts  :D

I am modifying my fastflood fill routine to make it easier to fill a part of the screen or a sprite & also some optimisations (not to the fill routine itself as that's pretty much maxed as I can get it). When doing a fill on a screen it grabs the entire screen with SPRITE2MEM, does the fill then dumps the entire array back to a sprite. Writing the entire array back then calling MEM2SPRITE is far from optimal if say the area that has been filled is only small (say 50x70 pixels) as the bigger the array the longer MEM2SPRITE takes.

My solution is to copy only the modified area to a new sprite with an ID created with GENSPRITE hence making the call to MEM2SPRITE faster when dealing with smaller areas.

Once the sprite has been drawn how do I delete it from memory otherwise every call to the routine will create a new sprite & end up with loads of basically dead & useless sprites taking up memory. I don't really want 1 sprite left in memory after the routine is called as even that sprite is not needed once it has been drawn.

Lee

Title: Re: How to free a generated sprite?
Post by: MrTAToad on 2013-Jun-04
Use LOADSPRITE "",<id>
Title: Re: How to free a generated sprite?
Post by: fuzzy70 on 2013-Jun-04
Use LOADSPRITE "",<id>

Thanks MrTAToad, like I said it was more than likely obvious & simple but the penny wouldn't drop  :D

Lee
Title: Re: How to free a generated sprite?
Post by: spicypixel on 2013-Jun-05
Use LOADSPRITE "",<id>

Thanks MrTAToad, like I said it was more than likely obvious & simple but the penny wouldn't drop  :D

Lee

I had some issues when developing for iOS (not sure why or how now) when I used LOADSPRITE "" but all was fine when I used LOADSPRITE "FREEME" <--- any filename that doesn't exist
Title: Re: Re: How to free a generated sprite?
Post by: fuzzy70 on 2013-Jun-05
I had some issues when developing for iOS (not sure why or how now) when I used LOADSPRITE "" but all was fine when I used LOADSPRITE "FREEME" <--- any filename that doesn't exist

Thanks Spicy, will keep that in mind. Not that I develop anything for iOS (maybe someday I will) but handy to include in case another platform may have issues with a blank filename :)

Lee

Sent from my HTC Wildfire using Tapatalk 2