Does Aal_convert_bitmaps Preserve Bitmap Flags?
jmasterx

I found a bug in Allegro when using OpenGL and this laptop I have with a GMA 4400 on Win8.

When I go from fullscreen window back to windowed, things mess up and it doesnt go back to windowed.

Even ex_fullscreen_window messes up if I tell it to use GL. Ofcourse D3D works fine. -_-

To try to address this, I tried to recreate the display instead of toggling the flag. This works. Only issue is now none of the bitmaps have mipmap, mag linear, etc.

      m_sceneMessenger->sendContextWillChangedMessage();
      Vec2 resolution = getResolution();
      al_set_new_display_flags(ALLEGRO_OPENGL | ALLEGRO_PROGRAMMABLE_PIPELINE | ALLEGRO_WINDOWED);
      al_set_new_bitmap_flags(
        ALLEGRO_VIDEO_BITMAP | ALLEGRO_MIN_LINEAR | 
        ALLEGRO_MAG_LINEAR | ALLEGRO_MIPMAP | ALLEGRO_CONVERT_BITMAP);
      al_destroy_display(context);
      context = al_create_display(resolution.getX(),resolution.getY());
      al_set_new_bitmap_flags(
        ALLEGRO_VIDEO_BITMAP | ALLEGRO_MIN_LINEAR | 
        ALLEGRO_MAG_LINEAR | ALLEGRO_MIPMAP | ALLEGRO_CONVERT_BITMAP);
      al_convert_bitmaps();
      m_sceneMessenger->sendContextChangedMessage();

Is this normal or is al_convert_bitmaps supposed to restore mipmap, maglinear etc?

Using 5.1.10 on Windows 7/8

Bruce Pascoe

I've noticed that as well, if you try to un-fullscreen a fullscreen window in OpenGL mode it gets stuck in some sort of weird "limbo" state. It only seems to happen on Intel cards though, on my AMD machine it works fine.

What's weird is that I also has a screenshot feature, and if I activate that while it's in "limbo", the screenshot code cloning the backbuffer usually coaxes it the rest of the way out of fullscreen mode.

That might be a thing to try, actually: In your code that switches between fullscreen and windowed modes, what happens if you add this line after the switch:

Does that work around the issue?

jmasterx

Wow, that completely fixed it! Many thanks! :)

Bruce Pascoe

I hereby dub this fix "How I fixed Allegro fullscreen using this one weird trick" ;)

SiegeLord

From what I understand, when bitmaps get converted, they all get their flags set to what is passed to al_set_new_bitmap_flags. It's not obvious how to get them to preserve flags, since if there's a memory bitmap in between conversions, it'll necessarily lose some flags.

As for the fullscreen toggling, I'll investigate it at some point.

jmasterx
SiegeLord said:

they all get their flags set to what is passed to al_set_new_bitmap_flags.

In this case that did not happen at all. I tried to shove calls to al_set_new_bitmap_flags with mipmap, mag linear etc before, after etc recreating the display but none of the bitmaps ever wound up having those attributes after conversion.

Maybe because Allegro notes that to have mipmap you need power of 2 textures and many of my textures are not power of 2 so maybe when they are converted they are not converted to power of 2?

Thomas Fjellstrom

I wonder if we should store the "last_flags" or something for a converted bitmap, so when its converted back it can keep its previous flags.

jmasterx said:

maybe when they are converted they are not converted to power of 2?

Hm, if allegro is actually turning your bitmaps into power of 2 textures, and isn't when its converting back, it probably should.

SiegeLord

Alright, so the situation somewhat different. Turns out al_convert_bitmaps merely toggles whether the bitmap is memory or not, but otherwise it preserves the remaining flags. What was happening in your example was that when the display was destroyed, the flags were reset to just ALLEGRO_MEMORY_BITMAP. I've now fixed it to preserve the bitmap flags upon destruction, so everything should be fine.

I'm still investigating the toggling issue.

Bruce Pascoe

Alright, good you're still looking into that issue, it's been plaguing me for a while. It only seems to occur on machines with Intel graphics, my main development machine (AMD) doesn't exhibit it.

Regardless, the workaround I came up with above has to be my favorite fix of all time:

#SelectExpand
513 // strange but true: this fixes an Allegro bug where OpenGL displays get 514 // stuck in limbo when switching out of fullscreen. 515 al_destroy_bitmap(al_clone_bitmap(al_get_backbuffer(g_display)));

:P

Thread #615520. Printed from Allegro.cc