Primitives appear black after Reset()

Started by
4 comments, last by Guimo 19 years, 2 months ago
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
==Colt "MainRoach" McAnlisGraphics Engineer - http://mainroach.blogspot.com
Advertisement
Maybe the texture resources are lost and need to be recreated?
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
==Colt "MainRoach" McAnlisGraphics Engineer - http://mainroach.blogspot.com
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.
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().
Co-creator of Star Bandits -- a graphical Science Fiction multiplayer online game, in the style of "Trade Wars'.
Also...check if your resources are created in the Managed pool.

Luck!
Guimo

This topic is closed to new replies.

Advertisement