In order to improve myself, I work on ready-made resources. However, I am currently faced with a problem that has been bothering me for days. When I first open the game, everything works fine, but when the Windows User Control (UAC) screen comes up through any program, the background visuals in my game are distorted. I am very novice in these matters, I would be very happy if you could help me in a way that I can understand. Thank you very much
Original:
After UAC:
First code:
if (FAILED(hr = ms_lpd3dDevice->TestCooperativeLevel()))
{
if (D3DERR_DEVICELOST == hr)
return DEVICESTATE_BROKEN;
if (D3DERR_DEVICENOTRESET == hr)
return DEVICESTATE_NEEDS_RESET;
return DEVICESTATE_BROKEN;
}
Then this place is triggered:
case CGraphicDevice::DEVICESTATE_NEEDS_RESET:
m_pyBackground.ReleaseCharacterShadowTexture();
CRenderTargetManager::Instance().ReleaseRenderTargetTextures();
Trace("DEVICESTATE_NEEDS_RESET - attempting");
if (!m_grpDevice.Reset())
{
return DEVICE_STATE_SKIP;
}
CRenderTargetManager::Instance().CreateRenderTargetTextures();
m_pyBackground.CreateCharacterShadowTexture();
break;
Based on the screenshots, it seems after the lost device and desktop switch, Windows resets sampler state you use to load from your low-resolution texture from linear to the default which is D3DTEXF_POINT
.
You should restore the state by calling IDirect3DDevice9.SetSamplerState
method the same way you do on startup of your app.
P.S. Direct3D 11 is much better than 9 in that regard, most of the times it manages these states automagically.