Texture's wont display when switching windowed-fullscreen.

Started by
4 comments, last by ph33r 19 years, 7 months ago
For some reason I can't get textures to display correctly when going from fullscreen to windowed and vice-versa. Every other managed resource gets re-created properly, like my vb and ib. Here is my code for loading the texture.
[SOURCE]
D3DXCreateTextureFromFileEx( 
g_pDevice, fileName, 
0, 0, 0, 0, 
D3DFMT_A8R8G8B8,
D3DPOOL_MANAGED, 
D3DX_FILTER_POINT, 
D3DX_DEFAULT, 
d3d::MAGENTA, 
NULL, NULL, &temp.m_tex );

Here is my code thats called when i reset the texture

	hr = g_pDevice->SetRenderState( D3DRS_ALPHATESTENABLE, TRUE );
	if( FAILED( hr ) )
	{
		::MessageBox( 0, "No support for renderstate ALPHATESTENABLE", 0, 0 );
		return false;
	}
	
	g_pDevice->SetRenderState( D3DRS_ALPHAREF, d3d::MAGENTA );
	g_pDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
	g_pDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
	g_pDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_POINT);
	g_pDevice->SetRenderState( D3DRS_ALPHAFUNC, D3DCMP_EQUAL );


Also, I even try calling SetTexture( ), and passing it the currently active texture. But the model just displays white after a switch from full->windowed. Thanks, -ph33r
Advertisement
bump, can anyone give me any hints on where to look?
When the device is reset, all device state is reset - you need to set your render states and texture/sampler stage states again.

I've got one code path for all my renderstates so im reseting them. What else could the problem be?

Here's the code path I do for reseting
	//	// Reset the device first.	//	if( FAILED( g_pDevice->Reset( &d3d::g_d3dpp ) ) )		return false;		//	// Reset manager classes(resources).	//	if( !g_vbManager.Reset( ) ) return false;	if( !g_ibManager.Reset( ) ) return false;	if( !g_TextureManager.Reset( ) ) return false;		// VB/IB	if( !g_vbManager.SetActiveVertexBuffer( 0 ) ) return false;	if( !g_ibManager.SetIndices( ) ) return false;	//	// Reset states.	//	if( !d3d::InitializeView( ) ) return false;	if( !InitializeRenderStates( ) ) return false;	//////////////////////////////////////////////////////////////////////////	//						Reset App Specifics here	//////////////////////////////////////////////////////////////////////////		if( !g_meshOne.Reset( ) ) return false;	if( !g_meshOne.SetMeshTexture( ) ) return false;	//////////////////////////////////////////////////////////////////////////	//						END	//////////////////////////////////////////////////////////////////////////	// Success!	return true;}


All my render states that are called, are being called in that intial render states function, so i dont understand how i could miss anything.
I'm not sure what your rendering loop looks like but is your call to Reset on the device returning success and are you doing a Clear/Present before the next update?

I *just* went through getting windowed <-> fullscreen working myself (a real pain). When it failed though I didn't get anything to display at all.
Yes, Reset is not failing, and I'm clearing the screen and doing a present.

My vertex/index buffer get reset properly because my mesh is still displayed its just my texture doesn't get reset properly. All I get is my mesh in plane white :(

This topic is closed to new replies.

Advertisement