Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » Managing sub-bitmaps

Credits go to Elias for helping out!
This thread is locked; no one can reply to it. rss feed Print
Managing sub-bitmaps
pmprog
Member #11,579
January 2010
avatar

Hopefully a quick question.

If I create a subbitmap, it says in the docs that if I delete the parent, the sub will become invalid. So do I need to delete subbitmaps? If so, is "al_destroy_bitmap" the function to use?

Kind of related, do subbitmaps perform better than using the al_draw_*_region functions? My code runs dog slow under Windows, but runs fine under Linux, using the al_draw_*_region functions, and was wondering if I should use sub-bitmaps (which I've never really used). As a side note, I have tried with both al_hold_drawing on and off

One thing I am aware of, is that with MSVC, the debug build of Allegro is crazy slow. When OpenApoc was using Allegro, if you wanted to dev in Windows/MSVC, you had to use the release version of Allegro, otherwise it would literally take minutes to start up cityscape.

I've been unable to build Allegro 5.2 using MSVC (2013) myself (gives me errors relating to ALLEGRO_DISPLAY not being defined in the ogl module, yet you can navigate to it in the code through the #includes, so it clearly is), so I'm using the binaries from nuget (which I downloaded and unzipped, because I don't really "get" nuget)

Sorry that ended up being a bit more verbose than planned.

Regards,
pmprog

Elias
Member #358
May 2000

Yes, you call al_destroy_bitmap for every al_create_sub_bitmap.

No, al_draw_bitmap_region does the exact same thing - you can click the small "source" link at [1] and at [2] and then if you look you see that both actually just call [3] - so they are 100% identical performance wise.

--
"Either help out or stop whining" - Evert

pmprog
Member #11,579
January 2010
avatar

Thanks for the reply. I guess I'm not sure why I'd use a subbitmap then if it does the same thing.

Need to see if I can figure out why I can't build a MSVC version of Allegro, and hope that that fixes the performance issue on Windows

Elias
Member #358
May 2000

The sub bitmap stores the offset and size for you... that can be a good reason :)

--
"Either help out or stop whining" - Evert

Niunio
Member #1,975
March 2002
avatar

Elias said:

The sub bitmap stores the offset and size for you...

Also different clipping rectangles and transformation matrix in each sub-bitmap wich would be useful in some cases.

-----------------
Current projects: Allegro.pas | MinGRo

Go to: