|
Allegro 5.1.5 and resizing problems |
kovarex
Member #14,203
April 2012
|
Hi, I'm just struggling with the upgrade of allegro 5.1.3 -> 5.1.5. a) Fonts are working I went through the changelog of 5.1.4 and 5.1.5 and I didn't find any clue, do you have any suggestion? Edit: www.factorio.com - a factory building game. |
jmasterx
Member #11,410
October 2009
|
I just upgraded to 5.1.5 to try this out. My game uses a bunch of fonts and dynamic resizing and I'm not seeing any problems. :/ -Try using OpenGL. Agui GUI API -> https://github.com/jmasterx/Agui |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Did you do an initial clear on all your bitmaps? Or are they all resources you loaded in that were working before the resize? I'm not seeing this behaviour with the latest git + Peter's patch. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
kovarex
Member #14,203
April 2012
|
I did incorporate the patch (sorry that I didn't mention it in the first post), works the same with or without it. When I switch to OPENGL it works. (But I need to use d3d on windows, for obvious (performance) reasons) Edit: Isn't it strange, that d3d_resize_display was never called when I resized? (only d3d_acknowledge_resize). www.factorio.com - a factory building game. |
jmasterx
Member #11,410
October 2009
|
Is there any way you could show some pertaining code? -Init Agui GUI API -> https://github.com/jmasterx/Agui |
kovarex
Member #14,203
April 2012
|
This is the init of allegro: 1 if (global->graphicsSettings->getFullScreen())
2 al_set_new_display_flags(ALLEGRO_FULLSCREEN_WINDOW);
3 else
4 al_set_new_display_flags(ALLEGRO_RESIZABLE);
5 al_set_new_display_option(ALLEGRO_VSYNC, 1, ALLEGRO_SUGGEST);
6 if (global->graphicsSettings->getMultisamplingLevel() != 0)
7 {
8 al_set_new_bitmap_flags(ALLEGRO_MIN_LINEAR | ALLEGRO_MAG_LINEAR | ALLEGRO_VIDEO_BITMAP);
9 al_set_new_display_option(ALLEGRO_SAMPLE_BUFFERS, 1, ALLEGRO_SUGGEST);
10 al_set_new_display_option(ALLEGRO_SAMPLES, global->graphicsSettings->getMultisamplingLevel(), ALLEGRO_SUGGEST);
11 }
12 else
13 {
14 al_set_new_bitmap_flags(ALLEGRO_VIDEO_BITMAP);
15 al_set_new_display_option(ALLEGRO_SAMPLE_BUFFERS, 0, ALLEGRO_SUGGEST);
16 al_set_new_display_option(ALLEGRO_SAMPLES, 0, ALLEGRO_SUGGEST);
17 }
18
19 this->display = al_create_display(width, height);
20
21 if (!this->display)
22 throw std::runtime_error("failed to create display!");
23 if (!al_init_image_addon())
24 throw std::runtime_error("Failed to initialize al_init_image_addon!");
25
26 this->temporaryIcon = al_load_bitmap((global->resourcePath / "factorio-icon.png").string().c_str());
27 if (!this->temporaryIcon)
28 throw std::runtime_error("Failed to load window icon!");
29 al_set_display_icon(this->display, this->temporaryIcon);
30
31 if (!al_install_keyboard())
32 throw std::runtime_error("failed to initialize the keyboard!");
33 if (!al_install_mouse())
34 throw std::runtime_error("failed to initialize the mouse!");
35 al_init_font_addon();
36 if (!al_init_ttf_addon())
37 throw std::runtime_error("failed to initialize the ttf addon!");
38 if (!al_init_primitives_addon())
39 throw std::runtime_error("failed to load primitives addon!");
40 if (!al_install_audio())
41 throw std::runtime_error("Failed to install audio!");
42 if (!al_init_acodec_addon())
43 throw std::runtime_error("Failed to initialize audio codecs!");
44 if (!al_reserve_samples(50))
45 throw std::runtime_error("Failed to reserve samples!");
46 this->loadAllegroFonts();
This is the part of the atlas bitmap creation (those are the bitmaps that get corrupted) this->atlas = al_create_bitmap(this->width, this->height); if (this->atlas == NULL) throw std::runtime_error(ssprintf("Couldn't create atlas bitmap (size %uX%u)." "Probably not enough of video memory.", this->width, this->height)); al_set_target_bitmap(this->atlas); al_clear_to_color(al_map_rgba_f(0, 0, 0, 0)); 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 _al_d3d_prepare_bitmaps_for_reset(disp); 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. 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. 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: al_lock_bitmap(atlas.atlas, al_get_bitmap_format(atlas.atlas), ALLEGRO_LOCK_READONLY);
and really strange thing happened, the atlas did survive the resize, but just once! 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: // MAGIC, when removed, atlas is lost on resize al_lock_bitmap(atlas, ALLEGRO_PIXEL_FORMAT_ANY, ALLEGRO_LOCK_READONLY); al_unlock_bitmap(atlas); In other words, atlas needs to have lock flags, but can't be locked to make it work. www.factorio.com - a factory building game. |
|