This is the init of allegro:
1 if (
6 if (
global->graphicsSettings->getMultisamplingLevel() != 0)
this->display = al_create_display(
21 if (!
std::runtime_error("failed to create display!");
23 if (!al_init_image_addon())
std::runtime_error("Failed to initialize al_init_image_addon!");
this->temporaryIcon = al_load_bitmap((
global->resourcePath / "factorio-icon.png")
27 if (!
std::runtime_error("Failed to load window icon!");
31 if (!al_install_keyboard())
std::runtime_error("failed to initialize the keyboard!");
33 if (!al_install_mouse())
std::runtime_error("failed to initialize the mouse!");
36 if (!al_init_ttf_addon())
std::runtime_error("failed to initialize the ttf addon!");
38 if (!al_init_primitives_addon())
std::runtime_error("failed to load primitives addon!");
40 if (!al_install_audio())
std::runtime_error("Failed to install audio!");
42 if (!al_init_acodec_addon())
std::runtime_error("Failed to initialize audio codecs!");
44 if (!al_reserve_samples(50))
std::runtime_error("Failed to reserve samples!");
This is the part of the atlas bitmap creation (those are the bitmaps that get corrupted)
At this stage:
new bitmap format flags = 2
New bitmap flags = 1024
These values are the same for the 5.1.3 and 5.1.5 version.
When I resize the display al_acknowledge_resize->d3d_acknowledge_resize is called (not al_resize_display)
I tried to mimic the change in the peters patch, and added this line to the
d3d_acknowledge_resize function, but it didn't help.
Edit: I did some debugging, _al_d3d_refresh_texture_memory is called, it obviously goes through all my bitmaps and sub-bitmaps
Edit: My fight with the bug continues.
I found out, that even in 5.1.3 I have the same problem, when I stop using the window icon. Yes you heard me right, I stop using window Icon and resizing now starts to mess all my bitmaps.
I found out, that this has something to do with the fact, that I used subitmap of my atlas bitmap for the windows icon, and that the fact, that I used it changed the state of the bitmap.
Properties :lock_x, lock_y, lock_w, lock_h and lock_flags had all value -842150451 when I didn't use the bitmap from the atlas as window icon.
When I use it, it changes these values and the resize works correctly.
So I tried to turn the using of the window icon off and call this function on the atlas after it is filled with images:
and really strange thing happened, the atlas did survive the resize, but just once!
When I tried to resize again, it was lost again.
So I tried to call this function after every resize, but it didn't help, second resize did kill it.
This is all magic for me now ... computers ... zeros and ones, nobody really can understand it.
Edit: So I investigated more, and went deep into the drawing routine, and found out, what exactly happens there, seems, like calling this on all of my atlas bitmaps saves them from being lost:
In other words, atlas needs to have lock flags, but can't be locked to make it work.