• Advertisement
Sign in to follow this  

Primitives appear black after Reset()

This topic is 4756 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'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
Advertisement
I get the same result without using a texture at all.
If i'm just displaying the quad, it's color goes from white, to black, after a reset


~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
Yup. It's most likely your lighting. Needs to be recreated.

Alternatively, if you just set the material once at the start, you may need to do it again after Reset().

Share this post


Link to post
Share on other sites
Also...check if your resources are created in the Managed pool.

Luck!
Guimo

Share this post


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

  • Advertisement