Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Destroying sub bitmaps?

This thread is locked; no one can reply to it. rss feed Print
Destroying sub bitmaps?
Itachihro
Member #12,001
May 2010

What happens when you destroy a sub-bitmap? Is destroying sub-bitmaps necessary?

gnolam
Member #2,030
March 2002
avatar

Itachihro said:

What happens when you destroy a sub-bitmap?

The sub bitmap is destroyed. The parent bitmap is untouched.

Quote:

Is destroying sub-bitmaps necessary?

Yes.

--
Move to the Democratic People's Republic of Vivendi Universal (formerly known as Sweden) - officially democracy- and privacy-free since 2008-06-18!

Itachihro
Member #12,001
May 2010

Well damn, in that case I somehow need a special case for handling sub-bitmaps in my sprite managers. I knew this wasn't going to be quite as easy as I thought it would.

Todd Cope
Member #998
November 2000
avatar

Maybe this will help: al_is_sub_bitmap(). Otherwise, not sure what you could be doing that would be difficult to deal with.

Itachihro
Member #12,001
May 2010

I'm managing my resources with smart pointers, so for sub bitmaps I have to keep a reference to the parent bitmap (so it doesn't get destroyed prematurely) as well as to the actual sub bitmap, so it made it a little less pleasant (I previously hoped I'd get away with ignoring the differences between the two) (I ended up writing subclasses for both cases, and then wrapping those in another class to hide pointer usage).

Temia Eszteri
Member #14,459
July 2012
avatar

Perhaps you could maintain an array of pointers to reference which sub-bitmaps have branched from a parent one? Or a basic reference counter, one of the two. That way if you need to destroy a parent bitmap for whatever reason, it won't happen if it's in use.

“Nothing is withheld from us what we have conceived to do.” —Russell Kirsch

Go to: