不知道大家有没碰到过这样的问题,我在一个窗口中做direct 3d的图像渲染的时候,当我去改变显示分辨率,这个时候我那个窗口就看不见图像了,不过我估计那个图像还是在渲染,只是没显示而已,不知道是不是在初始化3d的时候是不是有什么特别的设置,以下是我初始化3d的代码,请高手帮忙看看:
HRESULT C3DTest::InitD3D()
{
// Create 3D object
if( NULL == ( m_pD3D = Direct3DCreate8( D3D_SDK_VERSION ) ) )
return E_FAIL; // Get display mode
D3DDISPLAYMODE d3ddm;
if( FAILED( m_pD3D->GetAdapterDisplayMode( D3DADAPTER_DEFAULT, &d3ddm ) ) )
return E_FAIL; D3DPRESENT_PARAMETERS d3dpp; 
ZeroMemory( &d3dpp, sizeof(d3dpp) );
d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = d3ddm.Format;
d3dpp.EnableAutoDepthStencil = TRUE;
d3dpp.AutoDepthStencilFormat = D3DFMT_D16;

//Create D3D device
if( FAILED( m_pD3D->CreateDevice( D3DADAPTER_DEFAULT, 
  D3DDEVTYPE_HAL, 
  m_hWnd,
  D3DCREATE_SOFTWARE_VERTEXPROCESSING,
  &d3dpp, 
  &m_pDevice ) ) )
{
return E_FAIL;
} m_pDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );
//Enable Z buffer
m_pDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
// Turn on D3D lighting
    m_pDevice->SetRenderState( D3DRS_LIGHTING, true ); return S_OK;
}

解决方案 »

  1.   

    http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/directx9_m_Summer_03/directx/direct3d/gettingstarted/devices/lostdevices.aspA Microsoft® Direct3D® device can be in either an operational state or a lost state. The operational state is the normal state of the device, in which the device runs and presents all rendering as expected. The device makes a transition to the lost state when an event, such as the loss of keyboard focus in a full-screen application, causes rendering to become impossible. The lost state is characterized by the silent failure of all rendering operations, which means that the rendering methods can return success codes even though the rendering operations fail. In this situation, the Device.DeviceLost event is triggered.