Commit 871aa9d1 authored by Christian Costa's avatar Christian Costa Committed by Alexandre Julliard

d3drm: Check params in IDirect3DRMMeshBuilder2Impl_GetVertices + tests.

parent 1cd551cd
......@@ -801,14 +801,22 @@ static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GetVertices(IDirect3DRMMeshBui
TRACE("(%p)->(%p,%p,%p,%p,%p,%p)\n", This, vcount, vertices, ncount, normals, face_data_size, face_data);
if (vertices && (!vcount || (*vcount < This->nb_vertices)))
return D3DRMERR_BADVALUE;
if (vcount)
*vcount = This->nb_vertices;
if (vertices && This->nb_vertices)
memcpy(vertices, This->pVertices, This->nb_vertices * sizeof(D3DVECTOR));
if (normals && (!ncount || (*ncount < This->nb_normals)))
return D3DRMERR_BADVALUE;
if (ncount)
*ncount = This->nb_normals;
if (normals && This->nb_normals)
memcpy(normals, This->pNormals, This->nb_normals * sizeof(D3DVECTOR));
if (face_data && (!face_data_size || (*face_data_size < This->face_data_size)))
return D3DRMERR_BADVALUE;
if (face_data_size)
*face_data_size = This->face_data_size;
if (face_data && This->face_data_size)
......
......@@ -393,6 +393,24 @@ static void test_MeshBuilder(void)
val = IDirect3DRMMeshBuilder_GetFaceCount(pMeshBuilder);
ok(val == 1, "Wrong number of faces %d (must be 1)\n", val);
/* Check no buffer size and too small buffer size errors */
val1 = 1; val2 = 3; val3 = 8;
hr = IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder, &val1, v, &val2, n, &val3, f);
ok(hr == D3DRMERR_BADVALUE, "IDirect3DRMMeshBuilder_GetVertices returned %#x\n", hr);
hr = IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder, NULL, v, &val2, n, &val3, f);
ok(hr == D3DRMERR_BADVALUE, "IDirect3DRMMeshBuilder_GetVertices returned %#x\n", hr);
val1 = 3; val2 = 1; val3 = 8;
hr = IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder, &val1, v, &val2, n, &val3, f);
ok(hr == D3DRMERR_BADVALUE, "IDirect3DRMMeshBuilder_GetVertices returned %#x\n", hr);
hr = IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder, &val1, v, NULL, n, &val3, f);
ok(hr == D3DRMERR_BADVALUE, "IDirect3DRMMeshBuilder_GetVertices returned %#x\n", hr);
val1 = 3; val2 = 3; val3 = 1;
hr = IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder, &val1, v, &val2, n, &val3, f);
ok(hr == D3DRMERR_BADVALUE, "IDirect3DRMMeshBuilder_GetVertices returned %#x\n", hr);
hr = IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder, &val1, v, &val2, n, NULL, f);
ok(hr == D3DRMERR_BADVALUE, "IDirect3DRMMeshBuilder_GetVertices returned %#x\n", hr);
val1 = 3; val2 = 3; val3 = 8;
hr = IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder, &val1, v, &val2, n, &val3, f);
ok(hr == D3DRM_OK, "Cannot get vertices information (hr = %x)\n", hr);
ok(val1 == 3, "Wrong number of vertices %d (must be 3)\n", val1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment