Skip to main content
gamedev.net
🔒 Locked

Reset Device

Started by adamxiii Aug 12, 2003 at 5:54 PM 5 replies 950+ views
Original Post
adamxiii
adamxiii
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;
}
RenderTarget
RenderTarget
You''re not defining FullScreen_RefreshRateInHz. For fullscreen, it needs to be a valid refresh rate, as per the docs.

I like pie.
[sub]My spoon is too big.[/sub]
adamxiii
adamxiii
That might have helped. Now im getting the default error message though. Any reasons why that could happen?
Raloth
Raloth
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.
____________________________________________________________AAAAA: American Association Against Adobe AcrobatYou know you hate PDFs...
adamxiii
adamxiii
Thanks Raloth, I''ll comment out all the D3DPOLL_DEFAULT objects to see if maybe that is the problem.
adamxiii
adamxiii
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?
Raloth
Raloth
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?
____________________________________________________________AAAAA: American Association Against Adobe AcrobatYou know you hate PDFs...

Topic Locked

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

Sign in to reply to this topic.