![]() |
|
Getting size of ALLEGRO_BITMAP |
Aikei_c
Member #14,871
January 2013
![]() |
I am writing a resource manager for my game which should tell if some limit of allocated resources has been breached and delete some least used resources in this case (as well as allocate resources, count how much memory is in use for these resources etc.). |
Thomas Fjellstrom
Member #476
June 2000
![]() |
ALLEGRO_BTIMAP *bmp = al_load_bitmap("foo.png"); int size = al_get_bitmap_width(bmp) * al_get_bitmap_height(bmp) * al_get_pixel_size(al_get_bitmap_format(bmp)); That should do it. -- |
Aikei_c
Member #14,871
January 2013
![]() |
That's a good idea, thank you, Thomas. |
jmasterx
Member #11,410
October 2009
|
Note that if you use mipmapping, these numbers won't be totally accurate for vram usage. Also note that, in some cases, such as using texture preservation in D3D, Allegro keeps a backup of the texture in system memory. Also, in cases where non-power-of-2 textures are not supported, Allegro might pad your bitmap to PO2, so that might take up more memory. Sometimes too, the graphics driver will do this too. Also, if you use Windows, you may want to try MSI Afterburner. This neat tool can tell you how much vram is in use. So before you start your app, just note how much vram is used, and the difference between the value when your app is running and this start value is how much vram your app is consuming. Agui GUI API -> https://github.com/jmasterx/Agui |
|