Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » How to use acquire_bitmap

This thread is locked; no one can reply to it. rss feed Print
How to use acquire_bitmap
Sylvarant
Member #7,886
October 2006

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
Member #5,313
December 2004
avatar

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
Member #2,815
October 2002
avatar

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).

--
"Do not meddle in the affairs of cats, for they are subtle and will pee on your computer." -- Bruce Graham

Go to: