Skip to main content
gamedev.net
🔒 Locked

Lost Devices

Started by LoreKeeper Nov 19, 2003 at 7:30 PM 5 replies 950+ views
Original Post
LoreKeeper
LoreKeeper
I''ve been struggling for hours now and feel like I''m taking stupid-pills - for some reason my DirectX app has issues with regaining focus. When I ALT-TAB out-and-into my full-screen application then I simply do not get the opportunity to Reset the DirectX(9) device. I''ve tried all models I could think of to work this out. Finally I''ve even went for the "bare-bones" approach with the following code: ... hr := DX9Device.Present(nil, nil, 0, nil); if hr = D3DERR_DEVICELOST then begin while DX9Device.TestCooperativeLevel <> D3DERR_DEVICENOTRESET do sleep(100); DX9Device.Reset(present_parameters); end; ... No problems in windowed mode, but in fullscreen mode I end up with an infinite loop on the TestCooperativeLevel. The system simply isn''t willing to give me re-entry into the Device. The SDK makes everything sound simple - and in sample codes I''ve looked at there isn''t any difficulty; it just doesn''t want to work for me... Any ideas? (I maintain a IDirect3DSurface9 to the BackBuffer - but it shouldn''t affect the problem, ditto for a ID3DXFont I''m using - though I''ve commented out all fonting just to be safe. There aren''t vertexbuffers or textures around that could give me grief - the graphics are created with manual pixel-manipulation.) Help will be greatly appreciated...
PlayGGY
PlayGGY
Umm... try without the sleep part, just with looping.
And the rockets' red glare, the bombs bursting in air,gave proof through the fight that our flag was still there.Oh say, does that star-spangled banner yet waveover the land of the free and the home of the brave?
Fidelio66
Fidelio66
It will keep saying DEVICENOTRESET if there are still things allocated in D3DPOOL_DEFAULT. D3DPOOL_MANAGED do not need to be released.
The usual process is to catch that your application loses focus and call invalidate to reset all vertex/index buffers and textures, and to call restore to create/fill them again.

The sleep is neccesary, because when you lose the device it is probably the moment you alt-tab/ctrl-esc/windows key away and it will probably take some time before your app is alt-tabbed back again.
LoreKeeper
LoreKeeper
I agree with the gist of the replies, but it doesn''t solve the problem.

I have no buffers that need to be released. I have one Surface interface (to the backbuffer) that I release on loss of focus; however, the TestCooperative only ever returns DEVICELOST - I never have the chance to respond to DEVICENOTRESET.

I think I''ll start with a "blank" application (which should work) and slowly work my way up...
LoreKeeper
LoreKeeper
Fantastic - that actually helped, and worked out neatly in the end.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.