Sign in to follow this  
duhroach

Primitives appear black after Reset()

Recommended Posts

I've recently added lost device recovery to my system. During a device loss, i release all the objects, call Reset(params) and reinitalize all my objects. A white primitive, w/o any texture applied to it, shows up black after a reset If a texture is applied, the texture dissapers, and just the black quad renders Also, after this reset, Any data loaded (ie if i wait until after the reset to load the texture) has the same characteristics as if it were loaded before the reset. I'm wondering if this has anything to do with releasing and regaining my back buffer before and after a reset? my reset
if(!_Dx9Device)
		return E_FAIL;

	if(_backBuffer)
	{
		_backBuffer->Release();
		_backBuffer=NULL;
	}
	if(_depthBuffer)
	{
		_depthBuffer->Release();
		_depthBuffer=NULL;
	}

	HRESULT hr=_Dx9Device->Reset(&_Dx9params);
	switch (hr)
	{
	case D3DERR_DEVICELOST:				return E_FAIL;break;
	case D3DERR_DRIVERINTERNALERROR:	return E_FAIL;break;
	case D3DERR_INVALIDCALL:			return E_FAIL;break;
	case D3DERR_OUTOFVIDEOMEMORY:		return E_FAIL;break;
	case E_OUTOFMEMORY:					return E_FAIL;break;

	}

	if (hr = FAILED(_Dx9Device->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &_backBuffer)))
		return SX_FAIL;

	if (hr = FAILED(_Dx9Device->GetDepthStencilSurface(&_depthBuffer)))
		return SX_FAIL;

	return hr;
}

~Main

Share this post


Link to post
Share on other sites
On Reset, all renderstates and settings are lost. Your init code probably turns lighting off, sets up a projection matrix, etc. All this should be done again. I suspect lighting is what's making everything black.

Move all your initialization code to a seperate function, and call it both at init time and after a reset.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this