[AD] al_acknowledge_drawing_resume(ALLEGRO_DISPLAY *, void (*user_reload)(void))?

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


It's another one of those "looking for a better way or approval" threads. Since this hasn't gotten into 5.0.x yet it's a good time. Sorry that these things keep coming up, but with all the quirky hardware out there each new device brings untold code breaking drivers and stuff.

Take a typical game on Android: You don't really want to enable PRESERVE_TEXTURE on everything because you have limited memory. So, as is my situation, you have a pool of bitmaps that you reload each drawing halt, and a bunch that Allegro handles for you. There's a bad situation that can crop up:

1) When you get the HALT event you destroy all those bitmaps. Allegro, behind the scenes, backs up stuff. Then you get a RESUME. You can't refresh your bitmaps before the resume. So in the acknowledge_resume function, Allegro refreshes its bitmaps. So you refresh yours afterwards.

Here's the problem: Some of your bitmaps may depend on Allegro's and vice versa. Either they need each other to redraw themselves, or they're sub-bitmaps and you can't recreate them automatically in Allegro because you destroyed all of your self-managed bitmaps and you're reloading them after acknowledge_resume.

So it boils down to this: You may need to refresh some of your bitmaps before Allegro does its own, and you may need to refresh some after. Right now you can do it after, but not before. As I said, you can't just place a call before acknowledge_resume because that function sets up some state (makes context current etc).

Well my idea is simple, but last time Elias has a good idea so maybe you can beat it. I propose having an optionally NULL function pointer parameter to al_acknowledge_drawing_resume that is called after the context settings and stuff, but before Allegro refreshes its bitmaps. That gives you the ability to recreate stuff Allegro needs (such as stuff Allegro holds sub bitmaps of). You can still do you thing after the call to acknowledge_resume, so that doesn't change.

What do you think? I have this setup in my checkout now and it works well. It solved my problem of interdependencies. I'd like to hear some feedback though, either "good", "bad", or "maybe try this instead"...

Thanks,
Trent



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/