d3dx9_36: Cube texture can be loaded as a simple texture. The first face texture is taken in that case.
This commit is contained in:
parent
1fd55b7334
commit
12d11833f7
|
@ -542,7 +542,8 @@ HRESULT load_texture_from_dds(IDirect3DTexture9 *texture, const void *src_data,
|
||||||
const struct dds_header *header = src_data;
|
const struct dds_header *header = src_data;
|
||||||
const BYTE *pixels = (BYTE *)(header + 1);
|
const BYTE *pixels = (BYTE *)(header + 1);
|
||||||
|
|
||||||
if (src_info->ResourceType != D3DRTYPE_TEXTURE)
|
/* Loading a cube texture as a simple texture is also supported (only first face texture is taken) */
|
||||||
|
if ((src_info->ResourceType != D3DRTYPE_TEXTURE) && (src_info->ResourceType != D3DRTYPE_CUBETEXTURE))
|
||||||
return D3DXERR_INVALIDDATA;
|
return D3DXERR_INVALIDDATA;
|
||||||
|
|
||||||
width = src_info->Width;
|
width = src_info->Width;
|
||||||
|
|
|
@ -62,11 +62,11 @@ static const unsigned char dds_cube_map[] = {
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x00,0x00,
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x00,0x00,
|
||||||
0x00,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
0x00,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50,
|
0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50,
|
||||||
0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50,
|
0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x51,
|
||||||
0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50,
|
0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x52,
|
||||||
0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50,
|
0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x53,
|
||||||
0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50,
|
0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x54,
|
||||||
0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x50
|
0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x87,0x0f,0x78,0x05,0x05,0x50,0x55
|
||||||
};
|
};
|
||||||
|
|
||||||
/* 4x4x2 volume map dds, 2 mipmaps */
|
/* 4x4x2 volume map dds, 2 mipmaps */
|
||||||
|
@ -1288,6 +1288,10 @@ static void test_D3DXCreateTextureFromFileInMemory(IDirect3DDevice9 *device)
|
||||||
{
|
{
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
IDirect3DTexture9 *texture;
|
IDirect3DTexture9 *texture;
|
||||||
|
D3DRESOURCETYPE type;
|
||||||
|
D3DSURFACE_DESC desc;
|
||||||
|
D3DLOCKED_RECT lock_rect;
|
||||||
|
int i;
|
||||||
|
|
||||||
hr = D3DXCreateTextureFromFileInMemory(device, dds_16bit, sizeof(dds_16bit), &texture);
|
hr = D3DXCreateTextureFromFileInMemory(device, dds_16bit, sizeof(dds_16bit), &texture);
|
||||||
ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemory returned %#x, expected %#x\n", hr, D3D_OK);
|
ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemory returned %#x, expected %#x\n", hr, D3D_OK);
|
||||||
|
@ -1299,6 +1303,29 @@ static void test_D3DXCreateTextureFromFileInMemory(IDirect3DDevice9 *device)
|
||||||
|
|
||||||
hr = D3DXCreateTextureFromFileInMemory(device, dds_24bit, sizeof(dds_24bit) - 1, &texture);
|
hr = D3DXCreateTextureFromFileInMemory(device, dds_24bit, sizeof(dds_24bit) - 1, &texture);
|
||||||
ok(hr == D3DXERR_INVALIDDATA, "D3DXCreateTextureFromFileInMemory returned %#x, expected %#x\n", hr, D3DXERR_INVALIDDATA);
|
ok(hr == D3DXERR_INVALIDDATA, "D3DXCreateTextureFromFileInMemory returned %#x, expected %#x\n", hr, D3DXERR_INVALIDDATA);
|
||||||
|
|
||||||
|
/* Check that D3DXCreateTextureFromFileInMemory accepts cube texture dds file (only first face texture is loaded) */
|
||||||
|
hr = D3DXCreateTextureFromFileInMemory(device, dds_cube_map, sizeof(dds_cube_map), &texture);
|
||||||
|
ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemory returned %#x, expected %#x\n", hr, D3D_OK);
|
||||||
|
if (SUCCEEDED(hr))
|
||||||
|
{
|
||||||
|
type = IDirect3DTexture9_GetType(texture);
|
||||||
|
ok(type == D3DRTYPE_TEXTURE, "IDirect3DTexture9_GetType returned %u, expected %u\n", type, D3DRTYPE_TEXTURE);
|
||||||
|
hr = IDirect3DTexture9_GetLevelDesc(texture, 0, &desc);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DTexture9_GetLevelDesc returned %#x, expected %#x\n", hr, D3D_OK);
|
||||||
|
ok(desc.Width == 4, "Width is %u, expected 4\n", desc.Width);
|
||||||
|
ok(desc.Height == 4, "Width is %u, expected 4\n", desc.Height);
|
||||||
|
hr = IDirect3DTexture9_LockRect(texture, 0, &lock_rect, NULL, D3DLOCK_READONLY);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DTexture9_LockTexture returned %#x, expected %#x\n", hr, D3D_OK);
|
||||||
|
if (SUCCEEDED(hr))
|
||||||
|
{
|
||||||
|
for (i = 0; i < 16; i++)
|
||||||
|
ok(((BYTE*)lock_rect.pBits)[i] == dds_cube_map[128+i], "Byte at index %u is 0x%02x, expected 0x%02x\n", i, ((BYTE*)lock_rect.pBits)[i], dds_cube_map[144+i]);
|
||||||
|
IDirect3DTexture9_UnlockRect(texture, 0);
|
||||||
|
}
|
||||||
|
IDirect3DTexture9_Release(texture);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_D3DXCreateTextureFromFileInMemoryEx(IDirect3DDevice9 *device)
|
static void test_D3DXCreateTextureFromFileInMemoryEx(IDirect3DDevice9 *device)
|
||||||
|
|
Loading…
Reference in New Issue