- Online Community Forums » Programming Questions » al_set_target_bitmap on windows performace

This thread is locked; no one can reply to it. rss feed Print
al_set_target_bitmap on windows performace
Member #17,215
December 2019

Hi, I have a problem with perfomance on windows using Allegro.

My rendering loop is pretty simple:
1) Setup "buffer" texture as render target using al_set_target_bitmap.
2) Draw all stuff.
3) Setup display as render target.
4) Render "buffer" texture scaled by actual zoom to the display.

For maximal zoom of factor 2, the buffer texture has size (resolution * 2). All textures are video bitmaps.

On my linux system it works like a charm, I am able to achieve more than 1300 FPS in release build with hundrets of objects each frame (all from single texture in texture atlas).

But on the same machine on windows it drops to 30 FPS. Quite diference. I was able to simplify the problem code to simple setup of buffer texture. Even if I simply remove all drawing from the rendering loop and keep this simple code, it is still slow down to 100 FPS:


If I comment these two lines I have more than 2400 FPS.

Do you have any idea where the problem could be? Thank you very much for your answers.

I found a solution. The key is to create these "buffer" textures with ALLEGRO_NO_PRESERVE_TEXTURE flag enabled. And because it is only "buffer" texture is perfectly safe to not worry about losing it's content.

Edgar Reynaldo
Major Reynaldo
May 2007

Frank Drebin
Member #2,987
December 2002

I found the same increase in FPS when creating the buffer with the flag ALLEGRO_NO_PRESERVE_TEXTURE is enabled:


Member #17,215
December 2019

It seems that the slowdown increases with size of the buffer texture. So in my case where the size was 5120x2160, the difference was huge. Without the flag I got 30 FPS, with the flag a get over 1400 FPS :)

Member #3,861
September 2003

Wow the speed increase is great !

How can I try ?

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

Go to: