D3DPRESENT_PARAMETERS presentParams;
memset(&presentParams,0,sizeof(presentParams));
presentParams.BackBufferCount = 1;
presentParams.SwapEffect = D3DSWAPEFFECT_DISCARD;
presentParams.hDeviceWindow = hwndMyApp;
presentParams.Windowed = FALSE;
presentParams.BackBufferWidth = 1024;
presentParams.BackBufferHeight = 768;
presentParams.BackBufferFormat = D3DFMT_X8R8G8B8;
presentParams.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
presentParams.BackBufferFormat = D3DFMT_X8R8G8B8;
// This is what is intersting…
presentParams.EnableAutoDepthStencil = TRUE;
presentParams.AutoDepthStencilFormat = D3DFMT_D16; // or D3DFMT_D24S8