Jump to content
  • Advertisement
Sign in to follow this  
macmoy

ALT-TAB CRaSH. HELP T_T

This topic is 2922 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

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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();



}

Share this post


Link to post
Share on other sites
Don't use real full screen becuase many things can go wrong.

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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);
}

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
Thanks a lot Flimflam and Dawoodoz for your time to help me :) That solved my problem :) Thanks again! :) :)

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!