ALT-TAB CRaSH. HELP T_T

Started by
7 comments, last by Flimflam 13 years, 6 months ago
Guys.. I have this game made using C++ and DirectX 9. It crashes if I set the game in fullscreen. The moment i press the "alt-tab" = BOOM! another thing is it doesn't crash everytime i do this.

please help.. T_T
Advertisement
I'm kind of confused. Are you saying that you're playing someone else's game and it's crashing on alt-tab? If so, then you need to speak with the author of the game, not us. We're a game development forum, we discuss game development; we're not a troubleshooting forum for games.

If I've mistaken the situation, then it sounds like the device isn't being reset properly after it's lost. It sounds like the device is being lost mid-frame and is probably failing when Present is called (as you've mentioned it's sporadic. There is probably a catch to see if the device is lost, but it isn't being checked in both instances it aught to be). There needs to be two checks for a valid device: When the frame begins, and when Present is called.
Wow! i think you got it! though i haven't tried yet. yes, im the developer of the game. and YES! the crash points at my EndRender() function. so what will i do? here my code as of now.

HRESULT hr = g_Device.getD3dDevice()->TestCooperativeLevel();			if( FAILED( hr ) )			{				if(hr==D3DERR_DEVICENOTRESET)				{					g_Device.getD3dSprite()->OnLostDevice();					g_Device.getD3dDevice()->Reset( (D3DPRESENT_PARAMETERS*)g_Device.getD3dPp() );					g_Device.getD3dSprite()->OnResetDevice();				}			}			// -- Input, Update, Render			g_Input.processDirectInput();			g_Game->update();			g_Device.beginRender();							g_Game->render(); // 3d							g_Device.beginSprite();								g_Game->draw(); // 2d							g_Device.endRender();											}
Don't use real full screen becuase many things can go wrong.

Do this instead:
http://www.codeguru.com/forum/showthread.php?t=500867
Quote:Original post by Dawoodoz
Don't use real full screen becuase many things can go wrong.

Do this instead:
http://www.codeguru.com/forum/showthread.php?t=500867


That's not necessarily true. As long as you properly handle lost devices, I can't think of any reasons why you shouldn't use fullscreen.

Edit: Whoops, major brainfart. If you tried what this post suggested before I edited it, do this instead:

Macmoy, do a TestCooperativeLevel call right before you call IDirect3DDevice9::Present() inside your device.endRender() function and if the test fails, just skip the Present call altogether. The frame will be discarded and the device will be restored once the next frame begins.
        void Device::endRender()	{		HRESULT hr = g_Device.getD3dDevice()->TestCooperativeLevel();		if( FAILED( hr ) )		{	             // what should i put here?                     // return;?                     // or do i still need to put an if statement here, if yes,                     // what condition?				}		m_D3dSprite->End();		m_D3dDevice->EndScene();		m_D3dDevice->Present(0, 0, 0, 0);	}
        void Device::endRender()	{            m_D3dSprite->End();            m_D3dDevice->EndScene();            HRESULT hr = m_D3dDevice->TestCooperativeLevel();            if( FAILED( hr ) )            {                return;            }                            m_D3dDevice->Present(0, 0, 0, 0);	}


Sorry, I brainfarted when I made my last post, and corrected it too late. :(

The above is what you want to do.
Thanks a lot Flimflam and Dawoodoz for your time to help me :) That solved my problem :) Thanks again! :) :)
You are quite welcome. Happy coding. :)

This topic is closed to new replies.

Advertisement