Direct3D won't reset

This is a discussion on Direct3D won't reset within the Game Programming forums, part of the General Programming Boards category; I'm having some troubles when alt-tabbing out then back into my game. The Direct3DDevice->Reset() method fails, returning an "invalid parameter" ...

  1. #1
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145

    Direct3D won't reset

    I'm having some troubles when alt-tabbing out then back into my game. The Direct3DDevice->Reset() method fails, returning an "invalid parameter" error message. I have no idea what this could be. The device creation goes fine with the parameters, but when I use the same for the reset it fails (I've double chekced, they aren't modified somewhere else along the way). All buffers I use are managed.

    Any idea?

    These are the parameters I set up Direct3D with:
    Code:
    DeviceInfo.BackBufferWidth = Width;
    DeviceInfo.BackBufferHeight = Height;
    DeviceInfo.BackBufferFormat = D3DFMT_A8R8G8B8;
    DeviceInfo.BackBufferCount = 1;
    DeviceInfo.MultiSampleType = D3DMULTISAMPLE_NONE;
    DeviceInfo.MultiSampleQuality = 0;
    DeviceInfo.SwapEffect = D3DSWAPEFFECT_DISCARD;
    DeviceInfo.hDeviceWindow = Window;
    DeviceInfo.Windowed = FALSE;
    DeviceInfo.EnableAutoDepthStencil = TRUE;
    DeviceInfo.AutoDepthStencilFormat = D3DFMT_D16;
    DeviceInfo.Flags = 0;
    DeviceInfo.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
    DeviceInfo.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;
    This is the function I call before every rendering session:
    Code:
    BOOL GRAPHICS::BeginRender()
    {
    	HRESULT Result;
    
    	//Clears the debug information
    	BlocksRendered = 0;
    	SidesRendered = 0;
    
    	//Checks if the program lost focus
    	Result = Direct3DDevice->TestCooperativeLevel();
    	if(Result != D3D_OK)
    	{
    		//If you cannot simply reset, wait until you can
    		if(Result == D3DERR_DEVICELOST)
    		{
    			return FALSE;
    		}
    
    		//Resets the device
    		if(FAILED(Direct3DDevice->Reset(&DeviceInfo)))
    		{
    			return FALSE;
    		}
    
    		//Re-sets the render states
    		SetupRenderStates();
    	}
    
    	//Clears the back buffer and Z-buffer
    	if(FAILED(Direct3DDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
    									BackgroundColor, 1.0, 0)))
    	{
    		return FALSE;
    	}
    
    	//Begins rendering
    	if(FAILED(Direct3DDevice->BeginScene()))
    	{
    		return FALSE;
    	}
    
    	return TRUE;
    }
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    No one knows? :/
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Why use Direct3D?
    By m3rk in forum Tech Board
    Replies: 42
    Last Post: 05-22-2009, 09:08 AM
  2. Need help with getting DirectX 9.0 initilization
    By DarkMortar in forum Windows Programming
    Replies: 7
    Last Post: 05-09-2006, 08:58 PM
  3. Problem with Direct3D
    By frenchfry164 in forum Tech Board
    Replies: 1
    Last Post: 11-27-2003, 03:28 PM
  4. DIRECTDRAW DIRECT3d
    By samsam1 in forum Game Programming
    Replies: 3
    Last Post: 01-14-2003, 06:28 PM
  5. Direct3D vs. OpenGL
    By PorkyChop in forum Game Programming
    Replies: 22
    Last Post: 12-07-2002, 11:41 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21