[A5] Display lost/found events are never fired

Hi there,

I did post the same question a year ago, tho did not get any replies then. I am eager to tackle the same problem once again.

So, has anyone successfully implemented a Direct3D allegro display with ALLEGRO_NO_PRESERVE_TEXTURE bitmaps?

My issue is that display lost/found events are never fired (display event source is registered in event queue, can confirm this as I am getting display expose events).

Is it possible that video card drivers are affecting this?

(Testing on Windows 7 using Allegro 5.0.5)

Thomas Fjellstrom

That sounds strange. I'm pretty sure this works for other people. Could you show us the code your using? Or better yet, an absolute minimal example that still has this problem?


Hi Thomas,

I can't really post the full code as it spans multiple classes, but here is a pseudo excerpt:

1. Event queue:

2. Display setup:

1// Allegro bitmap setup 2al_set_new_bitmap_format(ALLEGRO_PIXEL_FORMAT_ARGB_8888); 3al_add_new_bitmap_flag(ALLEGRO_VIDEO_BITMAP); 4al_add_new_bitmap_flag(ALLEGRO_NO_PRESERVE_TEXTURE); 5 6// Display options and flags 7al_set_new_display_option(ALLEGRO_VSYNC, 0, ALLEGRO_SUGGEST); 8 9int displayFlags = 0; 10displayFlags |= ALLEGRO_DIRECT3D; 11displayFlags |= ALLEGRO_GENERATE_EXPOSE_EVENTS; 12displayFlags |= ALLEGRO_WINDOWED; 13displayFlags |= ALLEGRO_RESIZABLE; 14 15al_set_new_display_flags(displayFlags); 16 17ALLEGRO_DISPLAY* display = al_create_display(400, 400);

3. Display event source registration:

4. Bitmaps are created (not using any custom formats or flags, but default as defined above)

5. Event loop:


while (true) {

  al_wait_for_event(eventQueue, &event);

  if (event.type == ALLEGRO_EVENT_DISPLAY_FOUND) {
    // Never reported (same for ALLEGRO_EVENT_DISPLAY_LOST)
  // Other events
  else if (...) {


I can see that the bitmaps loose their textures if I resize display window, so at least ALLEGRO_NO_PRESERVE_TEXTURE seems to work as expected. However, the trouble is I never get lost/found events and that makes it a bit of a challenge to know when you need to re-create them.

Edit: I am also using VS2010 allegro static lib binaries from allegro.cc if that matters somehow?

Edit 2: My application is single-threaded.

Thomas Fjellstrom

Can you make an absolute minimal example that shows this problem? Something that is compilable and works?


Hi Thomas,

Thanks for helping me with this problem. I did create a very-minimal Visual C++ 2010 project illustrating the problem (attached).

There is a pre-compiled release EXE for testing (statically linked so there shouldn't be any dependencies for running). The code is in "main.cpp".

The program will pretty much do all the steps as in my post above, except it will also draw a blue bitmap with a timer. Display resize/lost/found events are sent to console.

Now on my laptop (late 2008 Macbook NVIDIA GeForce 9400M with bootcamp Windows 7 32-bits) display lost/found events are never reported (I have included a couple of screenshots in the attached ZIP to illustrate this).


Trent Gamblin

Here it's reporting some lost/found events but not on minimize. If I press Ctrl+Alt+Delete it does show the lost and found events. So I'm not sure why minimize isn't causing the events...


Just tested the same executable on a different machine (Windows 7 64-bits on NVIDIA GeForce 460 GTX) - and no lost/found events are reported there too.

Trent, what OS and video card have you got?

Oscar Giner

I don't get any lost/found event with your test. All I get are resize events if I resize, minimize, maximize or restore after maximize. No resize event if I restore a minimized Window. After I do any of those actions, the blue rectangle doesn't draw any more, and in its place there are a few random coloured pixels.

On a side note, the window border is horrendously thick.

I have an HD 6950 running Windows 7 64 bit.


Thanks Oscar, that is exactly my issue here. Apparently others are receiving lost/found events and I suspect that this could somehow be related to Windows 7 (as the events now seem to missing on both NVIDIA and AMD cards/drivers).

(The thing with an image turning into a random colored pixel junk is a result of ALLEGRO_NO_PRESERVE_TEXTURE flag, which is what we are basically testing here and is expected behavior)

Trent Gamblin

I was using Windows 7 64 bit. Did you try ctrl+alt+delete? I looked at the code and the lost/found detection looks like it's made so that the reason doesn't matter, so the events should be firing no matter what the cause. It's easy to hook minimize/maximum and fire the events there too but I'd like to know if that's normal behaviour or if the d3d code is broken. There may be more info on MSDN.

EDIT: Also I'm using 5.1. Could be that a fix wasn't backported to 5.0.



I tried with Ctrl+Alt+Delete - still no good, no lost/found events here.
As for using 5.1 - what do you mean? I have statically linked allegro 5.0.5 into provided EXE binary.

Since you are on Windows 7 as well, I am a bit lost. Could any Allegro developers look into this?

Trent Gamblin

I compiled your program myself using 5.1... and I am an Allegro developer :P.


Alright, that means I am in good hands and at the right place :)

Update: Built allegro 5.1 from the latest SVN 5.1 branch and re-compiled my test program using the new lib, results:

- When re-sizing I am still getting no lost/found events, however the ctrl+alt+del switch will now generate a lost and found event (and that never happened with 5.0.5). So at least something did change there for 5.1 branch, but it's still bugged.

(I have also attached just that new EXE linked with allegro 5.1).

Oscar Giner

With the new exe now it generates the lost/found event with Ctrl+Alt+And, but the blue rectangle gets lost still.

Trent Gamblin

That's expected Oscar, when using the ALLEGRO_NO_PRESERVE_TEXTURE flag with D3D. Except the part about not getting lost/found events on minimize. I'll try my best to look into it tomorrow after my regular work routine.


Trent, just to make clear - the events are also missing when re-sizing a window. Actually, is it normal for the Direct3D device to be lost just by re-sizing a window? I always thought you need something more serious for this to happen (a fullscreen switch or an alt-tab).

An excerpt from MSDN:

By design, the full set of scenarios that can cause a device to become lost is not specified. Some typical examples include loss of focus, such as when the user presses ALT+TAB or when a system dialog is initialized. Devices can also be lost due to a power management event, or when another application assumes full-screen operation. In addition, any failure from IDirect3DDevice9::Reset puts the device into a lost state.

E.g. nothing is mentioned even close to a simple window resize.

And do you think it's feasible to expect this fix in a stable 5.0 branch? (As I understand 5.1 is still not going to go stable any time soon).

Thanks again for looking into this,


Trent Gamblin

Yeah, it's not true that a device is "lost" on resize. Really it's not lost, it's manually recreated by Allegro though which has the same effect. Allegro does this so that the backbuffer is resized correctly, otherwise you'd get odd stretched disproportionate views. So ya, it needs to generate lost+found events when these things happen because the code now only checks for actual lost/found events from D3D like alt-tab out of fullscreen.

Neil Walker

Probably the same as everyone else, but I get resize events on resizing and minimise/maximise and a display found on coming back from ctrl-alt-delete. minimising/maximising loses the rectangle to be replaced by a couple of random pixels (probably caused by the video bitmap being lost)

Thread #609234. Printed from Allegro.cc