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?

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).

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.

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)

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.

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.

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).

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).

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.

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)