• Advertisement
Sign in to follow this  

direct3d 9 Lost Device

This topic is 3002 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi! I have a fullscreen d3d9 application, with an image displayed on the screen. if I press alt-tab to switch to another window, and then I try to get back to my application, I receive D3DERR_INVALIDCALL error at Code: m_pDevice->Reset(&m_pres_params); but the problem is that I did not modify m_pres_params structure since the initialization of direct3d (when worked). And I didn't even switch to windowed mode. Can anybody tell me what the problem is and what I can do to solve it? my code: main loop: Code: int CGameApp::Run(void) { MSG msg = {0}; while (msg.message != WM_QUIT) { while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } if (FALSE == IsLostDevice()) { UpdateScene(); DrawScene(); } } return (int)msg.wParam; } here, the function IsLostDevice: Code: bool CGameApp::IsLostDevice(void) { HRESULT hr = m_pDevice->TestCooperativeLevel(); if (hr == D3DERR_DEVICELOST) { Sleep(20); return true; } if (hr == D3DERR_DRIVERINTERNALERROR) D3DErrorMessage(hr); if (hr == D3DERR_DEVICENOTRESET) { OnLostDevice();//here I call OnLost on the sprite HRESULT hr = m_pDevice->Reset(&m_pres_params); if (hr != D3D_OK) D3DErrorMessage(hr); OnResetDevice();//here I call OnReset on the sprite return false; } return false; } and here is how I initialized present parameters: Code: ZeroMemory(&m_pres_params, sizeof(m_pres_params)); m_pres_params.BackBufferWidth = m_nWidth;//that is, 800 m_pres_params.BackBufferHeight = m_nHeight;//that is, 600 m_pres_params.BackBufferFormat = D3DFMT_X8R8G8B8; m_pres_params.BackBufferCount = 1; m_pres_params.MultiSampleType = D3DMULTISAMPLE_NONE; m_pres_params.MultiSampleQuality = 0; m_pres_params.SwapEffect = D3DSWAPEFFECT_DISCARD; m_pres_params.hDeviceWindow = m_hWnd; m_pres_params.Windowed = bWindowed; m_pres_params.EnableAutoDepthStencil = true; m_pres_params.AutoDepthStencilFormat = D3DFMT_D24S8; m_pres_params.Flags = 0; m_pres_params.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT; can anybody please help me?

Share this post


Link to post
Share on other sites
Advertisement
Hi. Are you using D3DPOOL_DEFAULT or D3DPOOL_MANAGED?
If you're using DEFAULT check you released your image before resetting.

Also, is there any further infomation from the DX debug output? (do you have this enabled? Goto Control Panel > DirectX)

Share this post


Link to post
Share on other sites
Yes, I am using D3DPOOL_DEFAULT.

"check you released your image before resetting" - you mean I have to call m_pMySprite->Release() and m_pMyTexture->Release()? and then recreate them again?
There is a function of D3DXSPRITE, m_pMySprite->OnLostDevice() - should I call this instead of m_pMySprite->Release()?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement