|
发表于 2004-5-26 16:15:00
|
显示全部楼层
Re:如何寻回丢失了的纹理?
给一段《real-time render in directx》的恢复代码给你看,希望对你有用
HRESULT CHostApplication::RestoreDevice()
{
HRESULT Result = m_pD3DDevice->TestCooperativeLevel();
//If the device is lost, enter a loop waiting for
//it to be restored.
while(Result == D3DERR_DEVICELOST)
{
//Keep testing the level until it says we
//can reset.
while(Result != D3DERR_DEVICENOTRESET)
{
//Give up control to other applications
Sleep(1000);
//Pump messages in order to respond to messages
//that may lead to restoration.
MSG Message;
PeekMessage(&Message, 0, 0, 0, PM_REMOVE);
TranslateMessage(&Message);
DispatchMessage(&Message);
//Check to see if things are ready to be reset
Result = m_pD3DDevice->TestCooperativeLevel();
}
//Reset the device using the saved parameters
if (FAILED(m_pD3DDevice->Reset(&m_PresentParameters)))
Result = D3DERR_DEVICELOST;
}
return S_OK;
} |
|