Direct3D Lost Device

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

Recommended Posts

Hello, I am trying to test to see if the Direct3D 9 device has been lost and if so, reset it. I ran my fullscreen program and alt tabbed out, then alt tabbed back in, but my device wasn't being reset. The problem was that my calls to IDirect3DDevice9::TestCooperativeLevel() were constantly returning D3DERR_DEVICELOST even though I had freed all my D3DPOOL_DEFAULT resources, so I ran it through the DirectX debugger and got this:
Direct3D9: (WARN) :Window does not have focus. TestCooperativeLevel fails
Does anyone know how to fix this? I would guess that means I need to capture the WM_ACTIVE message in my window-message-checking loop and do something with that, but I don't know what exactly to do. Please help!

Share on other sites
Tbh, I can never remember the exact code as I don't have to write it very often. You need to IDirect3DDevice9::Reset() your device and then re-create all your resources.

Your best reference for this is the DXSDK sample framework, it's pretty much the text-book way to handle any/every state.

hth
Jack

Share on other sites
Quote:
 Original post by jollyjeffersTbh, I can never remember the exact code as I don't have to write it very often. You need to IDirect3DDevice9::Reset() your device and then re-create all your resources.Your best reference for this is the DXSDK sample framework, it's pretty much the text-book way to handle any/every state.hthJack

Well, I can't Reset() yet because TestCooperativeLevel() is failing because my "window does not have focus", which means I cannot know when it's safe to Reset()! I'll see if sample framework turns up anything though.

EDIT: Ack, I can't find anything. I'm not very good at reading other peoples' code. [sad]

Share on other sites
Quote:
 Original post by TalibHi, had a similar problem a while back ... too long ago for me to remember, but here's my post, hope it helps:http://www.gamedev.net/community/forums/topic.asp?topic_id=289633

Yup, same exact problem here. I actually just figured it out a minute ago! I forgot to call my window's HandleMessages() so it couldn't refocus on the window. A cookie for you anyway [smile].

• What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 14
• 14
• 45
• 22
• 27
• Forum Statistics

• Total Topics
634044
• Total Posts
3015211
×