-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256
Am 2015-10-04 um 19:52 schrieb Andrew D'Addesio:
- /* Write ddHwDesc */
- desc_ptr = (BYTE*)&fdr->ddHwDesc;
- memcpy(desc_ptr, &desc1, desc_size);
- ((D3DDEVICEDESC*)desc_ptr)->dwSize = desc_size;
- /* Write ddSwDesc */
- desc_ptr += desc_size;
- memcpy(desc_ptr, &desc1, desc_size);
- ((D3DDEVICEDESC*)desc_ptr)->dwSize = desc_size;
Is there a nicer way? I can't think of one to be honest, but this code feels somewhat unsatisfying.
Also I guess we're lucky that all versions of D3DDEVICEDESC have a DWORD-aligned size, so we don't have to worry about padding between them.
Native ddraw doesn't support d3d in 64 bit. Ours does though, mostly out of laziness. Did you run the test in a 64 bit build? It might fail due to different struct alignment.
- /* Invalid D3DDEVICEDESC sizes should fail */
- search.dwSize = sizeof(search);
- search.dwFlags = 0;
- clear_device_result(&result, (D3D1_DESC_SIZE-4), (D3D1_DESC_SIZE-4)); hr = IDirect3D_FindDevice(Direct3D1, &search, &result);
- ok(hr == D3D_OK,
"Expected IDirect3D1::FindDevice to return D3D_OK, got 0x%08x\n", hr);
- ok(hr == DDERR_INVALIDPARAMS,
"Expected IDirect3D1::FindDevice to return DDERR_INVALIDPARAMS, got 0x%08x\n", hr);
What happens when you use something between D3D1_DESC_SIZE and D3D2_DESC_SIZE, or e.g. the largest size + 4?
I recommend to put the valid and invalid tests in a table together with an expect HRESULT. That way you don't have to duplicate the structure assignment code + FindDevice call and can just iterate over the table.