d3drm: Improve IDirect3DRMMeshBuilderImpl_Load and corresponding test.
This commit is contained in:
parent
aafcf1a536
commit
edd9e8cc5b
|
@ -39,8 +39,15 @@ typedef struct {
|
|||
LONG ref;
|
||||
} IDirect3DRMMeshBuilderImpl;
|
||||
|
||||
typedef struct {
|
||||
WORD major;
|
||||
WORD minor;
|
||||
DWORD flags;
|
||||
} Header;
|
||||
|
||||
static const struct IDirect3DRMMeshBuilderVtbl Direct3DRMMeshBuilder_Vtbl;
|
||||
|
||||
static const GUID GUID_Header = { 0x3D82AB43, 0x62DA, 0x11CF, { 0xAB, 0x39, 0x00, 0x20, 0xAF, 0x71, 0xE4, 0x33 } };
|
||||
static const GUID GUID_Mesh = { 0x3D82AB44, 0x62DA, 0x11CF, { 0xAB, 0x39, 0x00, 0x20, 0xAF, 0x71, 0xE4, 0x33 } };
|
||||
|
||||
static char templates[] = {
|
||||
|
@ -408,6 +415,8 @@ static HRESULT WINAPI IDirect3DRMMeshBuilderImpl_Load(IDirect3DRMMeshBuilder* if
|
|||
LPDIRECTXFILEENUMOBJECT pEnumObject = NULL;
|
||||
LPDIRECTXFILEDATA pData = NULL;
|
||||
const GUID* pGuid;
|
||||
DWORD size;
|
||||
Header* pHeader;
|
||||
HRESULT hr;
|
||||
HRESULT ret = D3DRMERR_BADOBJECT;
|
||||
|
||||
|
@ -431,7 +440,7 @@ static HRESULT WINAPI IDirect3DRMMeshBuilderImpl_Load(IDirect3DRMMeshBuilder* if
|
|||
if (hr != DXFILE_OK)
|
||||
goto end;
|
||||
|
||||
hr = IDirectXFile_RegisterTemplates(pDXFile, templates, sizeof(templates));
|
||||
hr = IDirectXFile_RegisterTemplates(pDXFile, templates, strlen(templates));
|
||||
if (hr != DXFILE_OK)
|
||||
goto end;
|
||||
|
||||
|
@ -449,12 +458,47 @@ static HRESULT WINAPI IDirect3DRMMeshBuilderImpl_Load(IDirect3DRMMeshBuilder* if
|
|||
|
||||
TRACE("Found object type whose GUID = %s\n", debugstr_guid(pGuid));
|
||||
|
||||
if (!IsEqualGUID(pGuid, &GUID_Mesh))
|
||||
if (!IsEqualGUID(pGuid, &GUID_Header))
|
||||
{
|
||||
ret = D3DRMERR_BADFILE;
|
||||
goto end;
|
||||
}
|
||||
|
||||
hr = IDirectXFileData_GetData(pData, NULL, &size, (void**)&pHeader);
|
||||
if ((hr != DXFILE_OK) || (size != sizeof(Header)))
|
||||
goto end;
|
||||
|
||||
TRACE("Version is %d %d %d\n", pHeader->major, pHeader->minor, pHeader->flags);
|
||||
|
||||
/* Version must be 1.0.x */
|
||||
if ((pHeader->major != 1) || (pHeader->minor != 0))
|
||||
{
|
||||
ret = D3DRMERR_BADFILE;
|
||||
goto end;
|
||||
}
|
||||
|
||||
IDirectXFileData_Release(pData);
|
||||
pData = NULL;
|
||||
|
||||
hr = IDirectXFileEnumObject_GetNextDataObject(pEnumObject, &pData);
|
||||
if (hr != DXFILE_OK)
|
||||
{
|
||||
ret = D3DRMERR_NOTFOUND;
|
||||
goto end;
|
||||
}
|
||||
|
||||
hr = IDirectXFileData_GetType(pData, &pGuid);
|
||||
if (hr != DXFILE_OK)
|
||||
goto end;
|
||||
|
||||
TRACE("Found object type whose GUID = %s\n", debugstr_guid(pGuid));
|
||||
|
||||
if (!IsEqualGUID(pGuid, &GUID_Mesh))
|
||||
{
|
||||
ret = D3DRMERR_NOTFOUND;
|
||||
goto end;
|
||||
}
|
||||
|
||||
ret = D3DRM_OK;
|
||||
|
||||
end:
|
||||
|
|
|
@ -47,21 +47,32 @@ static BOOL InitFunctionPtrs(void)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
char data_ok[] =
|
||||
"xof 0302txt 0064\n"
|
||||
"Mesh Object\n"
|
||||
"{\n"
|
||||
"0;\n"
|
||||
"0;\n"
|
||||
"}\n";
|
||||
|
||||
char data_bad[] =
|
||||
char data_bad_version[] =
|
||||
"xof 0302txt 0064\n"
|
||||
"Header Object\n"
|
||||
"{\n"
|
||||
"1; 2; 3;\n"
|
||||
"}\n";
|
||||
|
||||
char data_no_mesh[] =
|
||||
"xof 0302txt 0064\n"
|
||||
"Header Object\n"
|
||||
"{\n"
|
||||
"1; 0; 1;\n"
|
||||
"}\n";
|
||||
|
||||
char data_ok[] =
|
||||
"xof 0302txt 0064\n"
|
||||
"Header Object\n"
|
||||
"{\n"
|
||||
"1; 0; 1;\n"
|
||||
"}\n"
|
||||
"Mesh Object\n"
|
||||
"{\n"
|
||||
"0;\n"
|
||||
"0;\n"
|
||||
"}\n";
|
||||
|
||||
static void MeshBuilderTest(void)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
@ -75,13 +86,18 @@ static void MeshBuilderTest(void)
|
|||
hr = IDirect3DRM_CreateMeshBuilder(pD3DRM, &pMeshBuilder);
|
||||
ok(hr == D3DRM_OK, "Cannot get IDirect3DRMMeshBuilder interface (hr = %x)\n", hr);
|
||||
|
||||
info.lpMemory = data_bad;
|
||||
info.dSize = sizeof(data_bad);
|
||||
info.lpMemory = data_bad_version;
|
||||
info.dSize = strlen(data_bad_version);
|
||||
hr = IDirect3DRMMeshBuilder_Load(pMeshBuilder, &info, NULL, D3DRMLOAD_FROMMEMORY, NULL, NULL);
|
||||
ok(hr == D3DRMERR_BADFILE, "Sould have returned D3DRMERR_BADFILE (hr = %x)\n", hr);
|
||||
|
||||
info.lpMemory = data_no_mesh;
|
||||
info.dSize = strlen(data_no_mesh);
|
||||
hr = IDirect3DRMMeshBuilder_Load(pMeshBuilder, &info, NULL, D3DRMLOAD_FROMMEMORY, NULL, NULL);
|
||||
ok(hr == D3DRMERR_NOTFOUND, "Sould have returned D3DRMERR_NOTFOUND (hr = %x)\n", hr);
|
||||
|
||||
info.lpMemory = data_ok;
|
||||
info.dSize = sizeof(data_ok);
|
||||
info.dSize = strlen(data_ok);
|
||||
hr = IDirect3DRMMeshBuilder_Load(pMeshBuilder, &info, NULL, D3DRMLOAD_FROMMEMORY, NULL, NULL);
|
||||
ok(hr == D3DRM_OK, "Cannot load mesh data (hr = %x)\n", hr);
|
||||
|
||||
|
|
Loading…
Reference in New Issue