Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

adamxiii

Reset Device

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

I keep getting D3DERR_INVALIDCALL. Anyone know why this is happening?
//-----------------------------------------------------------------------------

// Name: CheckDeviceState

//-----------------------------------------------------------------------------

bool CheckDeviceState()
{
    HRESULT hResult;

    hResult = d3dDevice->TestCooperativeLevel();

    if(hResult == D3DERR_DEVICELOST) {
		return false;   
	}
    else if(hResult == D3DERR_DEVICENOTRESET) {
	    
		// Free all D3DPOOL_DEFAULT objects and fonts


		g_Font.Lost();
		mainCharacter.Lost();

		gameObjects.DeleteObject(CHARACTER, "Main" );
		
		// Reset Device


		ZeroMemory( &d3dpp, sizeof(d3dpp) );
		d3dpp.SwapEffect				= D3DSWAPEFFECT_DISCARD;
		d3dpp.BackBufferWidth			= XRESOLUTION;
		d3dpp.BackBufferHeight			= YRESOLUTION;
		d3dpp.EnableAutoDepthStencil	= TRUE;
		d3dpp.AutoDepthStencilFormat	= D3DFMT_D16;
		d3dpp.PresentationInterval		= D3DPRESENT_INTERVAL_IMMEDIATE;
		d3dpp.Windowed  = FALSE;
		d3dpp.BackBufferFormat = D3DFMT_A8R8G8B8;

		switch( d3dDevice->Reset(&d3dpp) ) 
		{
		case D3DERR_DRIVERINTERNALERROR:
			ERROR_MESSAGE( "Driver Internal Error" );
			break;
		case D3DERR_DEVICELOST:
			ERROR_MESSAGE( "Device Lost" );
			break;
		case D3DERR_INVALIDCALL:
			ERROR_MESSAGE( "Invalid Call" );
			break;
		case D3DERR_OUTOFVIDEOMEMORY:
			ERROR_MESSAGE( "Out Of Video Memory" );
			break;
		case E_OUTOFMEMORY:
			ERROR_MESSAGE( "Out Of Memory" );
			break;
		default:
			ERROR_MESSAGE( "Could not reset d3dDevice!" );
			break;
		}

		SetupMatrices();
	    InitDeviceState();

		g_Font.Reset();
	    mainCharacter.Reset();

		gameObjects.AddObject( mainCharacter );

		return true;
	}

	return true;
}

Share this post


Link to post
Share on other sites
Advertisement
Any number of things... Most likely you didn''t release and your resources. You must release all resources allocated with D3DPOOL_DEFAULT before you can reset the device, and then remake them when you are done. It''s a pain, I know . You can skip this problem by using D3DPOOL_MANAGED. The driver will keep a copy in system memory and load it to the card when it finds something wrong. It''s a little slower (little as in probably not noticable except on big projects) than D3DPOOL_DEFAULT but it might be worth it for the trouble you save.

Share this post


Link to post
Share on other sites
I tried commenting out all of the objects that I created except for the D3DPOOL_MANAGED ones and the program still crashes with a "Could not reset d3dDevice" error message once I alt-tab back into the program.

anyone else have any ideas?

Share this post


Link to post
Share on other sites
Sorry, I''m not exactly sure how it works. I do know that things created with DEFAULT will need to be recreated, but I''m not sure what you have to do with managed. I do know that you won''t need to recreate them. Have you checked the MSDN?

Share this post


Link to post
Share on other sites

  • 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!