   will this work for init d3d
 /* Direct3D header */#include <d3d8.h>  /* Direct 3D interfaces */ LPDIRECT3D8   m_pD3D; LPDIRECT3DDEVICE8  m_pD3DDevice;/* Setup and shutdown Direct3D */ HRESULT SetupDirect3D (void); HRESULT KillDirect3D (void);SetupDirect3D (void){  /* Create the Direct3D object */ if (NULL == (m_pD3D = Direct3DCreate8 (D3D_SDK_VERSION) ) ) {  return E_FAIL; }   /* Get the current display mode so we can know what bitdepth we are */ D3DDISPLAYMODE d3ddm; if (FAILED (m_pD3D->GetAdapterDisplayMode (D3DADAPTER_DEFAULT,&d3ddm) ) ) {  return E_FAIL; }   /* Fill in the present paramenters */ D3DPRESENT_PARAMETERS d3dpp;  ZeroMemory( &d3dpp, sizeof(d3dpp) );  /* We want windowed mode */ d3dpp.Windowed   = TRUE;  /* Discard this */ d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;  /* Same format as the current format (we got this from g_pD3D->GetAdapterDisplayMode)  */ d3dpp.BackBufferFormat = d3ddm.Format;   /* Create the device */ if (FAILED (m_pD3D->CreateDevice (D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,m_hWindow, D3DCREATE_SOFTWARE_VERTEXPROCESSING,&d3dpp, &m_pD3DDevice ) ) ) {  return E_FAIL; } return D3D_OK;} /* Shutdowns Direct3D */KillDirect3D (void){   /* If any of the Direct3D objects exist, release them */ if ( NULL != m_pD3D) {  m_pD3D->Release (); } if ( NULL != m_pD3DDevice) {  m_pD3DDevice->Release (); } return D3D_OK;} /* Clears the screen to blue */D3DWindow (void){  /* Clear the window to blue */ m_pD3DDevice->Clear (0, NULL, D3DCLEAR_TARGET,   D3DCOLOR_XRGB (0,0,255), 1.0f, 0);  /* Start rendering */ m_pD3DDevice->BeginScene(); m_pD3DDevice->EndScene();  /* Present the rendered scene to the screen */ m_pD3DDevice->Present (NULL, NULL, NULL, NULL); return 1;} then your windows and game loop
  You should probably reverse the order in which the Direct3D Device (m_pD3DDevice) and Direct3 object (m_pD3D) are released. HRESULT KillDirect3D(void){    if (m_pD3DDevice != NULL)    {   m_pD3DDevice->Release();   m_pD3DDevice = NULL;    }    if (m_pD3D != NULL)    {   m_pD3D->Release();   m_pD3D = NULL;    }}Assuming you are providing a valid window handle to CreateDevice() what you have there should work.Edit: Sorry I should probably explain my reasoning above. If you try to release the Direct3D Object first it probably won't work since the object still contains references to other objects. If it does work, then you might end up with a program crash or memory leaks when the Direct3D Device get orphaned (And consequently anything attached to it).Anyone correct me if necessary, I'm not yet an expert in Direct3D.   [edited by - Reaptide on February 16, 2004 4:21:26 AM]