Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » What is the fastest way to draw a large bitmap?

This thread is locked; no one can reply to it. rss feed Print
What is the fastest way to draw a large bitmap?
EatDaPewPew
Member #16,739
September 2017

I am making a game where you can scroll around a bitmap. I can play it fine on my i7 computer just fine up to a certain size. Then things get really slow. I have tried to get it running on a raspberry pi, but it is too slow to be playable even on the smallest size of bitmap. I have tried using a function called al_hold_bitmap_drawing() when I draw the large scrollable bitmap, but it only helped slightly. :-/

Edgar Reynaldo
Member #8,592
May 2007
avatar

If you're going to need a large tile map (that is too big to be a video bitmap), then you're going to need to break it up into individual textures. Find the max texture size and create as many textures that size as you need to cover the tile or background map.

EDIT
So, the algorithm I would use is something like this :

int NTWIDE = map->W()/MaxTextureWidth() + (map->W()%MaxTextureWidth())?1:0;
int NTTALL = map->H()/MaxTextureHeight() + (map->H()%MaxTextureHeight())?1:0;

Texture* TEXARRAY = new Texture[NTWIDE*NTTALL];
for each TEX in TEXARRAY :
   BLIT(MAP , x , y , MaxTextureWidth() , MaxTextureHeight() ,
        TEX , 0 , 0 , MaxTextureWidth() , MaxTextureHeight())

beoran
Member #12,636
March 2011

Use al_get_display_option with ALLEGRO_MAX_BITMAP_SIZE as the option parameter to see how big a hardware accelerated bitmap may be.

Go to: