From b2dac1df27a773ab4d63f92aa3248b97e1e56076 Mon Sep 17 00:00:00 2001 From: Dylan Smith Date: Wed, 27 Apr 2011 18:11:58 -0400 Subject: [PATCH] d3dx9: Implement GetNumBytesPerVertex using the vertex declaration. If a declaration without a corresponding FVF is used to create the mesh, then its declaration must be used to get the vertex size. --- dlls/d3dx9_36/mesh.c | 7 ++++++- dlls/d3dx9_36/tests/mesh.c | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/dlls/d3dx9_36/mesh.c b/dlls/d3dx9_36/mesh.c index 432db1d5012..404f447a35f 100644 --- a/dlls/d3dx9_36/mesh.c +++ b/dlls/d3dx9_36/mesh.c @@ -157,10 +157,15 @@ static HRESULT WINAPI ID3DXMeshImpl_GetDeclaration(ID3DXMesh *iface, D3DVERTEXEL static DWORD WINAPI ID3DXMeshImpl_GetNumBytesPerVertex(ID3DXMesh *iface) { ID3DXMeshImpl *This = impl_from_ID3DXMesh(iface); + UINT numelements; + D3DVERTEXELEMENT9 declaration[MAX_FVF_DECL_SIZE] = { D3DDECL_END() }; TRACE("iface (%p)\n", This); - return D3DXGetFVFVertexSize(This->fvf); + IDirect3DVertexDeclaration9_GetDeclaration(This->vertex_declaration, + declaration, + &numelements); + return D3DXGetDeclVertexSize(declaration, 0); } static DWORD WINAPI ID3DXMeshImpl_GetOptions(ID3DXMesh *iface) diff --git a/dlls/d3dx9_36/tests/mesh.c b/dlls/d3dx9_36/tests/mesh.c index 88ac59cc978..bde859512d2 100644 --- a/dlls/d3dx9_36/tests/mesh.c +++ b/dlls/d3dx9_36/tests/mesh.c @@ -1216,6 +1216,9 @@ static void D3DXCreateMeshTest(void) free_mesh(&mesh); } + mesh.vertex_size = d3dxmesh->lpVtbl->GetNumBytesPerVertex(d3dxmesh); + ok(mesh.vertex_size == 60, "Got vertex size %u, expected %u\n", mesh.vertex_size, 60); + d3dxmesh->lpVtbl->Release(d3dxmesh); } -- 2.11.4.GIT