; GraphicsLost Example
; --------------------

Graphics 640,480,0,2
SetBuffer BackBuffer()

; A bouncing pickup, so you can see the program is still running
x#=320
y#=240
dx#=2.4
dy#=1.7

frames=0
lost_frames=0

While Not KeyDown(1)

    Cls

    frames=frames+1

    ; The classic Blitz3D guard: if the display surfaces have been
    ; taken away, sit still instead of animating into nothing
    If GraphicsLost() Then
        lost_frames=lost_frames+1
        Delay 100
    Else
        x=x+dx
        y=y+dy
        If x<12 Or x>628 Then dx=-dx
        If y<12 Or y>468 Then dy=-dy
    End If

    Color 80,180,255
    Oval x-12,y-12,24,24,1
    Color 255,255,255

    Text 0,0,"Alt-tab away and back, or minimise the window   Esc: exit"
    Text 0,20,"GraphicsLost() = "+GraphicsLost()
    Text 0,40,"Frames "+frames+"   frames skipped as lost "+lost_frames

    Text 0,420,"On the DirectX 12 backend GraphicsLost always answers 0 - the"
    Text 0,440,"device is never lost, so the guard above never fires and the"
    Text 0,460,"skipped count stays at zero however much you alt-tab."

    Flip

Wend

End
