I posted earlier with regards to my program and its problem with resetting the device. I am unsure of where to reset the device if it is lost... I wrote my render function like this:
bool cVideo::RenderFrame()
{
m_device->Clear(0, NULL, D3DCLEAR_TARGET, SYS_ColorBlack, 1.0f, 0);
if(SUCCEEDED(m_device->BeginScene()))
{
// Render stuff...
ExecuteCallback(CALLBACK_RENDER);
m_device->EndScene();
}
HRESULT result;
if(FAILED(result = m_device->Present(NULL, NULL, NULL, NULL)))
{
if(result == D3DERR_DEVICELOST)
{
if(SUCCEEDED(m_device->Reset(&m_present)))
ExecuteCallback(CALLBACK_RESET); // Reload all pooled resources
}
}
return true;
}
However the device fails to reset because of an invalid parameter. How does everyone else normally do it? Do you check when the program regains focus to reset like this:
case WM_ACTIVATE:
if(LOWORD(wParam) == WA_ACTIVE)
Windows::Instance().SetFocus(true);
else if(LOWORD(wParam) == WA_INACTIVE)
Windows::Instance().SetFocus(false);
Or do you let the render function handle it for you as in the example above? Which is more "correct"?