d3dx9: Implement D3DXLoadVolumeFromFileInMemory.

This commit is contained in:
Józef Kucia 2012-07-03 16:06:45 +02:00 committed by Alexandre Julliard
parent 83c7fed1b0
commit 18a2dde127
4 changed files with 77 additions and 1 deletions

View File

@ -190,7 +190,7 @@
@ stdcall D3DXLoadSurfaceFromResourceW(ptr ptr ptr ptr wstr ptr long long ptr)
@ stdcall D3DXLoadSurfaceFromSurface(ptr ptr ptr ptr ptr ptr long long)
@ stub D3DXLoadVolumeFromFileA(ptr ptr ptr ptr ptr long long ptr)
@ stub D3DXLoadVolumeFromFileInMemory(ptr ptr ptr ptr long ptr long long ptr)
@ stdcall D3DXLoadVolumeFromFileInMemory(ptr ptr ptr ptr long ptr long long ptr)
@ stub D3DXLoadVolumeFromFileW(ptr ptr ptr ptr ptr long long ptr)
@ stdcall D3DXLoadVolumeFromMemory(ptr ptr ptr ptr long long long ptr ptr long long)
@ stub D3DXLoadVolumeFromResourceA(ptr ptr ptr long ptr ptr long long ptr)

View File

@ -68,6 +68,9 @@ HRESULT load_texture_from_dds(IDirect3DTexture9 *texture, const void *src_data,
DWORD filter, D3DCOLOR color_key, const D3DXIMAGE_INFO *src_info) DECLSPEC_HIDDEN;
HRESULT load_cube_texture_from_dds(IDirect3DCubeTexture9 *cube_texture, const void *src_data,
const PALETTEENTRY *palette, DWORD filter, D3DCOLOR color_key, const D3DXIMAGE_INFO *src_info) DECLSPEC_HIDDEN;
HRESULT load_volume_from_dds(IDirect3DVolume9 *dst_volume, const PALETTEENTRY *dst_palette,
const D3DBOX *dst_box, const void *src_data, const D3DBOX *src_box, DWORD filter, D3DCOLOR color_key,
const D3DXIMAGE_INFO *src_info) DECLSPEC_HIDDEN;
HRESULT load_volume_texture_from_dds(IDirect3DVolumeTexture9 *volume_texture, const void *src_data,
const PALETTEENTRY *palette, DWORD filter, DWORD color_key, const D3DXIMAGE_INFO *src_info) DECLSPEC_HIDDEN;

View File

@ -407,6 +407,24 @@ static HRESULT load_surface_from_dds(IDirect3DSurface9 *dst_surface, const PALET
src_pitch, NULL, src_rect, filter, color_key);
}
HRESULT load_volume_from_dds(IDirect3DVolume9 *dst_volume, const PALETTEENTRY *dst_palette,
const D3DBOX *dst_box, const void *src_data, const D3DBOX *src_box, DWORD filter, D3DCOLOR color_key,
const D3DXIMAGE_INFO *src_info)
{
UINT row_pitch, slice_pitch;
const struct dds_header *header = src_data;
const BYTE *pixels = (BYTE *)(header + 1);
if (src_info->ResourceType != D3DRTYPE_VOLUMETEXTURE)
return D3DXERR_INVALIDDATA;
if (FAILED(calculate_dds_surface_size(src_info, src_info->Width, src_info->Height, &row_pitch, &slice_pitch)))
return E_NOTIMPL;
return D3DXLoadVolumeFromMemory(dst_volume, dst_palette, dst_box, pixels, src_info->Format,
row_pitch, slice_pitch, NULL, src_box, filter, color_key);
}
HRESULT load_texture_from_dds(IDirect3DTexture9 *texture, const void *src_data, const PALETTEENTRY *palette,
DWORD filter, D3DCOLOR color_key, const D3DXIMAGE_INFO *src_info)

View File

@ -142,6 +142,61 @@ HRESULT WINAPI D3DXLoadVolumeFromMemory(IDirect3DVolume9 *dst_volume,
return D3D_OK;
}
HRESULT WINAPI D3DXLoadVolumeFromFileInMemory(IDirect3DVolume9 *dst_volume,
const PALETTEENTRY *dst_palette,
const D3DBOX *dst_box,
const void *src_data,
UINT src_data_size,
const D3DBOX *src_box,
DWORD filter,
D3DCOLOR color_key,
D3DXIMAGE_INFO *src_info)
{
HRESULT hr;
D3DBOX box;
D3DXIMAGE_INFO image_info;
if (!dst_volume || !src_data) return D3DERR_INVALIDCALL;
hr = D3DXGetImageInfoFromFileInMemory(src_data, src_data_size, &image_info);
if (FAILED(hr)) return hr;
if (src_box)
{
if (src_box->Right > image_info.Width
|| src_box->Bottom > image_info.Height
|| src_box->Back > image_info.Depth)
return D3DERR_INVALIDCALL;
box = *src_box;
}
else
{
box.Left = 0;
box.Top = 0;
box.Right = image_info.Width;
box.Bottom = image_info.Height;
box.Front = 0;
box.Back = image_info.Depth;
}
if (image_info.ImageFileFormat != D3DXIFF_DDS)
{
FIXME("File format %#x is not supported yet\n", image_info.ImageFileFormat);
return E_NOTIMPL;
}
hr = load_volume_from_dds(dst_volume, dst_palette, dst_box, src_data, &box,
filter, color_key, &image_info);
if (FAILED(hr)) return hr;
if (src_info)
*src_info = image_info;
return D3D_OK;
}
HRESULT WINAPI D3DXLoadVolumeFromVolume(IDirect3DVolume9 *dst_volume,
const PALETTEENTRY *dst_palette,
const D3DBOX *dst_box,