bitmap layering
ioncherry

Hello there fellow allegroids!

I was wondering if you could clear a couple of things up for me - firstly, is there a way to chose what layer your bitmap is on, so can I set it so that a certain bitmap is shown above another which is called later on in the program? - I ask this because as part of my game half way through I clear a bitmap to transparent colour, only problem is when objects go over this space the objects are going behind the white colour instead of infront!

A second query I have is the following - Is there a way when blitting multiple of the same bitmaps to set it so that each different blit is defined to it's own value so that the you can destroy one but not the other.

For example if I was to do the following:

         blit( image, buffer, 0, 0, 500, 200, image->w, image->h );
         blit( image, buffer, 0, 0, 500, 400, image->w, image->h );

and I was then to call destroy_bitmap(image); both images would be destroyed.

I would like it so that they can be each individually assigned so I can do different things to them whilst using the same bitmap.

Thank you in advance and I apologise if that was a really over explained version of a simple question!!

Jeff Bernard
ioncherry said:

is there a way to chose what layer your bitmap is on, so can I set it so that a certain bitmap is shown above another which is called later on in the program?

Bitmaps are drawn in the order you call blit. So for that, I'd implement a deferred drawing system. Instead of calling blit like you normally would, you'd push some object representing the draw into a sorted list. Then you just iterate through the list. If your objects aren't going to be changing layers, then you won't need to update these list every tick, only when things should be removed/added.

Quote:

Is there a way when blitting multiple of the same bitmaps to set it so that each different blit is defined to it's own value so that the you can destroy one but not the other.

No... but you could load the same bitmap twice for some reason? If you want to not draw one of them, then don't draw one of them, destroy_bitmap does not erase a bitmap from the screen.

ioncherry

Thank you for the reply,

Ahh okay - well I've sorted the layering now so thank you!

Does this mean I'm going to have to make multiple of the same bitmap files and rename them differently and blit them all seperately then if I want to do different things to them?

Cheers

Dizzy Egg

Nope. Have 1 bitmap file on your computer, and load it into as many different ALLEGRO_BITMAPS as you want!

ALLEGRO_BITMAP *bitmapA = load_bmp("myOneBitmap.bmp", NULL);
ALLEGRO_BITMAP *bitmapB = load_bmp("myOneBitmap.bmp", NULL);
ALLEGRO_BITMAP *bitmapC = load_bmp("myOneBitmap.bmp", NULL);
ALLEGRO_BITMAP *bitmapD = load_bmp("myOneBitmap.bmp", NULL);
ALLEGRO_BITMAP *bitmapE = load_bmp("myOneBitmap.bmp", NULL);
ALLEGRO_BITMAP *bitmapF = load_bmp("myOneBitmap.bmp", NULL);

pkrcel

Or load once and then al_clone_bitmap...or whatever your resource management style implies. :)

(Of course this post and Dizzy's refer(s) to Allegro5 API. :P ..gotta check beter next time).

ioncherry

Thanks so much guys! Dizzy got it spot on :D - Also thank you pkrcel - it's my fault I didn't mention that I'm using allegro 4, otherwise that would of been perfect as well!! Cheers all

Thread #612474. Printed from Allegro.cc