How to use acquire_bitmap
Sylvarant

How do you use the acquire_bitmap function so that it improves your gamespeed?
I'm currently just putting acquire_bitmap int the beginning of my main draw loop, is that the best way?

LennyLen
Adriaan Larmuseau said:

I'm currently just putting acquire_bitmap int the beginning of my main draw loop, is that the best way?

The Allegro Manual said:

These calls are not strictly required, because the drawing routines will automatically acquire the bitmap before accessing it, but locking a DirectDraw surface is very slow, so you will get much better performance if you acquire the screen just once at the start of your main redraw function, and only release it when the drawing is completely finished.

edit:

some pseudo-code:

While (game not over) {
    
    do logic;
    acquire_bitmap();
    do drawing;
    release_bitmap();

}

Kitty Cat

note the acquiring the screen or a video bitmap will cause input and timers to stop temporarilly. The only thing you should have between acquire_bitmap and release_bitmap is code to draw to that bitmap (and even then, it's only beneficial if you do more than one drawing operation at a time; so doing it just to blit to the screen is wasteful).

Thread #588297. Printed from Allegro.cc