d3dx9_36 [patch 1/2, resent]: Implement D3DXCreatePolygon
matteo.mystral at gmail.com
Tue Nov 8 08:29:15 CST 2011
2011/11/7 David Adam <david.adam.cnrs at gmail.com>:
> any problem with this patch
> and this one
> Thanks in advance
> ---------- Forwarded message ----------
> From: David Adam <david.adam.cnrs at gmail.com>
> Date: 2011/10/30
> Subject: d3dx9_36 [patch 1/2, resent]: Implement D3DXCreatePolygon
> To: wine-patches <wine-patches at winehq.org>
> Fix a possible crash when calling D3DXCreateMeshFVF.
I see Rico preceded me (his points are very much valid too, and I'm
going to overlap a bit), but as I have already written a reply
I think your patches generally look somewhat ugly. Many of the
comments I gave in
another patch of yours apply here all the same.
About specific issues I have noticed here:
+ hr = D3DXCreateMeshFVF((DWORD)sides, (DWORD)(sides + 1),
D3DXMESH_MANAGED, D3DFVF_XYZ | D3DFVF_NORMAL, device, &polygon);
Why those casts?
+ vertice = HeapAlloc(GetProcessHeap(), 0, 2 * (sides + 1) *
+ memcpy(data, vertice, 2 * (sides + 1) * sizeof(D3DXVECTOR3));
What's the point in allocating and filling this additional array? You
should just write into the vertex buffer. Same with the index buffer.
those parentheses around polygon are useless.
+ hr = D3DXCreateBuffer(11 * sizeof(DWORD), &ppBuffer);
Why are you creating a D3DXBuffer here? It is probably created and
returned by D3DXCreatePolygon (and indeed your own implementation in
patch 1 does exactly that).
If you want to have the cleanup work even when the tests fail, you
have to protect the Release() calls somehow (e.g. initializing the
object pointers to NULL and checking for != NULL on release).
+ index = *( (WORD*)( data + ( 3 * i + j ) * sizeof(WORD) ) );
You could make that much simpler by introducing a WORD pointer.
Similarly for the vertex data.
I guess the objection about expecting a specific vertex/index ordering
is moot as it was in D3DXCreateBox case (i.e. there are applications
blindly modifying the mesh), right?
More information about the wine-devel