Freeing Textures

Earlier in the course we are told we should free up textures we load and we’re shown where to put that code.

In this section we never add code to free textures, but I wonder if there is somewhere that makes more sense to put the code once we’re introduced to classes? Would it go in the destructor for a class or would that break other members of the same class?

That could potentially break instances of the same class.

What’s likely better is to create a pool of searchable textures (likely a hashmap) that you can reference. Then you can delete them as needed (again, being careful that they aren’t referenced).

That said, for Classy Clash it was an oversight on our part. Thankfully everything gets cleared up once you close the game or stop debugging.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms