From c6015d4c1c34f6a2495153b21e4e72917ec2322a Mon Sep 17 00:00:00 2001 From: spacy51 Date: Sat, 1 Dec 2007 14:41:48 +0000 Subject: [PATCH] fixed no image after multi-tasking from full screen --- trunk/src/win32/Direct3D.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/trunk/src/win32/Direct3D.cpp b/trunk/src/win32/Direct3D.cpp index 2127787c..2bc04a40 100644 --- a/trunk/src/win32/Direct3D.cpp +++ b/trunk/src/win32/Direct3D.cpp @@ -447,14 +447,30 @@ void Direct3DDisplay::render() { if( failed ) return; if(!pDevice) return; - if( FAILED( pDevice->TestCooperativeLevel() ) ) return; + + // Multi-Tasking fix + HRESULT hr = pDevice->TestCooperativeLevel(); + if( FAILED( hr ) ) { + switch( hr ) { + case D3DERR_DEVICELOST: + // The device has been lost but cannot be reset at this time. + // Therefore, rendering is not possible. + return; + case D3DERR_DEVICENOTRESET: + // The device has been lost but can be reset at this time. + resetDevice(); + return; + default: + DXTRACE_ERR( _T("ERROR: D3D device has serious problems"), hr ); + return; + } + } clear(); pDevice->BeginScene(); // copy pix to emulatedImage and apply pixel filter if selected - HRESULT hr; D3DLOCKED_RECT lr; if( FAILED( hr = emulatedImage->LockRect( 0, &lr, NULL, D3DLOCK_DISCARD ) ) ) {