From 417534fdb7e955c8c6d670de3b3c4179ebc65a1d Mon Sep 17 00:00:00 2001 From: Dylan Smith Date: Wed, 27 Apr 2011 18:12:20 -0400 Subject: [PATCH] d3dx9: Implement ID3DXMesh::DrawSubset. --- dlls/d3dx9_36/mesh.c | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/dlls/d3dx9_36/mesh.c b/dlls/d3dx9_36/mesh.c index e67dffae156..201b2b349e9 100644 --- a/dlls/d3dx9_36/mesh.c +++ b/dlls/d3dx9_36/mesh.c @@ -113,10 +113,43 @@ static ULONG WINAPI ID3DXMeshImpl_Release(ID3DXMesh *iface) static HRESULT WINAPI ID3DXMeshImpl_DrawSubset(ID3DXMesh *iface, DWORD attrib_id) { ID3DXMeshImpl *This = impl_from_ID3DXMesh(iface); + HRESULT hr; + DWORD face_start; + DWORD face_end = 0; + DWORD vertex_size; - FIXME("(%p)->(%u): stub\n", This, attrib_id); + TRACE("(%p)->(%u)\n", This, attrib_id); - return E_NOTIMPL; + vertex_size = iface->lpVtbl->GetNumBytesPerVertex(iface); + + hr = IDirect3DDevice9_SetVertexDeclaration(This->device, This->vertex_declaration); + if (FAILED(hr)) return hr; + hr = IDirect3DDevice9_SetStreamSource(This->device, 0, This->vertex_buffer, 0, vertex_size); + if (FAILED(hr)) return hr; + hr = IDirect3DDevice9_SetIndices(This->device, This->index_buffer); + if (FAILED(hr)) return hr; + + while (face_end < This->numfaces) + { + for (face_start = face_end; face_start < This->numfaces; face_start++) + { + if (This->attrib_buffer[face_start] == attrib_id) + break; + } + if (face_start >= This->numfaces) + break; + for (face_end = face_start + 1; face_end < This->numfaces; face_end++) + { + if (This->attrib_buffer[face_end] != attrib_id) + break; + } + + hr = IDirect3DDevice9_DrawIndexedPrimitive(This->device, D3DPT_TRIANGLELIST, + 0, 0, This->numvertices, face_start * 3, face_end - face_start); + if (FAILED(hr)) return hr; + } + + return D3D_OK; } static DWORD WINAPI ID3DXMeshImpl_GetNumFaces(ID3DXMesh *iface)