# DX5 Front buffer Lost Surface

**URL:** <https://discourse.libsdl.org/t/dx5-front-buffer-lost-surface/3344>\
**Category:** SDL Development\
**Created:** [October 18, 2000, 9:01pm UTC](https://discourse.libsdl.org/t/dx5-front-buffer-lost-surface/3344 "2000-10-18T21:01:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Manny](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/m/dec6dc/32.png) [@Manny](https://discourse.libsdl.org/u/Manny)\
**Post date:** [October 18, 2000, 9:01pm UTC](https://discourse.libsdl.org/t/dx5-front-buffer-lost-surface/3344/1 "2000-10-18T21:01:27Z")

</div>

Lordy I hate direct draw…

In DX5\_WindowUpdate, there isn’t a check for lost surface. So if another  
app gets exclusive mode, the screen goes black and stays that way until  
resized.

I copied the restore code from another routine and this seems to be working:  
(after, of course, getting the result from the blt…)

if(result == DDERR\_SURFACELOST )  
{  
result = IDirectDrawSurface3\_Restore(SDL\_primary);  
result = IDirectDrawSurface3\_Blt(SDL\_primary, &dst,  
this-\>screen-\>hwdata-\>dd\_surface, &src,  
DDBLT\_WAIT, NULL);  
}

---

<div class="post-metadata">

**Author:** ![Janis\_Kovalevskis](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/j/74df32/32.png) [@Janis\_Kovalevskis](https://discourse.libsdl.org/u/Janis_Kovalevskis)\
**Post date:** [October 19, 2000, 8:42pm UTC](https://discourse.libsdl.org/t/dx5-front-buffer-lost-surface/3344/2 "2000-10-19T20:42:28Z")

</div>

Yep, this was problem for me also. It is great to find somebody to write a  
solution for this. 😉

Can it be added to windows sdl version, or it is already done? Because  
this bug _really_ sux, as there was no nice way to detect it, and there  
was need to make an ugly workaround for it.

```
KovacsOn Wed, 18 Oct 2000, Manny wrote:

```

> Lordy I hate direct draw…
> 
> In DX5\_WindowUpdate, there isn’t a check for lost surface. So if another  
> app gets exclusive mode, the screen goes black and stays that way until  
> resized.
> 
> I copied the restore code from another routine and this seems to be working:  
> (after, of course, getting the result from the blt…)
> 
> if(result == DDERR\_SURFACELOST )  
> {  
> result = IDirectDrawSurface3\_Restore(SDL\_primary);  
> result = IDirectDrawSurface3\_Blt(SDL\_primary, &dst,  
> this-\>screen-\>hwdata-\>dd\_surface, &src,  
> DDBLT\_WAIT, NULL);  
> }

---

<div class="post-metadata">

**Author:** ![slouken](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/s/ec9cab/32.png) [@slouken](https://discourse.libsdl.org/u/slouken)\
**Post date:** [October 19, 2000, 6:06pm UTC](https://discourse.libsdl.org/t/dx5-front-buffer-lost-surface/3344/3 "2000-10-19T18:06:26Z")

</div>

> Lordy I hate direct draw…

> In DX5\_WindowUpdate, there isn’t a check for lost surface. So if another  
> app gets exclusive mode, the screen goes black and stays that way until  
> resized.

Doh! Thank you very much for this fix, it’s now in CVS.

See ya!  
-Sam Lantinga, Lead Programmer, Loki Entertainment Software
