All the sprites vanish after returning

Started by RayRayTea2, February 21, 2013, 09:49:27 AM

Previous topic - Next topic

RayRayTea2

After filling the screen with sprites, pressing CTRL + Alt + Del and selecting Task Manager results in sprites on screen disappearing forever!... and new sprites don't show up on the screen either (although I can hear the sound of them popping up). Anybody else having this or is it just on my computer (Win 7 64bit)?

How to see this in action: download the sprite generator. Fill the screen with a few flames (press space and move the mouse around). CTRL + Alt + Del, select Task manager (Windows throws you to a special screen)... after returning to the main Windows desktop, all the sprites stop working!

Big C.

this is a known thing and some answers are here on the forum.

the short version is: you lost your images if you put your app in the background. So you have to recognize the trigger for that, save temporary your imagesstatus etc and load back or recreate your images after you got the focus back to your appp.

RayRayTea2

Oh wow that's... so I'd have to come up with a whole backup system just to deal with the possibility of the application being pushed to the back (or Task Manager being summoned etc). Haven't seen it mentioned on the forums though.

stevmjon

if i remember correctly, this only effects video images. fx and afx images are safe.

loadimage = video memory
loadfximage = system memory
loadafximage = system memory

hope this helps,  stevmjon
It's easy to start a program, but harder to finish it...

I think that means i am getting old and get side tracked too easy.

kevin


Unfortunately this is how Windows was designed,  the OS deletes the direct draw surfaces living in video  memory and you can't catch this process.  When the app is reactivated, PB creates replacement surfaces for you, but these won't have the original pixel data in them, that data is lost when windows throws it away.     

You can detect such interruptions, by checking the pixel data in image, if it's changed from what it should be.  Then those surfaces have been flushed/reallocated at some point.  I generally just time the interval between two frames, if the frame runs long.. like beyond 500 milliseconds, then something has possibly occurred.    The same goes for making the app play nice on the host system.  Such montioring if the app is in focus, where it makes sense to give as much time back to the system as possible .. ie WAIT 

  I generally don't really bother using video surfaces, mostly FX/AFX.   There's a number of articles spread all of the forums.

Restoring after System interruptions (like Alt Tab).



RayRayTea2

Thanks guys, I guess I'll just use the AFX from now on (I depend on Alphas for so many things anyway), maybe if one day I become a Master PB Programmer I'll try this too.