Original Post
I am working with directx8 and vb6. This is a continuation of the Hidden face removal problem. I am trying to draw 2 triangles one inside the other in wireframe mode. The inner triangle also has a z value so that it is at the back of the bigger triangle. I am trying to enable the z buffer and I want only the outer bigger triangle to be drawn. The main functions are as follows. 1. The Direct3d start up function Public Function Startup(ByVal hWnd As Long, ByVal lWidth As Long, _ ByVal lHeight As Long) As Boolean On Local Error GoTo startup_error Startup = False 'Create the d3d object Set m_d3d = m_dx.Direct3DCreate() If m_d3d Is Nothing Then Exit Function End If 'Get the current display mode m_d3d.GetAdapterDisplayMode D3DADAPTER_DEFAULT, m_mode 'Fill in the structre used to create the device m_d3dpp.Windowed = 1 m_d3dpp.SwapEffect = D3DSWAPEFFECT_COPY_VSYNC m_d3dpp.BackBufferFormat = m_mode.Format m_d3dpp.BackBufferCount = 1 m_d3dpp.EnableAutoDepthStencil = 1 m_d3dpp.AutoDepthStencilFormat = D3DFMT_D16 'In order of preference: 32, 24, 16 If m_d3d.CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, m_mode.Format, _ D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, D3DFMT_D32) = D3D_OK Then '//Enable a pure 32bit Depth buffer m_d3dpp.AutoDepthStencilFormat = D3DFMT_D32 m_d3dpp.EnableAutoDepthStencil = 1 Debug.Print "32 bit Depth buffer selected" Else '//search for a 24 bit depth buffer ' If m_d3d.CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, m_mode.Format, _ ' D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, D3DFMT_D24X8) = D3D_OK Then '//Enable a 24 bit depth buffer ' m_d3dpp.AutoDepthStencilFormat = D3DFMT_D24X8 ' m_d3dpp.EnableAutoDepthStencil = 1 ' Debug.Print "24 bit Depth buffer selected" ' Else If m_d3d.CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, m_mode.Format, _ D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, D3DFMT_D16) = D3D_OK Then '//Enable a 16 bit depth buffer m_d3dpp.AutoDepthStencilFormat = D3DFMT_D16 m_d3dpp.EnableAutoDepthStencil = 1 Debug.Print "16 bit Depth buffer selected" Else '//hmm. No depth buffers available... Dont use one then :) m_d3dpp.EnableAutoDepthStencil = 0 Debug.Print "no Depth buffer selected" End If ' End If End If 'Create the d3ddevice with hardware 3d support Set m_d3dDevice = m_d3d.CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, _ hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, m_d3dpp) If m_d3dDevice Is Nothing Then Exit Function 'Set the vertex shader m_d3dDevice.SetVertexShader D3DFVF_VERTEX m_d3dDevice.SetRenderState D3DRS_ZENABLE, 1 m_d3dDevice.SetRenderState D3DRS_ZWRITEENABLE, 1 m_d3dDevice.SetRenderState D3DRS_ZFUNC, D3DCMP_LESSEQUAL 'Turn on ambient lighting m_d3dDevice.SetRenderState D3DRS_AMBIENT, True 'Turn off hardware lighting m_d3dDevice.SetRenderState D3DRS_LIGHTING, False 'Turn on counter-clockwise backface removal m_d3dDevice.SetRenderState D3DRS_CULLMODE, D3DCULL_NONE m_d3dDevice.SetRenderState D3DRS_FILLMODE, D3DFILL_WIREFRAME 'Retrieve device capabilities Device.GetDeviceCaps m_caps Startup = True Exit Function startup_error: Startup = False End Function 2. The rendering function Public Sub RenderScene() 'Clear the buffer m_d3d.Device.Clear 0, ByVal 0, D3DCLEAR_TARGET Or D3DCLEAR_ZBUFFER, lColor, 1, 0 'Start the rendering m_d3d.BeginScene 'Draw the triangle m_triangle(0).Draw m_triangle(1).Draw 'Stop the rendering m_d3d.EndScene m_d3d.Present End Sub I am still getting both the triangles drawn one within the other. Am i doing something wrong? Any suggestions? PS: Nik02 - I am trying to do what you have suggested in the other thread.