   transparent primitives? (direct3d, need direct help)
  While trying to draw 2 squares in different places (a red one and a green one), I set up a rotation around the y axis and the usual tutorial code from the directx 8.0 sdk.  The problem is, the red square seems to always be visible to the front, even when the green one should cover it up.  Furthermore, upon closing the program, windows xp reports an error.  What am I doing wrong?The code:HRESULT direct3d::initD3D(HWND hWnd){D3DDISPLAYMODEd3ddm;D3DPRESENT_PARAMETERSd3dpp;if(NULL==(gpd3d=Direct3DCreate8(D3D_SDK_VERSION)))return E_FAIL;if(FAILED(gpd3d->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm)))return E_FAIL;ZeroMemory(&d3dpp, sizeof(d3dpp));d3dpp.Windowed=TRUE;d3dpp.SwapEffect=D3DSWAPEFFECT_DISCARD;d3dpp.BackBufferFormat=d3ddm.Format;if(FAILED(gpd3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,D3DCREATE_SOFTWARE_VERTEXPROCESSING,&d3dpp, &gpd3ddevice)))return E_FAIL;gpd3ddevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);gpd3ddevice->SetRenderState(D3DRS_LIGHTING, FALSE);return S_OK;}HRESULT direct3d::initGeometry(){vertices vert_array[]={{-1.0f, -1.0f, -1.0f, 0xff00ff00},{-1.0f, 1.0f, -1.0f, 0xff00ff00},{1.0f, 1.0f, -1.0f, 0xff00ff00},{1.0f, -1.0f, -1.0f, 0xff00ff00},{-1.0f, -1.0f, 1.0f, 0xffff0000},{-1.0f, 1.0f, 1.0f, 0xffff0000},{1.0f, 1.0f, 1.0f, 0xffff0000},{1.0f, -1.0f, 1.0f, 0xffff0000},};if(FAILED(gpd3ddevice->CreateVertexBuffer(4*sizeof(vertices), 0,vertex3d, D3DPOOL_DEFAULT, &gpvb)))return E_FAIL;VOID* pVertices;if(FAILED(gpvb->Lock(0, sizeof(vert_array), (BYTE**)&pVertices, 0)))return E_FAIL;memcpy(pVertices, vert_array, sizeof(vert_array));gpvb->Unlock();return S_OK;}VOID direct3d::initMatrices(){D3DXMATRIX matWorld;D3DXMatrixIdentity(&matWorld);D3DXMatrixRotationY(&matWorld, timeGetTime()/1000.0f);gpd3ddevice->SetTransform(D3DTS_WORLD, &matWorld);D3DXMATRIX matView;D3DXMatrixLookAtLH(&matView, &D3DXVECTOR3(0.0f, 0.0f, -10.0f),&D3DXVECTOR3(0.0f, 0.0f, 0.0f),&D3DXVECTOR3(0.0f, 1.0f, 0.0f));gpd3ddevice->SetTransform(D3DTS_VIEW, &matView);D3DXMATRIX matProj;D3DXMatrixPerspectiveFovLH(&matProj, D3DX_PI/4, 1.0f, 1.0f, 100.0f);gpd3ddevice->SetTransform(D3DTS_PROJECTION, &matProj);}VOID direct3d::cleanup(){if(gpd3ddevice != NULL)gpd3ddevice->Release();if(gpd3d != NULL)gpd3d->Release();if(gpvb != NULL)gpvb->Release();}VOID direct3d::render(){if(NULL==gpd3ddevice)return;gpd3ddevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(128,128,128), 1.0f, 0);gpd3ddevice->BeginScene();initMatrices();gpd3ddevice->SetStreamSource(0, gpvb, sizeof(vertices));gpd3ddevice->SetVertexShader(vertex3d);gpd3ddevice->DrawPrimitive(D3DPT_TRIANGLEFAN, 0, 2);gpd3ddevice->DrawPrimitive(D3DPT_TRIANGLEFAN, 4, 2);gpd3ddevice->EndScene();gpd3ddevice->Present(NULL, NULL, NULL, NULL);} 
  I''m guessing you don''t have a Z-Buffer enabled.What error does Windows give? ;  first problem is probably becuase you''re not enabling the autodepthstencilformat in the d3dpresent_parameters structure and sgiving it a format. Second problem is becuase you are releasing your vb after relleasing teh device. You have to release the interfaces in backwards order ie: gpd3d, gpd3ddevice then gp vb.Another potential problem would occur if you are calling direct3d::cleanup() more then once. After you the interfaces, set them to NULL.Unless you are using the function AddRef() manually.   :::: [ Triple Buffer ] ::::;  Windows gives no error when compiling and linking, which I find weird but okay I guess.  I don''t have the z-buffer enabled, so that could be it, and I don''t have AddRef().  I don''t call the cleanup function more than once, but I''ll remember to set the interface objects to null after releasing them. 