mirror of
https://github.com/reactos/reactos.git
synced 2025-08-04 23:25:45 +00:00
[D3DX9_36]
* Sync with Wine 1.7.17. CORE-8080 svn path=/trunk/; revision=62819
This commit is contained in:
parent
482c3d3d9b
commit
b47789c216
18 changed files with 1994 additions and 1652 deletions
|
@ -76,7 +76,7 @@ static ULONG WINAPI ID3DXBufferImpl_Release(ID3DXBuffer *iface)
|
|||
return ref;
|
||||
}
|
||||
|
||||
static LPVOID WINAPI ID3DXBufferImpl_GetBufferPointer(ID3DXBuffer *iface)
|
||||
static void * WINAPI ID3DXBufferImpl_GetBufferPointer(ID3DXBuffer *iface)
|
||||
{
|
||||
struct ID3DXBufferImpl *This = impl_from_ID3DXBuffer(iface);
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
/***********************************************************************
|
||||
* DllMain.
|
||||
*/
|
||||
BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, LPVOID reserved)
|
||||
BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, void *reserved)
|
||||
{
|
||||
switch(reason)
|
||||
{
|
||||
|
|
|
@ -84,7 +84,7 @@ struct pixel_format_desc {
|
|||
};
|
||||
|
||||
HRESULT map_view_of_file(const WCHAR *filename, void **buffer, DWORD *length) DECLSPEC_HIDDEN;
|
||||
HRESULT load_resource_into_memory(HMODULE module, HRSRC resinfo, LPVOID *buffer, DWORD *length) DECLSPEC_HIDDEN;
|
||||
HRESULT load_resource_into_memory(HMODULE module, HRSRC resinfo, void **buffer, DWORD *length) DECLSPEC_HIDDEN;
|
||||
|
||||
HRESULT write_buffer_to_file(const WCHAR *filename, ID3DXBuffer *buffer) DECLSPEC_HIDDEN;
|
||||
|
||||
|
@ -104,7 +104,8 @@ void point_filter_argb_pixels(const BYTE *src, UINT src_row_pitch, UINT src_slic
|
|||
const struct pixel_format_desc *dst_format, D3DCOLOR color_key, const PALETTEENTRY *palette) DECLSPEC_HIDDEN;
|
||||
|
||||
HRESULT load_texture_from_dds(IDirect3DTexture9 *texture, const void *src_data, const PALETTEENTRY *palette,
|
||||
DWORD filter, D3DCOLOR color_key, const D3DXIMAGE_INFO *src_info) DECLSPEC_HIDDEN;
|
||||
DWORD filter, D3DCOLOR color_key, const D3DXIMAGE_INFO *src_info, unsigned int skip_levels,
|
||||
unsigned int *loaded_miplevels) 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,
|
||||
|
@ -114,6 +115,7 @@ HRESULT load_volume_texture_from_dds(IDirect3DVolumeTexture9 *volume_texture, co
|
|||
const PALETTEENTRY *palette, DWORD filter, DWORD color_key, const D3DXIMAGE_INFO *src_info) DECLSPEC_HIDDEN;
|
||||
|
||||
unsigned short float_32_to_16(const float in) DECLSPEC_HIDDEN;
|
||||
float float_16_to_32(const unsigned short in) DECLSPEC_HIDDEN;
|
||||
|
||||
/* debug helpers */
|
||||
const char *debug_d3dxparameter_class(D3DXPARAMETER_CLASS c) DECLSPEC_HIDDEN;
|
||||
|
@ -121,6 +123,7 @@ const char *debug_d3dxparameter_type(D3DXPARAMETER_TYPE t) DECLSPEC_HIDDEN;
|
|||
const char *debug_d3dxparameter_registerset(D3DXREGISTER_SET r) DECLSPEC_HIDDEN;
|
||||
|
||||
/* parameter type conversion helpers */
|
||||
void set_number(LPVOID outdata, D3DXPARAMETER_TYPE outtype, LPCVOID indata, D3DXPARAMETER_TYPE intype) DECLSPEC_HIDDEN;
|
||||
void set_number(void *outdata, D3DXPARAMETER_TYPE outtype,
|
||||
const void *indata, D3DXPARAMETER_TYPE intype) DECLSPEC_HIDDEN;
|
||||
|
||||
#endif /* __WINE_D3DX9_36_PRIVATE_H */
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -19,327 +19,289 @@
|
|||
|
||||
#include "d3dx9_36_private.h"
|
||||
|
||||
typedef struct ID3DXLineImpl {
|
||||
struct d3dx9_line
|
||||
{
|
||||
ID3DXLine ID3DXLine_iface;
|
||||
LONG ref;
|
||||
|
||||
IDirect3DDevice9 *device;
|
||||
IDirect3DStateBlock9 *state;
|
||||
} ID3DXLineImpl;
|
||||
};
|
||||
|
||||
static inline ID3DXLineImpl *impl_from_ID3DXLine(ID3DXLine *iface)
|
||||
static inline struct d3dx9_line *impl_from_ID3DXLine(ID3DXLine *iface)
|
||||
{
|
||||
return CONTAINING_RECORD(iface, ID3DXLineImpl, ID3DXLine_iface);
|
||||
return CONTAINING_RECORD(iface, struct d3dx9_line, ID3DXLine_iface);
|
||||
}
|
||||
|
||||
/*** IUnknown methods ***/
|
||||
static HRESULT WINAPI ID3DXLineImpl_QueryInterface(ID3DXLine* iface, REFIID riid, LPVOID* object)
|
||||
static HRESULT WINAPI d3dx9_line_QueryInterface(ID3DXLine *iface, REFIID riid, void **out)
|
||||
{
|
||||
TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), object);
|
||||
TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
|
||||
|
||||
if (IsEqualGUID(riid, &IID_IUnknown) ||
|
||||
IsEqualGUID(riid, &IID_ID3DXLine))
|
||||
if (IsEqualGUID(riid, &IID_ID3DXLine)
|
||||
|| IsEqualGUID(riid, &IID_IUnknown))
|
||||
{
|
||||
ID3DXLine_AddRef(iface);
|
||||
*object = iface;
|
||||
*out = iface;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
ERR("Interface %s not found\n", debugstr_guid(riid));
|
||||
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
|
||||
|
||||
*out = NULL;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
static ULONG WINAPI ID3DXLineImpl_AddRef(ID3DXLine* iface)
|
||||
static ULONG WINAPI d3dx9_line_AddRef(ID3DXLine *iface)
|
||||
{
|
||||
ID3DXLineImpl *This = impl_from_ID3DXLine(iface);
|
||||
struct d3dx9_line *line = impl_from_ID3DXLine(iface);
|
||||
ULONG refcount = InterlockedIncrement(&line->ref);
|
||||
|
||||
TRACE("(%p)->(): AddRef from %u\n", This, This->ref);
|
||||
TRACE("%p increasing refcount to %u.\n", line, refcount);
|
||||
|
||||
return InterlockedIncrement(&This->ref);
|
||||
return refcount;
|
||||
}
|
||||
|
||||
static ULONG WINAPI ID3DXLineImpl_Release(ID3DXLine* iface)
|
||||
static ULONG WINAPI d3dx9_line_Release(ID3DXLine *iface)
|
||||
{
|
||||
ID3DXLineImpl *This = impl_from_ID3DXLine(iface);
|
||||
ULONG ref = InterlockedDecrement(&This->ref);
|
||||
struct d3dx9_line *line = impl_from_ID3DXLine(iface);
|
||||
ULONG refcount = InterlockedDecrement(&line->ref);
|
||||
|
||||
TRACE("(%p)->(): Release from %u\n", This, ref + 1);
|
||||
TRACE("%p decreasing refcount to %u.\n", line, refcount);
|
||||
|
||||
if (!ref)
|
||||
if (!refcount)
|
||||
{
|
||||
IDirect3DDevice9_Release(This->device);
|
||||
HeapFree(GetProcessHeap(), 0, This);
|
||||
IDirect3DDevice9_Release(line->device);
|
||||
HeapFree(GetProcessHeap(), 0, line);
|
||||
}
|
||||
|
||||
return ref;
|
||||
return refcount;
|
||||
}
|
||||
|
||||
/*** ID3DXLine methods ***/
|
||||
static HRESULT WINAPI ID3DXLineImpl_GetDevice(struct ID3DXLine *iface, struct IDirect3DDevice9 **device)
|
||||
static HRESULT WINAPI d3dx9_line_GetDevice(struct ID3DXLine *iface, struct IDirect3DDevice9 **device)
|
||||
{
|
||||
ID3DXLineImpl *This = impl_from_ID3DXLine(iface);
|
||||
struct d3dx9_line *line = impl_from_ID3DXLine(iface);
|
||||
|
||||
TRACE ("(%p)->(%p)\n", This, device);
|
||||
TRACE("iface %p, device %p.\n", iface, line);
|
||||
|
||||
if (device == NULL) return D3DERR_INVALIDCALL;
|
||||
if (!device)
|
||||
return D3DERR_INVALIDCALL;
|
||||
|
||||
*device = This->device;
|
||||
IDirect3DDevice9_AddRef(This->device);
|
||||
*device = line->device;
|
||||
IDirect3DDevice9_AddRef(line->device);
|
||||
|
||||
return D3D_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ID3DXLineImpl_Begin(ID3DXLine* iface)
|
||||
static HRESULT WINAPI d3dx9_line_Begin(ID3DXLine *iface)
|
||||
{
|
||||
ID3DXLineImpl *This = impl_from_ID3DXLine(iface);
|
||||
|
||||
HRESULT hr;
|
||||
struct d3dx9_line *line = impl_from_ID3DXLine(iface);
|
||||
D3DXMATRIX identity, projection;
|
||||
D3DVIEWPORT9 vp;
|
||||
|
||||
TRACE ("(%p)->()\n", This);
|
||||
TRACE("iface %p.\n", iface);
|
||||
|
||||
if (This->state != NULL) /* We already began. Return error. */
|
||||
if (line->state)
|
||||
return D3DERR_INVALIDCALL;
|
||||
|
||||
hr = IDirect3DDevice9_CreateStateBlock(This->device, D3DSBT_ALL, &This->state);
|
||||
if (FAILED(hr)) return D3DXERR_INVALIDDATA;
|
||||
if (FAILED(IDirect3DDevice9_CreateStateBlock(line->device, D3DSBT_ALL, &line->state)))
|
||||
return D3DXERR_INVALIDDATA;
|
||||
|
||||
hr = IDirect3DDevice9_GetViewport(This->device, &vp);
|
||||
if (FAILED(hr)) goto failed;
|
||||
if (FAILED(IDirect3DDevice9_GetViewport(line->device, &vp)))
|
||||
goto failed;
|
||||
|
||||
D3DXMatrixIdentity(&identity);
|
||||
D3DXMatrixOrthoOffCenterLH(&projection,
|
||||
0.0, vp.Width, /* Min and max x */
|
||||
vp.Height, 0.0, /* Min and max y. Screen y is on top so this is inverted */
|
||||
0.0, 1.0); /* Min and max z */
|
||||
D3DXMatrixOrthoOffCenterLH(&projection, 0.0, (FLOAT)vp.Width, (FLOAT)vp.Height, 0.0, 0.0, 1.0);
|
||||
|
||||
hr = IDirect3DDevice9_SetTransform(This->device, D3DTS_WORLD, &identity);
|
||||
if (FAILED(hr)) goto failed;
|
||||
if (FAILED(IDirect3DDevice9_SetTransform(line->device, D3DTS_WORLD, &identity)))
|
||||
goto failed;
|
||||
if (FAILED(IDirect3DDevice9_SetTransform(line->device, D3DTS_VIEW, &identity)))
|
||||
goto failed;
|
||||
if (FAILED(IDirect3DDevice9_SetTransform(line->device, D3DTS_PROJECTION, &projection)))
|
||||
goto failed;
|
||||
|
||||
hr = IDirect3DDevice9_SetTransform(This->device, D3DTS_VIEW, &identity);
|
||||
if (FAILED(hr)) goto failed;
|
||||
|
||||
hr = IDirect3DDevice9_SetTransform(This->device, D3DTS_PROJECTION, &projection);
|
||||
if (FAILED(hr)) goto failed;
|
||||
|
||||
/* Windows sets similar states so we do the same */
|
||||
|
||||
hr = IDirect3DDevice9_SetRenderState(This->device, D3DRS_LIGHTING, FALSE);
|
||||
if (FAILED(hr)) goto failed;
|
||||
|
||||
hr = IDirect3DDevice9_SetRenderState(This->device, D3DRS_FOGENABLE, FALSE);
|
||||
if (FAILED(hr)) goto failed;
|
||||
|
||||
hr = IDirect3DDevice9_SetRenderState(This->device, D3DRS_SHADEMODE, D3DSHADE_FLAT);
|
||||
if (FAILED(hr)) goto failed;
|
||||
|
||||
hr = IDirect3DDevice9_SetRenderState(This->device, D3DRS_ALPHABLENDENABLE, TRUE);
|
||||
if (FAILED(hr)) goto failed;
|
||||
|
||||
hr = IDirect3DDevice9_SetRenderState(This->device, D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
|
||||
if (FAILED(hr)) goto failed;
|
||||
|
||||
hr = IDirect3DDevice9_SetRenderState(This->device, D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
|
||||
if (FAILED(hr)) goto failed;
|
||||
if (FAILED(IDirect3DDevice9_SetRenderState(line->device, D3DRS_LIGHTING, FALSE)))
|
||||
goto failed;
|
||||
if (FAILED(IDirect3DDevice9_SetRenderState(line->device, D3DRS_FOGENABLE, FALSE)))
|
||||
goto failed;
|
||||
if (FAILED(IDirect3DDevice9_SetRenderState(line->device, D3DRS_SHADEMODE, D3DSHADE_FLAT)))
|
||||
goto failed;
|
||||
if (FAILED(IDirect3DDevice9_SetRenderState(line->device, D3DRS_ALPHABLENDENABLE, TRUE)))
|
||||
goto failed;
|
||||
if (FAILED(IDirect3DDevice9_SetRenderState(line->device, D3DRS_SRCBLEND, D3DBLEND_SRCALPHA)))
|
||||
goto failed;
|
||||
if (FAILED(IDirect3DDevice9_SetRenderState(line->device, D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA)))
|
||||
goto failed;
|
||||
|
||||
return D3D_OK;
|
||||
|
||||
failed:
|
||||
IDirect3DStateBlock9_Apply(This->state);
|
||||
IDirect3DStateBlock9_Release(This->state);
|
||||
This->state = NULL;
|
||||
IDirect3DStateBlock9_Apply(line->state);
|
||||
IDirect3DStateBlock9_Release(line->state);
|
||||
line->state = NULL;
|
||||
return D3DXERR_INVALIDDATA;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ID3DXLineImpl_Draw(ID3DXLine* iface, CONST D3DXVECTOR2* vertexlist, DWORD vertexlistcount, D3DCOLOR color)
|
||||
static HRESULT WINAPI d3dx9_line_Draw(ID3DXLine *iface, const D3DXVECTOR2 *vertex_list,
|
||||
DWORD vertex_list_count, D3DCOLOR color)
|
||||
{
|
||||
ID3DXLineImpl *This = impl_from_ID3DXLine(iface);
|
||||
|
||||
FIXME("(%p)->(%p, %u, %#x): stub\n", This, vertexlist, vertexlistcount, color);
|
||||
FIXME("iface %p, vertex_list %p, vertex_list_count %u, color 0x%08x stub!\n",
|
||||
iface, vertex_list, vertex_list_count, color);
|
||||
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ID3DXLineImpl_DrawTransform(ID3DXLine* iface, CONST D3DXVECTOR3* vertexlist, DWORD vertexlistcount,
|
||||
CONST D3DXMATRIX* transform, D3DCOLOR color)
|
||||
static HRESULT WINAPI d3dx9_line_DrawTransform(ID3DXLine *iface, const D3DXVECTOR3 *vertex_list,
|
||||
DWORD vertex_list_count, const D3DXMATRIX *transform, D3DCOLOR color)
|
||||
{
|
||||
ID3DXLineImpl *This = impl_from_ID3DXLine(iface);
|
||||
|
||||
FIXME("(%p)->(%p, %u, %p, %#x): stub\n", This, vertexlist, vertexlistcount, transform, color);
|
||||
FIXME("iface %p, vertex_list %p, vertex_list_count %u, transform %p, color 0x%08x stub!\n",
|
||||
iface, vertex_list, vertex_list_count, transform, color);
|
||||
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ID3DXLineImpl_SetPattern(ID3DXLine* iface, DWORD pattern)
|
||||
static HRESULT WINAPI d3dx9_line_SetPattern(ID3DXLine *iface, DWORD pattern)
|
||||
{
|
||||
ID3DXLineImpl *This = impl_from_ID3DXLine(iface);
|
||||
|
||||
FIXME("(%p)->(%#x): stub\n", This, pattern);
|
||||
FIXME("iface %p, pattern 0x%08x stub!\n", iface, pattern);
|
||||
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static DWORD WINAPI ID3DXLineImpl_GetPattern(ID3DXLine* iface)
|
||||
static DWORD WINAPI d3dx9_line_GetPattern(ID3DXLine *iface)
|
||||
{
|
||||
ID3DXLineImpl *This = impl_from_ID3DXLine(iface);
|
||||
FIXME("iface %p stub!\n", iface);
|
||||
|
||||
FIXME("(%p)->(): stub\n", This);
|
||||
|
||||
return 0xFFFFFFFF;
|
||||
return 0xffffffff;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ID3DXLineImpl_SetPatternScale(ID3DXLine* iface, FLOAT scale)
|
||||
static HRESULT WINAPI d3dx9_line_SetPatternScale(ID3DXLine *iface, float scale)
|
||||
{
|
||||
ID3DXLineImpl *This = impl_from_ID3DXLine(iface);
|
||||
|
||||
FIXME("(%p)->(%f): stub\n", This, scale);
|
||||
FIXME("iface %p, scale %.8e stub!\n", iface, scale);
|
||||
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static FLOAT WINAPI ID3DXLineImpl_GetPatternScale(ID3DXLine* iface)
|
||||
static float WINAPI d3dx9_line_GetPatternScale(ID3DXLine *iface)
|
||||
{
|
||||
ID3DXLineImpl *This = impl_from_ID3DXLine(iface);
|
||||
|
||||
FIXME("(%p)->(): stub\n", This);
|
||||
FIXME("iface %p stub!\n", iface);
|
||||
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ID3DXLineImpl_SetWidth(ID3DXLine* iface, FLOAT width)
|
||||
static HRESULT WINAPI d3dx9_line_SetWidth(ID3DXLine *iface, float width)
|
||||
{
|
||||
ID3DXLineImpl *This = impl_from_ID3DXLine(iface);
|
||||
|
||||
FIXME("(%p)->(%f): stub\n", This, width);
|
||||
FIXME("iface %p, width %.8e stub!\n", iface, width);
|
||||
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static FLOAT WINAPI ID3DXLineImpl_GetWidth(ID3DXLine* iface)
|
||||
static float WINAPI d3dx9_line_GetWidth(ID3DXLine *iface)
|
||||
{
|
||||
ID3DXLineImpl *This = impl_from_ID3DXLine(iface);
|
||||
|
||||
FIXME("(%p)->(): stub\n", This);
|
||||
FIXME("iface %p stub!\n", iface);
|
||||
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ID3DXLineImpl_SetAntialias(ID3DXLine* iface, BOOL antialias)
|
||||
static HRESULT WINAPI d3dx9_line_SetAntialias(ID3DXLine *iface, BOOL antialias)
|
||||
{
|
||||
ID3DXLineImpl *This = impl_from_ID3DXLine(iface);
|
||||
|
||||
FIXME("(%p)->(%u): stub\n", This, antialias);
|
||||
FIXME("iface %p, antialias %#x stub!\n", iface, antialias);
|
||||
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static BOOL WINAPI ID3DXLineImpl_GetAntialias(ID3DXLine* iface)
|
||||
static BOOL WINAPI d3dx9_line_GetAntialias(ID3DXLine *iface)
|
||||
{
|
||||
ID3DXLineImpl *This = impl_from_ID3DXLine(iface);
|
||||
|
||||
FIXME("(%p)->(): stub\n", This);
|
||||
FIXME("iface %p stub!\n", iface);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ID3DXLineImpl_SetGLLines(ID3DXLine* iface, BOOL gl_lines)
|
||||
static HRESULT WINAPI d3dx9_line_SetGLLines(ID3DXLine *iface, BOOL gl_lines)
|
||||
{
|
||||
ID3DXLineImpl *This = impl_from_ID3DXLine(iface);
|
||||
|
||||
FIXME("(%p)->(%u): stub\n", This, gl_lines);
|
||||
FIXME("iface %p, gl_lines %#x stub!\n", iface, gl_lines);
|
||||
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static BOOL WINAPI ID3DXLineImpl_GetGLLines(ID3DXLine* iface)
|
||||
static BOOL WINAPI d3dx9_line_GetGLLines(ID3DXLine *iface)
|
||||
{
|
||||
ID3DXLineImpl *This = impl_from_ID3DXLine(iface);
|
||||
|
||||
FIXME("(%p)->(): stub\n", This);
|
||||
FIXME("iface %p stub!\n", iface);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ID3DXLineImpl_End(ID3DXLine* iface)
|
||||
static HRESULT WINAPI d3dx9_line_End(ID3DXLine *iface)
|
||||
{
|
||||
ID3DXLineImpl *This = impl_from_ID3DXLine(iface);
|
||||
struct d3dx9_line *line = impl_from_ID3DXLine(iface);
|
||||
|
||||
HRESULT hr;
|
||||
|
||||
TRACE ("(%p)->()\n", This);
|
||||
TRACE("iface %p.\n", iface);
|
||||
|
||||
if (This->state == NULL) /* We haven't begun yet. */
|
||||
if (!line->state)
|
||||
return D3DERR_INVALIDCALL;
|
||||
|
||||
hr = IDirect3DStateBlock9_Apply(This->state);
|
||||
IDirect3DStateBlock9_Release(This->state);
|
||||
This->state = NULL;
|
||||
hr = IDirect3DStateBlock9_Apply(line->state);
|
||||
IDirect3DStateBlock9_Release(line->state);
|
||||
line->state = NULL;
|
||||
|
||||
if (FAILED(hr)) return D3DXERR_INVALIDDATA;
|
||||
else return D3D_OK;
|
||||
if (FAILED(hr))
|
||||
return D3DXERR_INVALIDDATA;
|
||||
|
||||
return D3D_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ID3DXLineImpl_OnLostDevice(ID3DXLine* iface)
|
||||
static HRESULT WINAPI d3dx9_line_OnLostDevice(ID3DXLine *iface)
|
||||
{
|
||||
ID3DXLineImpl *This = impl_from_ID3DXLine(iface);
|
||||
|
||||
FIXME("(%p)->(): stub\n", This);
|
||||
FIXME("iface %p stub!\n", iface);
|
||||
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
static HRESULT WINAPI ID3DXLineImpl_OnResetDevice(ID3DXLine* iface)
|
||||
static HRESULT WINAPI d3dx9_line_OnResetDevice(ID3DXLine *iface)
|
||||
{
|
||||
ID3DXLineImpl *This = impl_from_ID3DXLine(iface);
|
||||
|
||||
FIXME("(%p)->(): stub\n", This);
|
||||
FIXME("iface %p stub!\n", iface);
|
||||
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static const struct ID3DXLineVtbl ID3DXLine_Vtbl =
|
||||
static const struct ID3DXLineVtbl d3dx9_line_vtbl =
|
||||
{
|
||||
/*** IUnknown methods ***/
|
||||
ID3DXLineImpl_QueryInterface,
|
||||
ID3DXLineImpl_AddRef,
|
||||
ID3DXLineImpl_Release,
|
||||
/*** ID3DXLine methods ***/
|
||||
ID3DXLineImpl_GetDevice,
|
||||
ID3DXLineImpl_Begin,
|
||||
ID3DXLineImpl_Draw,
|
||||
ID3DXLineImpl_DrawTransform,
|
||||
ID3DXLineImpl_SetPattern,
|
||||
ID3DXLineImpl_GetPattern,
|
||||
ID3DXLineImpl_SetPatternScale,
|
||||
ID3DXLineImpl_GetPatternScale,
|
||||
ID3DXLineImpl_SetWidth,
|
||||
ID3DXLineImpl_GetWidth,
|
||||
ID3DXLineImpl_SetAntialias,
|
||||
ID3DXLineImpl_GetAntialias,
|
||||
ID3DXLineImpl_SetGLLines,
|
||||
ID3DXLineImpl_GetGLLines,
|
||||
ID3DXLineImpl_End,
|
||||
ID3DXLineImpl_OnLostDevice,
|
||||
ID3DXLineImpl_OnResetDevice
|
||||
d3dx9_line_QueryInterface,
|
||||
d3dx9_line_AddRef,
|
||||
d3dx9_line_Release,
|
||||
d3dx9_line_GetDevice,
|
||||
d3dx9_line_Begin,
|
||||
d3dx9_line_Draw,
|
||||
d3dx9_line_DrawTransform,
|
||||
d3dx9_line_SetPattern,
|
||||
d3dx9_line_GetPattern,
|
||||
d3dx9_line_SetPatternScale,
|
||||
d3dx9_line_GetPatternScale,
|
||||
d3dx9_line_SetWidth,
|
||||
d3dx9_line_GetWidth,
|
||||
d3dx9_line_SetAntialias,
|
||||
d3dx9_line_GetAntialias,
|
||||
d3dx9_line_SetGLLines,
|
||||
d3dx9_line_GetGLLines,
|
||||
d3dx9_line_End,
|
||||
d3dx9_line_OnLostDevice,
|
||||
d3dx9_line_OnResetDevice,
|
||||
};
|
||||
|
||||
HRESULT WINAPI D3DXCreateLine(struct IDirect3DDevice9 *device, struct ID3DXLine **line)
|
||||
{
|
||||
ID3DXLineImpl* object;
|
||||
struct d3dx9_line *object;
|
||||
|
||||
TRACE("(%p, %p)\n", device, line);
|
||||
TRACE("device %p, line %p.\n", device, line);
|
||||
|
||||
if (!device || !line)
|
||||
return D3DERR_INVALIDCALL;
|
||||
|
||||
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ID3DXLineImpl));
|
||||
if (!object)
|
||||
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
object->ID3DXLine_iface.lpVtbl = &ID3DXLine_Vtbl;
|
||||
object->ID3DXLine_iface.lpVtbl = &d3dx9_line_vtbl;
|
||||
object->ref = 1;
|
||||
object->device = device;
|
||||
object->state = NULL; /* We only initialize it on Begin */
|
||||
IDirect3DDevice9_AddRef(device);
|
||||
|
||||
*line = &object->ID3DXLine_iface;
|
||||
|
|
|
@ -155,7 +155,7 @@ D3DXMATRIX * WINAPI D3DXMatrixAffineTransformation2D(D3DXMATRIX *out, FLOAT scal
|
|||
|
||||
s = sinf(rotation / 2.0f);
|
||||
tmp1 = 1.0f - 2.0f * s * s;
|
||||
tmp2 = 2.0 * s * cosf(rotation / 2.0f);
|
||||
tmp2 = 2.0f * s * cosf(rotation / 2.0f);
|
||||
|
||||
D3DXMatrixIdentity(out);
|
||||
out->u.m[0][0] = scaling * tmp1;
|
||||
|
@ -480,8 +480,8 @@ D3DXMATRIX* WINAPI D3DXMatrixPerspectiveFovLH(D3DXMATRIX *pout, FLOAT fovy, FLOA
|
|||
TRACE("pout %p, fovy %f, aspect %f, zn %f, zf %f\n", pout, fovy, aspect, zn, zf);
|
||||
|
||||
D3DXMatrixIdentity(pout);
|
||||
pout->u.m[0][0] = 1.0f / (aspect * tan(fovy/2.0f));
|
||||
pout->u.m[1][1] = 1.0f / tan(fovy/2.0f);
|
||||
pout->u.m[0][0] = 1.0f / (aspect * tanf(fovy/2.0f));
|
||||
pout->u.m[1][1] = 1.0f / tanf(fovy/2.0f);
|
||||
pout->u.m[2][2] = zf / (zf - zn);
|
||||
pout->u.m[2][3] = 1.0f;
|
||||
pout->u.m[3][2] = (zf * zn) / (zn - zf);
|
||||
|
@ -494,8 +494,8 @@ D3DXMATRIX* WINAPI D3DXMatrixPerspectiveFovRH(D3DXMATRIX *pout, FLOAT fovy, FLOA
|
|||
TRACE("pout %p, fovy %f, aspect %f, zn %f, zf %f\n", pout, fovy, aspect, zn, zf);
|
||||
|
||||
D3DXMatrixIdentity(pout);
|
||||
pout->u.m[0][0] = 1.0f / (aspect * tan(fovy/2.0f));
|
||||
pout->u.m[1][1] = 1.0f / tan(fovy/2.0f);
|
||||
pout->u.m[0][0] = 1.0f / (aspect * tanf(fovy/2.0f));
|
||||
pout->u.m[1][1] = 1.0f / tanf(fovy/2.0f);
|
||||
pout->u.m[2][2] = zf / (zn - zf);
|
||||
pout->u.m[2][3] = -1.0f;
|
||||
pout->u.m[3][2] = (zf * zn) / (zn - zf);
|
||||
|
@ -640,10 +640,10 @@ D3DXMATRIX* WINAPI D3DXMatrixRotationX(D3DXMATRIX *pout, FLOAT angle)
|
|||
TRACE("pout %p, angle %f\n", pout, angle);
|
||||
|
||||
D3DXMatrixIdentity(pout);
|
||||
pout->u.m[1][1] = cos(angle);
|
||||
pout->u.m[2][2] = cos(angle);
|
||||
pout->u.m[1][2] = sin(angle);
|
||||
pout->u.m[2][1] = -sin(angle);
|
||||
pout->u.m[1][1] = cosf(angle);
|
||||
pout->u.m[2][2] = cosf(angle);
|
||||
pout->u.m[1][2] = sinf(angle);
|
||||
pout->u.m[2][1] = -sinf(angle);
|
||||
return pout;
|
||||
}
|
||||
|
||||
|
@ -652,10 +652,10 @@ D3DXMATRIX* WINAPI D3DXMatrixRotationY(D3DXMATRIX *pout, FLOAT angle)
|
|||
TRACE("pout %p, angle %f\n", pout, angle);
|
||||
|
||||
D3DXMatrixIdentity(pout);
|
||||
pout->u.m[0][0] = cos(angle);
|
||||
pout->u.m[2][2] = cos(angle);
|
||||
pout->u.m[0][2] = -sin(angle);
|
||||
pout->u.m[2][0] = sin(angle);
|
||||
pout->u.m[0][0] = cosf(angle);
|
||||
pout->u.m[2][2] = cosf(angle);
|
||||
pout->u.m[0][2] = -sinf(angle);
|
||||
pout->u.m[2][0] = sinf(angle);
|
||||
return pout;
|
||||
}
|
||||
|
||||
|
@ -697,10 +697,10 @@ D3DXMATRIX* WINAPI D3DXMatrixRotationZ(D3DXMATRIX *pout, FLOAT angle)
|
|||
TRACE("pout %p, angle %f\n", pout, angle);
|
||||
|
||||
D3DXMatrixIdentity(pout);
|
||||
pout->u.m[0][0] = cos(angle);
|
||||
pout->u.m[1][1] = cos(angle);
|
||||
pout->u.m[0][1] = sin(angle);
|
||||
pout->u.m[1][0] = -sin(angle);
|
||||
pout->u.m[0][0] = cosf(angle);
|
||||
pout->u.m[1][1] = cosf(angle);
|
||||
pout->u.m[0][1] = sinf(angle);
|
||||
pout->u.m[1][0] = -sinf(angle);
|
||||
return pout;
|
||||
}
|
||||
|
||||
|
@ -881,15 +881,15 @@ D3DXMATRIX* WINAPI D3DXMatrixTransformation2D(D3DXMATRIX *pout, const D3DXVECTOR
|
|||
trans.z=0.0f;
|
||||
}
|
||||
|
||||
rot.w=cos(rotation/2.0f);
|
||||
rot.w=cosf(rotation/2.0f);
|
||||
rot.x=0.0f;
|
||||
rot.y=0.0f;
|
||||
rot.z=sin(rotation/2.0f);
|
||||
rot.z=sinf(rotation/2.0f);
|
||||
|
||||
sca_rot.w=cos(scalingrotation/2.0f);
|
||||
sca_rot.w=cosf(scalingrotation/2.0f);
|
||||
sca_rot.x=0.0f;
|
||||
sca_rot.y=0.0f;
|
||||
sca_rot.z=sin(scalingrotation/2.0f);
|
||||
sca_rot.z=sinf(scalingrotation/2.0f);
|
||||
|
||||
D3DXMatrixTransformation(pout, &sca_center, &sca_rot, &sca, &rot_center, &rot, &trans);
|
||||
|
||||
|
@ -1648,7 +1648,7 @@ void WINAPI D3DXQuaternionToAxisAngle(const D3DXQUATERNION *pq, D3DXVECTOR3 *pax
|
|||
paxis->x = pq->x;
|
||||
paxis->y = pq->y;
|
||||
paxis->z = pq->z;
|
||||
*pangle = 2.0f * acos(pq->w);
|
||||
*pangle = 2.0f * acosf(pq->w);
|
||||
}
|
||||
|
||||
/*_________________D3DXVec2_____________________*/
|
||||
|
@ -2121,7 +2121,7 @@ D3DXVECTOR4* WINAPI D3DXVec4TransformArray(D3DXVECTOR4* out, UINT outstride, con
|
|||
unsigned short float_32_to_16(const float in)
|
||||
{
|
||||
int exp = 0, origexp;
|
||||
float tmp = fabs(in);
|
||||
float tmp = fabsf(in);
|
||||
int sign = (copysignf(1, in) < 0);
|
||||
unsigned int mantissa;
|
||||
unsigned short ret;
|
||||
|
@ -2219,7 +2219,7 @@ D3DXFLOAT16 *WINAPI D3DXFloat32To16Array(D3DXFLOAT16 *pout, const FLOAT *pin, UI
|
|||
|
||||
/* Native d3dx9's D3DXFloat16to32Array lacks support for NaN and Inf. Specifically, e = 16 is treated as a
|
||||
* regular number - e.g., 0x7fff is converted to 131008.0 and 0xffff to -131008.0. */
|
||||
static inline float float_16_to_32(const unsigned short in)
|
||||
float float_16_to_32(const unsigned short in)
|
||||
{
|
||||
const unsigned short s = (in & 0x8000);
|
||||
const unsigned short e = (in & 0x7C00) >> 10;
|
||||
|
@ -2279,7 +2279,7 @@ FLOAT WINAPI D3DXSHDot(UINT order, const FLOAT *a, const FLOAT *b)
|
|||
return s;
|
||||
}
|
||||
|
||||
static void weightedcapintegrale(FLOAT *out, FLOAT order, FLOAT angle)
|
||||
static void weightedcapintegrale(FLOAT *out, UINT order, FLOAT angle)
|
||||
{
|
||||
FLOAT coeff[3];
|
||||
|
||||
|
@ -2387,9 +2387,9 @@ FLOAT* WINAPI D3DXSHEvalDirection(FLOAT *out, UINT order, const D3DXVECTOR3 *dir
|
|||
|
||||
out[9] = -sqrtf(70.0f / D3DX_PI) / 8.0f * dir->y * (3.0f * dirxx - diryy);
|
||||
out[10] = sqrtf(105.0f / D3DX_PI) / 2.0f * dirxy * dir->z;
|
||||
out[11] = -sqrtf(42.0 / D3DX_PI) / 8.0f * dir->y * (-1.0f + 5.0f * dirzz);
|
||||
out[11] = -sqrtf(42.0f / D3DX_PI) / 8.0f * dir->y * (-1.0f + 5.0f * dirzz);
|
||||
out[12] = sqrtf(7.0f / D3DX_PI) / 4.0f * dir->z * (5.0f * dirzz - 3.0f);
|
||||
out[13] = sqrtf(42.0 / D3DX_PI) / 8.0f * dir->x * (1.0f - 5.0f * dirzz);
|
||||
out[13] = sqrtf(42.0f / D3DX_PI) / 8.0f * dir->x * (1.0f - 5.0f * dirzz);
|
||||
out[14] = sqrtf(105.0f / D3DX_PI) / 4.0f * dir->z * (dirxx - diryy);
|
||||
out[15] = -sqrtf(70.0f / D3DX_PI) / 8.0f * dir->x * (dirxx - 3.0f * diryy);
|
||||
if (order == 4)
|
||||
|
@ -2402,7 +2402,7 @@ FLOAT* WINAPI D3DXSHEvalDirection(FLOAT *out, UINT order, const D3DXVECTOR3 *dir
|
|||
out[20] = 3.0f / (16.0f * sqrtf(D3DX_PI)) * (35.0f * dirzzzz - 30.f * dirzz + 3.0f);
|
||||
out[21] = 0.375f * sqrtf(10.0f / D3DX_PI) * dirxz * (3.0f - 7.0f * dirzz);
|
||||
out[22] = 0.375f * sqrtf(5.0f / D3DX_PI) * (dirxx - diryy) * (7.0f * dirzz - 1.0f);
|
||||
out[23] = 3.0 * dir->z * out[15];
|
||||
out[23] = 3.0f * dir->z * out[15];
|
||||
out[24] = 3.0f / 16.0f * sqrtf(35.0f / D3DX_PI) * (dirxxxx - 6.0f * dirxyxy + diryyyy);
|
||||
if (order == 5)
|
||||
return out;
|
||||
|
@ -2416,7 +2416,7 @@ FLOAT* WINAPI D3DXSHEvalDirection(FLOAT *out, UINT order, const D3DXVECTOR3 *dir
|
|||
out[31] = sqrtf(165.0f / D3DX_PI) / 16.0f * dir->x * (14.0f * dirzz - 21.0f * dirzzzz - 1.0f);
|
||||
out[32] = sqrtf(1155.0f / D3DX_PI) / 8.0f * dir->z * (dirxx - diryy) * (3.0f * dirzz - 1.0f);
|
||||
out[33] = sqrtf(770.0f / D3DX_PI) / 32.0f * dir->x * (dirxx - 3.0f * diryy) * (1.0f - 9.0f * dirzz);
|
||||
out[34] = 3.0f / 16.0f * sqrtf(385.0f / D3DX_PI) * dir->z * (dirxxxx - 6.0 * dirxyxy + diryyyy);
|
||||
out[34] = 3.0f / 16.0f * sqrtf(385.0f / D3DX_PI) * dir->z * (dirxxxx - 6.0f * dirxyxy + diryyyy);
|
||||
out[35] = -3.0f/ 32.0f * sqrtf(154.0f / D3DX_PI) * dir->x * (dirxxxx - 10.0f * dirxyxy + 5.0f * diryyyy);
|
||||
|
||||
return out;
|
||||
|
@ -2622,8 +2622,8 @@ FLOAT * WINAPI D3DXSHMultiply3(FLOAT *out, const FLOAT *a, const FLOAT *b)
|
|||
t = a[4] * b[5] + a[5] * b[4];
|
||||
out[7] += 0.15607834f * t;
|
||||
|
||||
ta = 0.28209479f * a[0] + 0.09011186 * a[6] - 0.15607835f * a[8];
|
||||
tb = 0.28209479f * b[0] + 0.09011186 * b[6] - 0.15607835f * b[8];
|
||||
ta = 0.28209479f * a[0] + 0.09011186f * a[6] - 0.15607835f * a[8];
|
||||
tb = 0.28209479f * b[0] + 0.09011186f * b[6] - 0.15607835f * b[8];
|
||||
out[5] += ta * b[5] + tb * a[5];
|
||||
t = a[5] * b[5];
|
||||
out[0] += 0.28209479f * t;
|
||||
|
@ -2637,8 +2637,8 @@ FLOAT * WINAPI D3DXSHMultiply3(FLOAT *out, const FLOAT *a, const FLOAT *b)
|
|||
out[0] += 0.28209480f * t;
|
||||
out[6] += 0.18022376f * t;
|
||||
|
||||
ta = 0.28209479f * a[0] + 0.09011186 * a[6] + 0.15607835f * a[8];
|
||||
tb = 0.28209479f * b[0] + 0.09011186 * b[6] + 0.15607835f * b[8];
|
||||
ta = 0.28209479f * a[0] + 0.09011186f * a[6] + 0.15607835f * a[8];
|
||||
tb = 0.28209479f * b[0] + 0.09011186f * b[6] + 0.15607835f * b[8];
|
||||
out[7] += ta * b[7] + tb * a[7];
|
||||
t = a[7] * b[7];
|
||||
out[0] += 0.28209479f * t;
|
||||
|
@ -2981,7 +2981,7 @@ static void rotate_X(FLOAT *out, UINT order, FLOAT a, FLOAT *in)
|
|||
|
||||
out[25] = a * 0.7015607357f * in[30] - a * 0.6846531630f * in[32] + a * 0.1976423711f * in[34];
|
||||
out[26] = -0.5f * in[26] + 0.8660253882f * in[28];
|
||||
out[27] = a * 0.5229125023f * in[30] + a * 0.3061861992f * in[32] - a * 0.7954951525 * in[34];
|
||||
out[27] = a * 0.5229125023f * in[30] + a * 0.3061861992f * in[32] - a * 0.7954951525f * in[34];
|
||||
out[28] = 0.8660253882f * in[26] + 0.5f * in[28];
|
||||
out[29] = a * 0.4841229022f * in[30] + a * 0.6614378691f * in[32] + a * 0.5728219748f * in[34];
|
||||
out[30] = -a * 0.7015607357f * in[25] - a * 0.5229125023f * in[27] - a * 0.4841229022f * in[29];
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2012 Jأ³zef Kucia
|
||||
* Copyright (C) 2012 Józef Kucia
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
|
@ -21,11 +21,11 @@
|
|||
#include "d3dx9_36_private.h"
|
||||
#include "d3dcompiler.h"
|
||||
|
||||
/* This function is not declared in the SDK headers yet */
|
||||
HRESULT WINAPI D3DAssemble(LPCVOID data, SIZE_T datasize, LPCSTR filename,
|
||||
const D3D_SHADER_MACRO *defines, ID3DInclude *include,
|
||||
UINT flags,
|
||||
ID3DBlob **shader, ID3DBlob **error_messages);
|
||||
|
||||
/* This function is not declared in the SDK headers yet. */
|
||||
HRESULT WINAPI D3DAssemble(const void *data, SIZE_T datasize, const char *filename,
|
||||
const D3D_SHADER_MACRO *defines, ID3DInclude *include, UINT flags,
|
||||
ID3DBlob **shader, ID3DBlob **error_messages);
|
||||
|
||||
static inline BOOL is_valid_bytecode(DWORD token)
|
||||
{
|
||||
|
@ -142,6 +142,7 @@ const char * WINAPI D3DXGetVertexShaderProfile(struct IDirect3DDevice9 *device)
|
|||
HRESULT WINAPI D3DXFindShaderComment(const DWORD *byte_code, DWORD fourcc, const void **data, UINT *size)
|
||||
{
|
||||
const DWORD *ptr = byte_code;
|
||||
DWORD version;
|
||||
|
||||
TRACE("byte_code %p, fourcc %x, data %p, size %p\n", byte_code, fourcc, data, size);
|
||||
|
||||
|
@ -149,7 +150,18 @@ HRESULT WINAPI D3DXFindShaderComment(const DWORD *byte_code, DWORD fourcc, const
|
|||
if (size) *size = 0;
|
||||
|
||||
if (!byte_code) return D3DERR_INVALIDCALL;
|
||||
if (!is_valid_bytecode(*byte_code)) return D3DXERR_INVALIDDATA;
|
||||
|
||||
version = *ptr >> 16;
|
||||
if (version != 0x4658 /* FX */
|
||||
&& version != 0x5458 /* TX */
|
||||
&& version != 0x7ffe
|
||||
&& version != 0x7fff
|
||||
&& version != 0xfffe /* VS */
|
||||
&& version != 0xffff) /* PS */
|
||||
{
|
||||
WARN("Invalid data supplied\n");
|
||||
return D3DXERR_INVALIDDATA;
|
||||
}
|
||||
|
||||
while (*++ptr != D3DSIO_END)
|
||||
{
|
||||
|
@ -162,7 +174,7 @@ HRESULT WINAPI D3DXFindShaderComment(const DWORD *byte_code, DWORD fourcc, const
|
|||
if (*(ptr + 1) == fourcc)
|
||||
{
|
||||
UINT ctab_size = (comment_size - 1) * sizeof(DWORD);
|
||||
LPCVOID ctab_data = ptr + 2;
|
||||
const void *ctab_data = ptr + 2;
|
||||
if (size)
|
||||
*size = ctab_size;
|
||||
if (data)
|
||||
|
@ -196,14 +208,13 @@ HRESULT WINAPI D3DXAssembleShader(const char *data, UINT data_len, const D3DXMAC
|
|||
}
|
||||
|
||||
/* D3DXInclude private implementation, used to implement
|
||||
D3DXAssembleShaderFromFile from D3DXAssembleShader */
|
||||
/* To be able to correctly resolve include search paths we have to store
|
||||
the pathname of each include file. We store the pathname pointer right
|
||||
before the file data. */
|
||||
static HRESULT WINAPI d3dincludefromfile_open(ID3DXInclude *iface,
|
||||
D3DXINCLUDE_TYPE include_type,
|
||||
LPCSTR filename, LPCVOID parent_data,
|
||||
LPCVOID *data, UINT *bytes) {
|
||||
* D3DXAssembleShaderFromFile() from D3DXAssembleShader(). */
|
||||
/* To be able to correctly resolve include search paths we have to store the
|
||||
* pathname of each include file. We store the pathname pointer right before
|
||||
* the file data. */
|
||||
static HRESULT WINAPI d3dincludefromfile_open(ID3DXInclude *iface, D3DXINCLUDE_TYPE include_type,
|
||||
const char *filename, const void *parent_data, const void **data, UINT *bytes)
|
||||
{
|
||||
const char *p, *parent_name = "";
|
||||
char *pathname = NULL;
|
||||
char **buffer = NULL;
|
||||
|
@ -253,7 +264,8 @@ error:
|
|||
return HRESULT_FROM_WIN32(GetLastError());
|
||||
}
|
||||
|
||||
static HRESULT WINAPI d3dincludefromfile_close(ID3DXInclude *iface, LPCVOID data) {
|
||||
static HRESULT WINAPI d3dincludefromfile_close(ID3DXInclude *iface, const void *data)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, *((char **)data - 1));
|
||||
HeapFree(GetProcessHeap(), 0, (char **)data - 1);
|
||||
return S_OK;
|
||||
|
@ -271,10 +283,13 @@ struct D3DXIncludeImpl {
|
|||
HRESULT WINAPI D3DXAssembleShaderFromFileA(const char *filename, const D3DXMACRO *defines,
|
||||
ID3DXInclude *include, DWORD flags, ID3DXBuffer **shader, ID3DXBuffer **error_messages)
|
||||
{
|
||||
LPWSTR filename_w = NULL;
|
||||
WCHAR *filename_w;
|
||||
DWORD len;
|
||||
HRESULT ret;
|
||||
|
||||
TRACE("filename %s, defines %p, include %p, flags %#x, shader %p, error_messages %p.\n",
|
||||
debugstr_a(filename), defines, include, flags, shader, error_messages);
|
||||
|
||||
if (!filename) return D3DXERR_INVALIDDATA;
|
||||
|
||||
len = MultiByteToWideChar(CP_ACP, 0, filename, -1, NULL, 0);
|
||||
|
@ -291,13 +306,14 @@ HRESULT WINAPI D3DXAssembleShaderFromFileA(const char *filename, const D3DXMACRO
|
|||
HRESULT WINAPI D3DXAssembleShaderFromFileW(const WCHAR *filename, const D3DXMACRO *defines,
|
||||
ID3DXInclude *include, DWORD flags, ID3DXBuffer **shader, ID3DXBuffer **error_messages)
|
||||
{
|
||||
void *buffer;
|
||||
const void *buffer;
|
||||
DWORD len;
|
||||
HRESULT hr;
|
||||
struct D3DXIncludeImpl includefromfile;
|
||||
char *filename_a;
|
||||
|
||||
if(FAILED(map_view_of_file(filename, &buffer, &len)))
|
||||
return D3DXERR_INVALIDDATA;
|
||||
TRACE("filename %s, defines %p, include %p, flags %#x, shader %p, error_messages %p.\n",
|
||||
debugstr_w(filename), defines, include, flags, shader, error_messages);
|
||||
|
||||
if(!include)
|
||||
{
|
||||
|
@ -305,10 +321,23 @@ HRESULT WINAPI D3DXAssembleShaderFromFileW(const WCHAR *filename, const D3DXMACR
|
|||
include = &includefromfile.ID3DXInclude_iface;
|
||||
}
|
||||
|
||||
hr = D3DXAssembleShader(buffer, len, defines, include, flags,
|
||||
shader, error_messages);
|
||||
len = WideCharToMultiByte(CP_ACP, 0, filename, -1, NULL, 0, NULL, NULL);
|
||||
filename_a = HeapAlloc(GetProcessHeap(), 0, len * sizeof(char));
|
||||
if (!filename_a)
|
||||
return E_OUTOFMEMORY;
|
||||
WideCharToMultiByte(CP_ACP, 0, filename, -1, filename_a, len, NULL, NULL);
|
||||
|
||||
UnmapViewOfFile(buffer);
|
||||
hr = ID3DXInclude_Open(include, D3D_INCLUDE_LOCAL, filename_a, NULL, &buffer, &len);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, filename_a);
|
||||
return D3DXERR_INVALIDDATA;
|
||||
}
|
||||
|
||||
hr = D3DXAssembleShader(buffer, len, defines, include, flags, shader, error_messages);
|
||||
|
||||
ID3DXInclude_Close(include, buffer);
|
||||
HeapFree(GetProcessHeap(), 0, filename_a);
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
@ -319,7 +348,10 @@ HRESULT WINAPI D3DXAssembleShaderFromResourceA(HMODULE module, const char *resou
|
|||
HRSRC res;
|
||||
DWORD len;
|
||||
|
||||
if (!(res = FindResourceA(module, resource, (LPCSTR)RT_RCDATA)))
|
||||
TRACE("module %p, resource %s, defines %p, include %p, flags %#x, shader %p, error_messages %p.\n",
|
||||
module, debugstr_a(resource), defines, include, flags, shader, error_messages);
|
||||
|
||||
if (!(res = FindResourceA(module, resource, (const char *)RT_RCDATA)))
|
||||
return D3DXERR_INVALIDDATA;
|
||||
if (FAILED(load_resource_into_memory(module, res, &buffer, &len)))
|
||||
return D3DXERR_INVALIDDATA;
|
||||
|
@ -351,8 +383,10 @@ HRESULT WINAPI D3DXCompileShader(const char *data, UINT length, const D3DXMACRO
|
|||
{
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("data %p, length %u, defines %p, include %p, function %s, profile %s, flags %#x, shader %p, error_msgs %p, constant_table %p\n",
|
||||
data, length, defines, include, function, profile, flags, shader, error_msgs, constant_table);
|
||||
TRACE("data %s, length %u, defines %p, include %p, function %s, profile %s, "
|
||||
"flags %#x, shader %p, error_msgs %p, constant_table %p.\n",
|
||||
debugstr_a(data), length, defines, include, debugstr_a(function), debugstr_a(profile),
|
||||
flags, shader, error_msgs, constant_table);
|
||||
|
||||
hr = D3DCompile(data, length, NULL, (D3D_SHADER_MACRO *)defines, (ID3DInclude *)include,
|
||||
function, profile, flags, 0, (ID3DBlob **)shader, (ID3DBlob **)error_msgs);
|
||||
|
@ -374,10 +408,15 @@ HRESULT WINAPI D3DXCompileShaderFromFileA(const char *filename, const D3DXMACRO
|
|||
ID3DXInclude *include, const char *entrypoint, const char *profile, DWORD flags,
|
||||
ID3DXBuffer **shader, ID3DXBuffer **error_messages, ID3DXConstantTable **constant_table)
|
||||
{
|
||||
LPWSTR filename_w = NULL;
|
||||
WCHAR *filename_w;
|
||||
DWORD len;
|
||||
HRESULT ret;
|
||||
|
||||
TRACE("filename %s, defines %p, include %p, entrypoint %s, profile %s, "
|
||||
"flags %#x, shader %p, error_messages %p, constant_table %p.\n",
|
||||
debugstr_a(filename), defines, include, debugstr_a(entrypoint),
|
||||
debugstr_a(profile), flags, shader, error_messages, constant_table);
|
||||
|
||||
if (!filename) return D3DXERR_INVALIDDATA;
|
||||
|
||||
len = MultiByteToWideChar(CP_ACP, 0, filename, -1, NULL, 0);
|
||||
|
@ -397,14 +436,16 @@ HRESULT WINAPI D3DXCompileShaderFromFileW(const WCHAR *filename, const D3DXMACRO
|
|||
ID3DXInclude *include, const char *entrypoint, const char *profile, DWORD flags,
|
||||
ID3DXBuffer **shader, ID3DXBuffer **error_messages, ID3DXConstantTable **constant_table)
|
||||
{
|
||||
void *buffer;
|
||||
const void *buffer;
|
||||
DWORD len, filename_len;
|
||||
HRESULT hr;
|
||||
struct D3DXIncludeImpl includefromfile;
|
||||
char *filename_a;
|
||||
|
||||
if (FAILED(map_view_of_file(filename, &buffer, &len)))
|
||||
return D3DXERR_INVALIDDATA;
|
||||
TRACE("filename %s, defines %p, include %p, entrypoint %s, profile %s, "
|
||||
"flags %#x, shader %p, error_messages %p, constant_table %p.\n",
|
||||
debugstr_w(filename), defines, include, debugstr_a(entrypoint), debugstr_a(profile),
|
||||
flags, shader, error_messages, constant_table);
|
||||
|
||||
if (!include)
|
||||
{
|
||||
|
@ -415,12 +456,16 @@ HRESULT WINAPI D3DXCompileShaderFromFileW(const WCHAR *filename, const D3DXMACRO
|
|||
filename_len = WideCharToMultiByte(CP_ACP, 0, filename, -1, NULL, 0, NULL, NULL);
|
||||
filename_a = HeapAlloc(GetProcessHeap(), 0, filename_len * sizeof(char));
|
||||
if (!filename_a)
|
||||
{
|
||||
UnmapViewOfFile(buffer);
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
WideCharToMultiByte(CP_ACP, 0, filename, -1, filename_a, filename_len, NULL, NULL);
|
||||
|
||||
hr = ID3DXInclude_Open(include, D3D_INCLUDE_LOCAL, filename_a, NULL, &buffer, &len);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, filename_a);
|
||||
return D3DXERR_INVALIDDATA;
|
||||
}
|
||||
|
||||
hr = D3DCompile(buffer, len, filename_a, (const D3D_SHADER_MACRO *)defines,
|
||||
(ID3DInclude *)include, entrypoint, profile, flags, 0,
|
||||
(ID3DBlob **)shader, (ID3DBlob **)error_messages);
|
||||
|
@ -429,8 +474,8 @@ HRESULT WINAPI D3DXCompileShaderFromFileW(const WCHAR *filename, const D3DXMACRO
|
|||
hr = D3DXGetShaderConstantTable(ID3DXBuffer_GetBufferPointer(*shader),
|
||||
constant_table);
|
||||
|
||||
ID3DXInclude_Close(include, buffer);
|
||||
HeapFree(GetProcessHeap(), 0, filename_a);
|
||||
UnmapViewOfFile(buffer);
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
@ -442,7 +487,12 @@ HRESULT WINAPI D3DXCompileShaderFromResourceA(HMODULE module, const char *resour
|
|||
HRSRC res;
|
||||
DWORD len;
|
||||
|
||||
if (!(res = FindResourceA(module, resource, (LPCSTR)RT_RCDATA)))
|
||||
TRACE("module %p, resource %s, defines %p, include %p, entrypoint %s, profile %s, "
|
||||
"flags %#x, shader %p, error_messages %p, constant_table %p.\n",
|
||||
module, debugstr_a(resource), defines, include, debugstr_a(entrypoint), debugstr_a(profile),
|
||||
flags, shader, error_messages, constant_table);
|
||||
|
||||
if (!(res = FindResourceA(module, resource, (const char *)RT_RCDATA)))
|
||||
return D3DXERR_INVALIDDATA;
|
||||
if (FAILED(load_resource_into_memory(module, res, &buffer, &len)))
|
||||
return D3DXERR_INVALIDDATA;
|
||||
|
@ -474,7 +524,9 @@ HRESULT WINAPI D3DXCompileShaderFromResourceW(HMODULE module, const WCHAR *resou
|
|||
HRESULT WINAPI D3DXPreprocessShader(const char *data, UINT data_len, const D3DXMACRO *defines,
|
||||
ID3DXInclude *include, ID3DXBuffer **shader, ID3DXBuffer **error_messages)
|
||||
{
|
||||
TRACE("Forward to D3DPreprocess\n");
|
||||
TRACE("data %s, data_len %u, defines %p, include %p, shader %p, error_messages %p.\n",
|
||||
debugstr_a(data), data_len, defines, include, shader, error_messages);
|
||||
|
||||
return D3DPreprocess(data, data_len, NULL,
|
||||
(const D3D_SHADER_MACRO *)defines, (ID3DInclude *)include,
|
||||
(ID3DBlob **)shader, (ID3DBlob **)error_messages);
|
||||
|
@ -487,6 +539,9 @@ HRESULT WINAPI D3DXPreprocessShaderFromFileA(const char *filename, const D3DXMAC
|
|||
DWORD len;
|
||||
HRESULT ret;
|
||||
|
||||
TRACE("filename %s, defines %p, include %p, shader %p, error_messages %p.\n",
|
||||
debugstr_a(filename), defines, include, shader, error_messages);
|
||||
|
||||
if (!filename) return D3DXERR_INVALIDDATA;
|
||||
|
||||
len = MultiByteToWideChar(CP_ACP, 0, filename, -1, NULL, 0);
|
||||
|
@ -503,13 +558,14 @@ HRESULT WINAPI D3DXPreprocessShaderFromFileA(const char *filename, const D3DXMAC
|
|||
HRESULT WINAPI D3DXPreprocessShaderFromFileW(const WCHAR *filename, const D3DXMACRO *defines,
|
||||
ID3DXInclude *include, ID3DXBuffer **shader, ID3DXBuffer **error_messages)
|
||||
{
|
||||
void *buffer;
|
||||
const void *buffer;
|
||||
DWORD len;
|
||||
HRESULT hr;
|
||||
struct D3DXIncludeImpl includefromfile;
|
||||
char *filename_a;
|
||||
|
||||
if (FAILED(map_view_of_file(filename, &buffer, &len)))
|
||||
return D3DXERR_INVALIDDATA;
|
||||
TRACE("filename %s, defines %p, include %p, shader %p, error_messages %p.\n",
|
||||
debugstr_w(filename), defines, include, shader, error_messages);
|
||||
|
||||
if (!include)
|
||||
{
|
||||
|
@ -517,12 +573,26 @@ HRESULT WINAPI D3DXPreprocessShaderFromFileW(const WCHAR *filename, const D3DXMA
|
|||
include = &includefromfile.ID3DXInclude_iface;
|
||||
}
|
||||
|
||||
len = WideCharToMultiByte(CP_ACP, 0, filename, -1, NULL, 0, NULL, NULL);
|
||||
filename_a = HeapAlloc(GetProcessHeap(), 0, len * sizeof(char));
|
||||
if (!filename_a)
|
||||
return E_OUTOFMEMORY;
|
||||
WideCharToMultiByte(CP_ACP, 0, filename, -1, filename_a, len, NULL, NULL);
|
||||
|
||||
hr = ID3DXInclude_Open(include, D3D_INCLUDE_LOCAL, filename_a, NULL, &buffer, &len);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, filename_a);
|
||||
return D3DXERR_INVALIDDATA;
|
||||
}
|
||||
|
||||
hr = D3DPreprocess(buffer, len, NULL,
|
||||
(const D3D_SHADER_MACRO *)defines,
|
||||
(ID3DInclude *) include,
|
||||
(ID3DBlob **)shader, (ID3DBlob **)error_messages);
|
||||
|
||||
UnmapViewOfFile(buffer);
|
||||
ID3DXInclude_Close(include, buffer);
|
||||
HeapFree(GetProcessHeap(), 0, filename_a);
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
@ -533,7 +603,10 @@ HRESULT WINAPI D3DXPreprocessShaderFromResourceA(HMODULE module, const char *res
|
|||
HRSRC res;
|
||||
DWORD len;
|
||||
|
||||
if (!(res = FindResourceA(module, resource, (LPCSTR)RT_RCDATA)))
|
||||
TRACE("module %p, resource %s, defines %p, include %p, shader %p, error_messages %p.\n",
|
||||
module, debugstr_a(resource), defines, include, shader, error_messages);
|
||||
|
||||
if (!(res = FindResourceA(module, resource, (const char *)RT_RCDATA)))
|
||||
return D3DXERR_INVALIDDATA;
|
||||
if (FAILED(load_resource_into_memory(module, res, &buffer, &len)))
|
||||
return D3DXERR_INVALIDDATA;
|
||||
|
@ -548,6 +621,9 @@ HRESULT WINAPI D3DXPreprocessShaderFromResourceW(HMODULE module, const WCHAR *re
|
|||
HRSRC res;
|
||||
DWORD len;
|
||||
|
||||
TRACE("module %p, resource %s, defines %p, include %p, shader %p, error_messages %p.\n",
|
||||
module, debugstr_w(resource), defines, include, shader, error_messages);
|
||||
|
||||
if (!(res = FindResourceW(module, resource, (const WCHAR *)RT_RCDATA)))
|
||||
return D3DXERR_INVALIDDATA;
|
||||
if (FAILED(load_resource_into_memory(module, res, &buffer, &len)))
|
||||
|
@ -615,12 +691,13 @@ static inline D3DXHANDLE handle_from_constant(struct ctab_constant *constant)
|
|||
return (D3DXHANDLE)constant;
|
||||
}
|
||||
|
||||
static struct ctab_constant *get_constant_by_name(struct ID3DXConstantTableImpl *, struct ctab_constant *, LPCSTR);
|
||||
static struct ctab_constant *get_constant_by_name(struct ID3DXConstantTableImpl *table,
|
||||
struct ctab_constant *constant, const char *name);
|
||||
|
||||
static struct ctab_constant *get_constant_element_by_name(struct ctab_constant *constant, LPCSTR name)
|
||||
static struct ctab_constant *get_constant_element_by_name(struct ctab_constant *constant, const char *name)
|
||||
{
|
||||
const char *part;
|
||||
UINT element;
|
||||
LPCSTR part;
|
||||
|
||||
TRACE("constant %p, name %s\n", constant, debugstr_a(name));
|
||||
|
||||
|
@ -656,11 +733,11 @@ static struct ctab_constant *get_constant_element_by_name(struct ctab_constant *
|
|||
}
|
||||
|
||||
static struct ctab_constant *get_constant_by_name(struct ID3DXConstantTableImpl *table,
|
||||
struct ctab_constant *constant, LPCSTR name)
|
||||
struct ctab_constant *constant, const char *name)
|
||||
{
|
||||
UINT i, count, length;
|
||||
struct ctab_constant *handles;
|
||||
LPCSTR part;
|
||||
const char *part;
|
||||
|
||||
TRACE("table %p, constant %p, name %s\n", table, constant, debugstr_a(name));
|
||||
|
||||
|
@ -788,13 +865,13 @@ static ULONG WINAPI ID3DXConstantTableImpl_Release(ID3DXConstantTable *iface)
|
|||
}
|
||||
|
||||
/*** ID3DXBuffer methods ***/
|
||||
static LPVOID WINAPI ID3DXConstantTableImpl_GetBufferPointer(ID3DXConstantTable *iface)
|
||||
static void * WINAPI ID3DXConstantTableImpl_GetBufferPointer(ID3DXConstantTable *iface)
|
||||
{
|
||||
struct ID3DXConstantTableImpl *This = impl_from_ID3DXConstantTable(iface);
|
||||
struct ID3DXConstantTableImpl *table = impl_from_ID3DXConstantTable(iface);
|
||||
|
||||
TRACE("(%p)->()\n", This);
|
||||
TRACE("iface %p.\n", iface);
|
||||
|
||||
return This->ctab;
|
||||
return table->ctab;
|
||||
}
|
||||
|
||||
static DWORD WINAPI ID3DXConstantTableImpl_GetBufferSize(ID3DXConstantTable *iface)
|
||||
|
@ -889,12 +966,13 @@ static D3DXHANDLE WINAPI ID3DXConstantTableImpl_GetConstant(ID3DXConstantTable *
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static D3DXHANDLE WINAPI ID3DXConstantTableImpl_GetConstantByName(ID3DXConstantTable *iface, D3DXHANDLE constant, LPCSTR name)
|
||||
static D3DXHANDLE WINAPI ID3DXConstantTableImpl_GetConstantByName(ID3DXConstantTable *iface,
|
||||
D3DXHANDLE constant, const char *name)
|
||||
{
|
||||
struct ID3DXConstantTableImpl *This = impl_from_ID3DXConstantTable(iface);
|
||||
struct ctab_constant *c = get_valid_constant(This, constant);
|
||||
|
||||
TRACE("(%p)->(%p, %s)\n", This, constant, name);
|
||||
TRACE("iface %p, constant %p, name %s.\n", iface, constant, debugstr_a(name));
|
||||
|
||||
c = get_constant_by_name(This, c, name);
|
||||
TRACE("Returning constant %p\n", c);
|
||||
|
@ -939,7 +1017,7 @@ static UINT set(struct ID3DXConstantTableImpl *table, IDirect3DDevice9 *device,
|
|||
UINT l, i, regcount = 1, regsize = 1, cin = 1, rin = 1, ret, last = 0;
|
||||
DWORD tmp;
|
||||
|
||||
/* size to small to set anything */
|
||||
/* size too small to set anything */
|
||||
if (*size < desc->Rows * desc->Columns)
|
||||
{
|
||||
*size = 0;
|
||||
|
@ -1059,7 +1137,7 @@ static UINT set(struct ID3DXConstantTableImpl *table, IDirect3DDevice9 *device,
|
|||
break;
|
||||
|
||||
case D3DXPC_MATRIX_COLUMNS:
|
||||
regcount = desc->Columns;
|
||||
regcount = min(desc->RegisterCount, desc->Columns);
|
||||
if (inclass == D3DXPC_MATRIX_ROWS) rin = incol;
|
||||
else cin = incol;
|
||||
regsize = desc->Rows;
|
||||
|
@ -1685,7 +1763,7 @@ static const struct ID3DXConstantTableVtbl ID3DXConstantTable_Vtbl =
|
|||
};
|
||||
|
||||
static HRESULT parse_ctab_constant_type(const char *ctab, DWORD typeoffset, struct ctab_constant *constant,
|
||||
BOOL is_element, WORD index, WORD max, DWORD *offset, DWORD nameoffset, UINT regset)
|
||||
BOOL is_element, WORD index, WORD max_index, DWORD *offset, DWORD nameoffset, UINT regset)
|
||||
{
|
||||
const D3DXSHADER_TYPEINFO *type = (LPD3DXSHADER_TYPEINFO)(ctab + typeoffset);
|
||||
const D3DXSHADER_STRUCTMEMBERINFO *memberinfo = NULL;
|
||||
|
@ -1734,7 +1812,7 @@ static HRESULT parse_ctab_constant_type(const char *ctab, DWORD typeoffset, stru
|
|||
for (i = 0; i < count; ++i)
|
||||
{
|
||||
hr = parse_ctab_constant_type(ctab, memberinfo ? memberinfo[i].TypeInfo : typeoffset,
|
||||
&constant->constants[i], memberinfo == NULL, index + size, max, offset,
|
||||
&constant->constants[i], memberinfo == NULL, index + size, max_index, offset,
|
||||
memberinfo ? memberinfo[i].Name : nameoffset, regset);
|
||||
if (hr != D3D_OK)
|
||||
goto error;
|
||||
|
@ -1769,7 +1847,7 @@ static HRESULT parse_ctab_constant_type(const char *ctab, DWORD typeoffset, stru
|
|||
|
||||
case D3DXPC_MATRIX_ROWS:
|
||||
offsetdiff = type->Rows * 4;
|
||||
size = is_element ? type->Rows : max(type->Rows, type->Columns);
|
||||
size = type->Rows;
|
||||
break;
|
||||
|
||||
case D3DXPC_MATRIX_COLUMNS:
|
||||
|
@ -1803,7 +1881,7 @@ static HRESULT parse_ctab_constant_type(const char *ctab, DWORD typeoffset, stru
|
|||
if (offset) *offset += offsetdiff * 4;
|
||||
}
|
||||
|
||||
constant->desc.RegisterCount = max(0, min(max - index, size));
|
||||
constant->desc.RegisterCount = max(0, min(max_index - index, size));
|
||||
constant->desc.Bytes = 4 * constant->desc.Elements * type->Rows * type->Columns;
|
||||
|
||||
return D3D_OK;
|
||||
|
@ -1825,8 +1903,8 @@ error:
|
|||
HRESULT WINAPI D3DXGetShaderConstantTableEx(const DWORD *byte_code, DWORD flags, ID3DXConstantTable **constant_table)
|
||||
{
|
||||
struct ID3DXConstantTableImpl *object = NULL;
|
||||
const void *data;
|
||||
HRESULT hr;
|
||||
LPCVOID data;
|
||||
UINT size;
|
||||
const D3DXSHADER_CONSTANTTABLE *ctab_header;
|
||||
const D3DXSHADER_CONSTANTINFO *constant_info;
|
||||
|
|
|
@ -29,7 +29,7 @@ struct bone
|
|||
FLOAT *weights;
|
||||
};
|
||||
|
||||
typedef struct ID3DXSkinInfoImpl
|
||||
struct d3dx9_skin_info
|
||||
{
|
||||
ID3DXSkinInfo ID3DXSkinInfo_iface;
|
||||
LONG ref;
|
||||
|
@ -39,21 +39,21 @@ typedef struct ID3DXSkinInfoImpl
|
|||
DWORD num_vertices;
|
||||
DWORD num_bones;
|
||||
struct bone *bones;
|
||||
} ID3DXSkinInfoImpl;
|
||||
};
|
||||
|
||||
static inline struct ID3DXSkinInfoImpl *impl_from_ID3DXSkinInfo(ID3DXSkinInfo *iface)
|
||||
static inline struct d3dx9_skin_info *impl_from_ID3DXSkinInfo(ID3DXSkinInfo *iface)
|
||||
{
|
||||
return CONTAINING_RECORD(iface, struct ID3DXSkinInfoImpl, ID3DXSkinInfo_iface);
|
||||
return CONTAINING_RECORD(iface, struct d3dx9_skin_info, ID3DXSkinInfo_iface);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ID3DXSkinInfoImpl_QueryInterface(ID3DXSkinInfo *iface, REFIID riid, void **ppobj)
|
||||
static HRESULT WINAPI d3dx9_skin_info_QueryInterface(ID3DXSkinInfo *iface, REFIID riid, void **out)
|
||||
{
|
||||
TRACE("(%p, %s, %p)\n", iface, debugstr_guid(riid), ppobj);
|
||||
TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
|
||||
|
||||
if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_ID3DXSkinInfo))
|
||||
{
|
||||
IUnknown_AddRef(iface);
|
||||
*ppobj = iface;
|
||||
*out = iface;
|
||||
return D3D_OK;
|
||||
}
|
||||
|
||||
|
@ -62,47 +62,52 @@ static HRESULT WINAPI ID3DXSkinInfoImpl_QueryInterface(ID3DXSkinInfo *iface, REF
|
|||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
static ULONG WINAPI ID3DXSkinInfoImpl_AddRef(ID3DXSkinInfo *iface)
|
||||
static ULONG WINAPI d3dx9_skin_info_AddRef(ID3DXSkinInfo *iface)
|
||||
{
|
||||
struct ID3DXSkinInfoImpl *This = impl_from_ID3DXSkinInfo(iface);
|
||||
ULONG ref = InterlockedIncrement(&This->ref);
|
||||
struct d3dx9_skin_info *skin = impl_from_ID3DXSkinInfo(iface);
|
||||
ULONG refcount = InterlockedIncrement(&skin->ref);
|
||||
|
||||
TRACE("%p increasing refcount to %u\n", This, ref);
|
||||
TRACE("%p increasing refcount to %u.\n", skin, refcount);
|
||||
|
||||
return ref;
|
||||
return refcount;
|
||||
}
|
||||
|
||||
static ULONG WINAPI ID3DXSkinInfoImpl_Release(ID3DXSkinInfo *iface)
|
||||
static ULONG WINAPI d3dx9_skin_info_Release(ID3DXSkinInfo *iface)
|
||||
{
|
||||
struct ID3DXSkinInfoImpl *This = impl_from_ID3DXSkinInfo(iface);
|
||||
ULONG ref = InterlockedDecrement(&This->ref);
|
||||
struct d3dx9_skin_info *skin = impl_from_ID3DXSkinInfo(iface);
|
||||
ULONG refcount = InterlockedDecrement(&skin->ref);
|
||||
|
||||
TRACE("%p decreasing refcount to %u\n", This, ref);
|
||||
TRACE("%p decreasing refcount to %u.\n", skin, refcount);
|
||||
|
||||
if (ref == 0) {
|
||||
if (!refcount)
|
||||
{
|
||||
DWORD i;
|
||||
for (i = 0; i < This->num_bones; i++) {
|
||||
HeapFree(GetProcessHeap(), 0, This->bones[i].name);
|
||||
HeapFree(GetProcessHeap(), 0, This->bones[i].vertices);
|
||||
HeapFree(GetProcessHeap(), 0, This->bones[i].weights);
|
||||
|
||||
for (i = 0; i < skin->num_bones; ++i)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, skin->bones[i].name);
|
||||
HeapFree(GetProcessHeap(), 0, skin->bones[i].vertices);
|
||||
HeapFree(GetProcessHeap(), 0, skin->bones[i].weights);
|
||||
}
|
||||
HeapFree(GetProcessHeap(), 0, This->bones);
|
||||
HeapFree(GetProcessHeap(), 0, This);
|
||||
HeapFree(GetProcessHeap(), 0, skin->bones);
|
||||
HeapFree(GetProcessHeap(), 0, skin);
|
||||
}
|
||||
|
||||
return ref;
|
||||
return refcount;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ID3DXSkinInfoImpl_SetBoneInfluence(ID3DXSkinInfo *iface, DWORD bone_num, DWORD num_influences, CONST DWORD *vertices, CONST FLOAT *weights)
|
||||
static HRESULT WINAPI d3dx9_skin_info_SetBoneInfluence(ID3DXSkinInfo *iface,
|
||||
DWORD bone_num, DWORD num_influences, const DWORD *vertices, const float *weights)
|
||||
{
|
||||
ID3DXSkinInfoImpl *This = impl_from_ID3DXSkinInfo(iface);
|
||||
struct d3dx9_skin_info *skin = impl_from_ID3DXSkinInfo(iface);
|
||||
struct bone *bone;
|
||||
DWORD *new_vertices = NULL;
|
||||
FLOAT *new_weights = NULL;
|
||||
|
||||
TRACE("(%p, %u, %u, %p, %p)\n", This, bone_num, num_influences, vertices, weights);
|
||||
TRACE("iface %p, bone_num %u, num_influences %u, vertices %p, weights %p.\n",
|
||||
iface, bone_num, num_influences, vertices, weights);
|
||||
|
||||
if (bone_num >= This->num_bones || !vertices || !weights)
|
||||
if (bone_num >= skin->num_bones || !vertices || !weights)
|
||||
return D3DERR_INVALIDCALL;
|
||||
|
||||
if (num_influences) {
|
||||
|
@ -117,7 +122,7 @@ static HRESULT WINAPI ID3DXSkinInfoImpl_SetBoneInfluence(ID3DXSkinInfo *iface, D
|
|||
memcpy(new_vertices, vertices, num_influences * sizeof(*vertices));
|
||||
memcpy(new_weights, weights, num_influences * sizeof(*weights));
|
||||
}
|
||||
bone = &This->bones[bone_num];
|
||||
bone = &skin->bones[bone_num];
|
||||
bone->num_influences = num_influences;
|
||||
HeapFree(GetProcessHeap(), 0, bone->vertices);
|
||||
HeapFree(GetProcessHeap(), 0, bone->weights);
|
||||
|
@ -127,38 +132,40 @@ static HRESULT WINAPI ID3DXSkinInfoImpl_SetBoneInfluence(ID3DXSkinInfo *iface, D
|
|||
return D3D_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ID3DXSkinInfoImpl_SetBoneVertexInfluence(ID3DXSkinInfo *iface, DWORD bone_num, DWORD influence_num, float weight)
|
||||
static HRESULT WINAPI d3dx9_skin_info_SetBoneVertexInfluence(ID3DXSkinInfo *iface,
|
||||
DWORD bone_num, DWORD influence_num, float weight)
|
||||
{
|
||||
ID3DXSkinInfoImpl *This = impl_from_ID3DXSkinInfo(iface);
|
||||
|
||||
FIXME("(%p, %u, %u, %g): stub\n", This, bone_num, influence_num, weight);
|
||||
FIXME("iface %p, bone_num %u, influence_num %u, weight %.8e stub!\n",
|
||||
iface, bone_num, influence_num, weight);
|
||||
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static DWORD WINAPI ID3DXSkinInfoImpl_GetNumBoneInfluences(ID3DXSkinInfo *iface, DWORD bone_num)
|
||||
static DWORD WINAPI d3dx9_skin_info_GetNumBoneInfluences(ID3DXSkinInfo *iface, DWORD bone_num)
|
||||
{
|
||||
ID3DXSkinInfoImpl *This = impl_from_ID3DXSkinInfo(iface);
|
||||
struct d3dx9_skin_info *skin = impl_from_ID3DXSkinInfo(iface);
|
||||
|
||||
TRACE("(%p, %u)\n", This, bone_num);
|
||||
TRACE("iface %p, bone_num %u.\n", iface, bone_num);
|
||||
|
||||
if (bone_num >= This->num_bones)
|
||||
if (bone_num >= skin->num_bones)
|
||||
return 0;
|
||||
|
||||
return This->bones[bone_num].num_influences;
|
||||
return skin->bones[bone_num].num_influences;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ID3DXSkinInfoImpl_GetBoneInfluence(ID3DXSkinInfo *iface, DWORD bone_num, DWORD *vertices, FLOAT *weights)
|
||||
static HRESULT WINAPI d3dx9_skin_info_GetBoneInfluence(ID3DXSkinInfo *iface,
|
||||
DWORD bone_num, DWORD *vertices, float *weights)
|
||||
{
|
||||
ID3DXSkinInfoImpl *This = impl_from_ID3DXSkinInfo(iface);
|
||||
struct d3dx9_skin_info *skin = impl_from_ID3DXSkinInfo(iface);
|
||||
struct bone *bone;
|
||||
|
||||
TRACE("(%p, %u, %p, %p)\n", This, bone_num, vertices, weights);
|
||||
TRACE("iface %p, bone_num %u, vertices %p, weights %p.\n",
|
||||
iface, bone_num, vertices, weights);
|
||||
|
||||
if (bone_num >= This->num_bones || !vertices)
|
||||
if (bone_num >= skin->num_bones || !vertices)
|
||||
return D3DERR_INVALIDCALL;
|
||||
|
||||
bone = &This->bones[bone_num];
|
||||
bone = &skin->bones[bone_num];
|
||||
if (!bone->num_influences)
|
||||
return D3D_OK;
|
||||
|
||||
|
@ -169,81 +176,72 @@ static HRESULT WINAPI ID3DXSkinInfoImpl_GetBoneInfluence(ID3DXSkinInfo *iface, D
|
|||
return D3D_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ID3DXSkinInfoImpl_GetBoneVertexInfluence(ID3DXSkinInfo *iface, DWORD bone_num,
|
||||
DWORD influence_num, float *weight, DWORD *vertex_num)
|
||||
static HRESULT WINAPI d3dx9_skin_info_GetBoneVertexInfluence(ID3DXSkinInfo *iface,
|
||||
DWORD bone_num, DWORD influence_num, float *weight, DWORD *vertex_num)
|
||||
{
|
||||
ID3DXSkinInfoImpl *This = impl_from_ID3DXSkinInfo(iface);
|
||||
|
||||
FIXME("(%p, %u, %u, %p, %p): stub\n", This, bone_num, influence_num, weight, vertex_num);
|
||||
FIXME("iface %p, bone_num %u, influence_num %u, weight %p, vertex_num %p stub!\n",
|
||||
iface, bone_num, influence_num, weight, vertex_num);
|
||||
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ID3DXSkinInfoImpl_GetMaxVertexInfluences(ID3DXSkinInfo *iface, DWORD *max_vertex_influences)
|
||||
static HRESULT WINAPI d3dx9_skin_info_GetMaxVertexInfluences(ID3DXSkinInfo *iface, DWORD *max_vertex_influences)
|
||||
{
|
||||
ID3DXSkinInfoImpl *This = impl_from_ID3DXSkinInfo(iface);
|
||||
|
||||
FIXME("(%p, %p): stub\n", This, max_vertex_influences);
|
||||
FIXME("iface %p, max_vertex_influences %p stub!\n", iface, max_vertex_influences);
|
||||
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static DWORD WINAPI ID3DXSkinInfoImpl_GetNumBones(ID3DXSkinInfo *iface)
|
||||
static DWORD WINAPI d3dx9_skin_info_GetNumBones(ID3DXSkinInfo *iface)
|
||||
{
|
||||
ID3DXSkinInfoImpl *This = impl_from_ID3DXSkinInfo(iface);
|
||||
struct d3dx9_skin_info *skin = impl_from_ID3DXSkinInfo(iface);
|
||||
|
||||
TRACE("(%p)\n", This);
|
||||
TRACE("iface %p.\n", iface);
|
||||
|
||||
return This->num_bones;
|
||||
return skin->num_bones;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ID3DXSkinInfoImpl_FindBoneVertexInfluenceIndex(ID3DXSkinInfo *iface, DWORD bone_num,
|
||||
DWORD vertex_num, DWORD *influence_index)
|
||||
static HRESULT WINAPI d3dx9_skin_info_FindBoneVertexInfluenceIndex(ID3DXSkinInfo *iface,
|
||||
DWORD bone_num, DWORD vertex_num, DWORD *influence_index)
|
||||
{
|
||||
ID3DXSkinInfoImpl *This = impl_from_ID3DXSkinInfo(iface);
|
||||
|
||||
FIXME("(%p, %u, %u, %p): stub\n", This, bone_num, vertex_num, influence_index);
|
||||
FIXME("iface %p, bone_num %u, vertex_num %u, influence_index %p stub!\n",
|
||||
iface, bone_num, vertex_num, influence_index);
|
||||
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ID3DXSkinInfoImpl_GetMaxFaceInfluences(struct ID3DXSkinInfo *iface,
|
||||
static HRESULT WINAPI d3dx9_skin_info_GetMaxFaceInfluences(struct ID3DXSkinInfo *iface,
|
||||
struct IDirect3DIndexBuffer9 *index_buffer, DWORD num_faces, DWORD *max_face_influences)
|
||||
{
|
||||
ID3DXSkinInfoImpl *This = impl_from_ID3DXSkinInfo(iface);
|
||||
|
||||
FIXME("(%p, %p, %u, %p): stub\n", This, index_buffer, num_faces, max_face_influences);
|
||||
FIXME("iface %p, index_buffer %p, num_faces %u, max_face_influences %p stub!\n",
|
||||
iface, index_buffer, num_faces, max_face_influences);
|
||||
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ID3DXSkinInfoImpl_SetMinBoneInfluence(ID3DXSkinInfo *iface, FLOAT min_influence)
|
||||
static HRESULT WINAPI d3dx9_skin_info_SetMinBoneInfluence(ID3DXSkinInfo *iface, float min_influence)
|
||||
{
|
||||
ID3DXSkinInfoImpl *This = impl_from_ID3DXSkinInfo(iface);
|
||||
|
||||
FIXME("(%p, %g): stub\n", This, min_influence);
|
||||
FIXME("iface %p, min_influence %.8e stub!\n", iface, min_influence);
|
||||
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static FLOAT WINAPI ID3DXSkinInfoImpl_GetMinBoneInfluence(ID3DXSkinInfo *iface)
|
||||
static float WINAPI d3dx9_skin_info_GetMinBoneInfluence(ID3DXSkinInfo *iface)
|
||||
{
|
||||
ID3DXSkinInfoImpl *This = impl_from_ID3DXSkinInfo(iface);
|
||||
|
||||
FIXME("(%p): stub\n", This);
|
||||
FIXME("iface %p stub!\n", iface);
|
||||
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ID3DXSkinInfoImpl_SetBoneName(ID3DXSkinInfo *iface, DWORD bone_num, LPCSTR name)
|
||||
static HRESULT WINAPI d3dx9_skin_info_SetBoneName(ID3DXSkinInfo *iface, DWORD bone_idx, const char *name)
|
||||
{
|
||||
ID3DXSkinInfoImpl *This = impl_from_ID3DXSkinInfo(iface);
|
||||
struct d3dx9_skin_info *skin = impl_from_ID3DXSkinInfo(iface);
|
||||
char *new_name;
|
||||
size_t size;
|
||||
|
||||
TRACE("(%p, %u, %s)\n", This, bone_num, debugstr_a(name));
|
||||
TRACE("iface %p, bone_idx %u, name %s.\n", iface, bone_idx, debugstr_a(name));
|
||||
|
||||
if (bone_num >= This->num_bones || !name)
|
||||
if (bone_idx >= skin->num_bones || !name)
|
||||
return D3DERR_INVALIDCALL;
|
||||
|
||||
size = strlen(name) + 1;
|
||||
|
@ -251,74 +249,70 @@ static HRESULT WINAPI ID3DXSkinInfoImpl_SetBoneName(ID3DXSkinInfo *iface, DWORD
|
|||
if (!new_name)
|
||||
return E_OUTOFMEMORY;
|
||||
memcpy(new_name, name, size);
|
||||
HeapFree(GetProcessHeap(), 0, This->bones[bone_num].name);
|
||||
This->bones[bone_num].name = new_name;
|
||||
HeapFree(GetProcessHeap(), 0, skin->bones[bone_idx].name);
|
||||
skin->bones[bone_idx].name = new_name;
|
||||
|
||||
return D3D_OK;
|
||||
}
|
||||
|
||||
static LPCSTR WINAPI ID3DXSkinInfoImpl_GetBoneName(ID3DXSkinInfo *iface, DWORD bone_num)
|
||||
static const char * WINAPI d3dx9_skin_info_GetBoneName(ID3DXSkinInfo *iface, DWORD bone_idx)
|
||||
{
|
||||
ID3DXSkinInfoImpl *This = impl_from_ID3DXSkinInfo(iface);
|
||||
struct d3dx9_skin_info *skin = impl_from_ID3DXSkinInfo(iface);
|
||||
|
||||
TRACE("(%p, %u)\n", This, bone_num);
|
||||
TRACE("iface %p, bone_idx %u.\n", iface, bone_idx);
|
||||
|
||||
if (bone_num >= This->num_bones)
|
||||
if (bone_idx >= skin->num_bones)
|
||||
return NULL;
|
||||
|
||||
return This->bones[bone_num].name;
|
||||
return skin->bones[bone_idx].name;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ID3DXSkinInfoImpl_SetBoneOffsetMatrix(ID3DXSkinInfo *iface, DWORD bone_num, CONST D3DXMATRIX *bone_transform)
|
||||
static HRESULT WINAPI d3dx9_skin_info_SetBoneOffsetMatrix(ID3DXSkinInfo *iface,
|
||||
DWORD bone_num, const D3DXMATRIX *bone_transform)
|
||||
{
|
||||
ID3DXSkinInfoImpl *This = impl_from_ID3DXSkinInfo(iface);
|
||||
struct d3dx9_skin_info *skin = impl_from_ID3DXSkinInfo(iface);
|
||||
|
||||
TRACE("(%p, %u, %p)\n", This, bone_num, bone_transform);
|
||||
TRACE("iface %p, bone_num %u, bone_transform %p.\n", iface, bone_num, bone_transform);
|
||||
|
||||
if (bone_num >= This->num_bones || !bone_transform)
|
||||
if (bone_num >= skin->num_bones || !bone_transform)
|
||||
return D3DERR_INVALIDCALL;
|
||||
|
||||
This->bones[bone_num].transform = *bone_transform;
|
||||
skin->bones[bone_num].transform = *bone_transform;
|
||||
return D3D_OK;
|
||||
}
|
||||
|
||||
static D3DXMATRIX * WINAPI ID3DXSkinInfoImpl_GetBoneOffsetMatrix(ID3DXSkinInfo *iface, DWORD bone_num)
|
||||
static D3DXMATRIX * WINAPI d3dx9_skin_info_GetBoneOffsetMatrix(ID3DXSkinInfo *iface, DWORD bone_num)
|
||||
{
|
||||
ID3DXSkinInfoImpl *This = impl_from_ID3DXSkinInfo(iface);
|
||||
struct d3dx9_skin_info *skin = impl_from_ID3DXSkinInfo(iface);
|
||||
|
||||
TRACE("(%p, %u)\n", This, bone_num);
|
||||
TRACE("iface %p, bone_num %u.\n", iface, bone_num);
|
||||
|
||||
if (bone_num >= This->num_bones)
|
||||
if (bone_num >= skin->num_bones)
|
||||
return NULL;
|
||||
|
||||
return &This->bones[bone_num].transform;
|
||||
return &skin->bones[bone_num].transform;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ID3DXSkinInfoImpl_Clone(ID3DXSkinInfo *iface, ID3DXSkinInfo **skin_info)
|
||||
static HRESULT WINAPI d3dx9_skin_info_Clone(ID3DXSkinInfo *iface, ID3DXSkinInfo **skin_info)
|
||||
{
|
||||
ID3DXSkinInfoImpl *This = impl_from_ID3DXSkinInfo(iface);
|
||||
|
||||
FIXME("(%p, %p): stub\n", This, skin_info);
|
||||
FIXME("iface %p, skin_info %p stub!\n", iface, skin_info);
|
||||
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ID3DXSkinInfoImpl_Remap(ID3DXSkinInfo *iface, DWORD num_vertices, DWORD *vertex_remap)
|
||||
static HRESULT WINAPI d3dx9_skin_info_Remap(ID3DXSkinInfo *iface, DWORD num_vertices, DWORD *vertex_remap)
|
||||
{
|
||||
ID3DXSkinInfoImpl *This = impl_from_ID3DXSkinInfo(iface);
|
||||
|
||||
FIXME("(%p, %u, %p): stub\n", This, num_vertices, vertex_remap);
|
||||
FIXME("iface %p, num_vertices %u, vertex_remap %p stub!\n", iface, num_vertices, vertex_remap);
|
||||
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ID3DXSkinInfoImpl_SetFVF(ID3DXSkinInfo *iface, DWORD fvf)
|
||||
static HRESULT WINAPI d3dx9_skin_info_SetFVF(ID3DXSkinInfo *iface, DWORD fvf)
|
||||
{
|
||||
ID3DXSkinInfoImpl *This = impl_from_ID3DXSkinInfo(iface);
|
||||
HRESULT hr;
|
||||
D3DVERTEXELEMENT9 declaration[MAX_FVF_DECL_SIZE];
|
||||
|
||||
TRACE("(%p, %x)\n", This, fvf);
|
||||
TRACE("iface %p, fvf %#x.\n", iface, fvf);
|
||||
|
||||
hr = D3DXDeclaratorFromFVF(fvf, declaration);
|
||||
if (FAILED(hr)) return hr;
|
||||
|
@ -326,13 +320,13 @@ static HRESULT WINAPI ID3DXSkinInfoImpl_SetFVF(ID3DXSkinInfo *iface, DWORD fvf)
|
|||
return iface->lpVtbl->SetDeclaration(iface, declaration);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ID3DXSkinInfoImpl_SetDeclaration(ID3DXSkinInfo *iface, CONST D3DVERTEXELEMENT9 *declaration)
|
||||
static HRESULT WINAPI d3dx9_skin_info_SetDeclaration(ID3DXSkinInfo *iface, const D3DVERTEXELEMENT9 *declaration)
|
||||
{
|
||||
ID3DXSkinInfoImpl *This = impl_from_ID3DXSkinInfo(iface);
|
||||
struct d3dx9_skin_info *skin = impl_from_ID3DXSkinInfo(iface);
|
||||
HRESULT hr;
|
||||
int count;
|
||||
|
||||
TRACE("(%p, %p)\n", This, declaration);
|
||||
TRACE("iface %p, declaration %p.\n", iface, declaration);
|
||||
|
||||
if (!declaration)
|
||||
return D3DERR_INVALIDCALL;
|
||||
|
@ -345,115 +339,111 @@ static HRESULT WINAPI ID3DXSkinInfoImpl_SetDeclaration(ID3DXSkinInfo *iface, CON
|
|||
}
|
||||
count++;
|
||||
|
||||
memcpy(This->vertex_declaration, declaration, count * sizeof(*declaration));
|
||||
memcpy(skin->vertex_declaration, declaration, count * sizeof(*declaration));
|
||||
|
||||
hr = D3DXFVFFromDeclarator(This->vertex_declaration, &This->fvf);
|
||||
if (FAILED(hr))
|
||||
This->fvf = 0;
|
||||
if (FAILED(hr = D3DXFVFFromDeclarator(skin->vertex_declaration, &skin->fvf)))
|
||||
skin->fvf = 0;
|
||||
|
||||
return D3D_OK;
|
||||
}
|
||||
|
||||
static DWORD WINAPI ID3DXSkinInfoImpl_GetFVF(ID3DXSkinInfo *iface)
|
||||
static DWORD WINAPI d3dx9_skin_info_GetFVF(ID3DXSkinInfo *iface)
|
||||
{
|
||||
ID3DXSkinInfoImpl *This = impl_from_ID3DXSkinInfo(iface);
|
||||
struct d3dx9_skin_info *skin = impl_from_ID3DXSkinInfo(iface);
|
||||
|
||||
TRACE("(%p)\n", This);
|
||||
TRACE("iface %p.\n", iface);
|
||||
|
||||
return This->fvf;
|
||||
return skin->fvf;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ID3DXSkinInfoImpl_GetDeclaration(ID3DXSkinInfo *iface, D3DVERTEXELEMENT9 declaration[MAX_FVF_DECL_SIZE])
|
||||
static HRESULT WINAPI d3dx9_skin_info_GetDeclaration(ID3DXSkinInfo *iface,
|
||||
D3DVERTEXELEMENT9 declaration[MAX_FVF_DECL_SIZE])
|
||||
{
|
||||
ID3DXSkinInfoImpl *This = impl_from_ID3DXSkinInfo(iface);
|
||||
struct d3dx9_skin_info *skin = impl_from_ID3DXSkinInfo(iface);
|
||||
UINT count = 0;
|
||||
|
||||
TRACE("(%p)\n", This);
|
||||
TRACE("iface %p, declaration %p.\n", iface, declaration);
|
||||
|
||||
while (This->vertex_declaration[count++].Stream != 0xff);
|
||||
memcpy(declaration, This->vertex_declaration, count * sizeof(declaration[0]));
|
||||
while (skin->vertex_declaration[count++].Stream != 0xff);
|
||||
memcpy(declaration, skin->vertex_declaration, count * sizeof(declaration[0]));
|
||||
return D3D_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ID3DXSkinInfoImpl_UpdateSkinnedMesh(ID3DXSkinInfo *iface, CONST D3DXMATRIX *bone_transforms,
|
||||
CONST D3DXMATRIX *bone_inv_transpose_transforms, LPCVOID vertices_src, PVOID vertices_dest)
|
||||
static HRESULT WINAPI d3dx9_skin_info_UpdateSkinnedMesh(ID3DXSkinInfo *iface, const D3DXMATRIX *bone_transforms,
|
||||
const D3DXMATRIX *bone_inv_transpose_transforms, const void *src_vertices, void *dst_vertices)
|
||||
{
|
||||
ID3DXSkinInfoImpl *This = impl_from_ID3DXSkinInfo(iface);
|
||||
|
||||
FIXME("(%p, %p, %p, %p, %p): stub\n", This, bone_transforms, bone_inv_transpose_transforms, vertices_src, vertices_dest);
|
||||
FIXME("iface %p, bone_transforms %p, bone_inv_transpose_transforms %p, src_vertices %p, dst_vertices %p stub!\n",
|
||||
iface, bone_transforms, bone_inv_transpose_transforms, src_vertices, dst_vertices);
|
||||
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ID3DXSkinInfoImpl_ConvertToBlendedMesh(ID3DXSkinInfo *iface, ID3DXMesh *mesh_in,
|
||||
static HRESULT WINAPI d3dx9_skin_info_ConvertToBlendedMesh(ID3DXSkinInfo *iface, ID3DXMesh *mesh_in,
|
||||
DWORD options, const DWORD *adjacency_in, DWORD *adjacency_out, DWORD *face_remap,
|
||||
ID3DXBuffer **vertex_remap, DWORD *max_face_infl, DWORD *num_bone_combinations,
|
||||
ID3DXBuffer **bone_combination_table, ID3DXMesh **mesh_out)
|
||||
{
|
||||
ID3DXSkinInfoImpl *This = impl_from_ID3DXSkinInfo(iface);
|
||||
|
||||
FIXME("(%p, %p, %x, %p, %p, %p, %p, %p, %p, %p, %p): stub\n",
|
||||
This, mesh_in, options, adjacency_in, adjacency_out, face_remap, vertex_remap,
|
||||
max_face_infl, num_bone_combinations, bone_combination_table, mesh_out);
|
||||
FIXME("iface %p, mesh_in %p, options %#x, adjacency_in %p, adjacency_out %p, face_remap %p, vertex_remap %p, "
|
||||
"max_face_infl %p, num_bone_combinations %p, bone_combination_table %p, mesh_out %p stub!\n",
|
||||
iface, mesh_in, options, adjacency_in, adjacency_out, face_remap, vertex_remap,
|
||||
max_face_infl, num_bone_combinations, bone_combination_table, mesh_out);
|
||||
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ID3DXSkinInfoImpl_ConvertToIndexedBlendedMesh(ID3DXSkinInfo *iface, ID3DXMesh *mesh_in,
|
||||
static HRESULT WINAPI d3dx9_skin_info_ConvertToIndexedBlendedMesh(ID3DXSkinInfo *iface, ID3DXMesh *mesh_in,
|
||||
DWORD options, const DWORD *adjacency_in, DWORD *adjacency_out, DWORD *face_remap,
|
||||
ID3DXBuffer **vertex_remap, DWORD *max_face_infl, DWORD *num_bone_combinations,
|
||||
ID3DXBuffer **bone_combination_table, ID3DXMesh **mesh_out)
|
||||
{
|
||||
ID3DXSkinInfoImpl *This = impl_from_ID3DXSkinInfo(iface);
|
||||
|
||||
FIXME("(%p, %p, %x, %p, %p, %p, %p, %p, %p, %p, %p): stub\n",
|
||||
This, mesh_in, options, adjacency_in, adjacency_out, face_remap, vertex_remap,
|
||||
max_face_infl, num_bone_combinations, bone_combination_table, mesh_out);
|
||||
FIXME("iface %p, mesh_in %p, options %#x, adjacency_in %p, adjacency_out %p, face_remap %p, vertex_remap %p, "
|
||||
"max_face_infl %p, num_bone_combinations %p, bone_combination_table %p, mesh_out %p stub!\n",
|
||||
iface, mesh_in, options, adjacency_in, adjacency_out, face_remap, vertex_remap,
|
||||
max_face_infl, num_bone_combinations, bone_combination_table, mesh_out);
|
||||
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static const struct ID3DXSkinInfoVtbl ID3DXSkinInfoImpl_Vtbl =
|
||||
static const struct ID3DXSkinInfoVtbl d3dx9_skin_info_vtbl =
|
||||
{
|
||||
/* IUnknown methods */
|
||||
ID3DXSkinInfoImpl_QueryInterface,
|
||||
ID3DXSkinInfoImpl_AddRef,
|
||||
ID3DXSkinInfoImpl_Release,
|
||||
/* ID3DXSkinInfo */
|
||||
ID3DXSkinInfoImpl_SetBoneInfluence,
|
||||
ID3DXSkinInfoImpl_SetBoneVertexInfluence,
|
||||
ID3DXSkinInfoImpl_GetNumBoneInfluences,
|
||||
ID3DXSkinInfoImpl_GetBoneInfluence,
|
||||
ID3DXSkinInfoImpl_GetBoneVertexInfluence,
|
||||
ID3DXSkinInfoImpl_GetMaxVertexInfluences,
|
||||
ID3DXSkinInfoImpl_GetNumBones,
|
||||
ID3DXSkinInfoImpl_FindBoneVertexInfluenceIndex,
|
||||
ID3DXSkinInfoImpl_GetMaxFaceInfluences,
|
||||
ID3DXSkinInfoImpl_SetMinBoneInfluence,
|
||||
ID3DXSkinInfoImpl_GetMinBoneInfluence,
|
||||
ID3DXSkinInfoImpl_SetBoneName,
|
||||
ID3DXSkinInfoImpl_GetBoneName,
|
||||
ID3DXSkinInfoImpl_SetBoneOffsetMatrix,
|
||||
ID3DXSkinInfoImpl_GetBoneOffsetMatrix,
|
||||
ID3DXSkinInfoImpl_Clone,
|
||||
ID3DXSkinInfoImpl_Remap,
|
||||
ID3DXSkinInfoImpl_SetFVF,
|
||||
ID3DXSkinInfoImpl_SetDeclaration,
|
||||
ID3DXSkinInfoImpl_GetFVF,
|
||||
ID3DXSkinInfoImpl_GetDeclaration,
|
||||
ID3DXSkinInfoImpl_UpdateSkinnedMesh,
|
||||
ID3DXSkinInfoImpl_ConvertToBlendedMesh,
|
||||
ID3DXSkinInfoImpl_ConvertToIndexedBlendedMesh
|
||||
d3dx9_skin_info_QueryInterface,
|
||||
d3dx9_skin_info_AddRef,
|
||||
d3dx9_skin_info_Release,
|
||||
d3dx9_skin_info_SetBoneInfluence,
|
||||
d3dx9_skin_info_SetBoneVertexInfluence,
|
||||
d3dx9_skin_info_GetNumBoneInfluences,
|
||||
d3dx9_skin_info_GetBoneInfluence,
|
||||
d3dx9_skin_info_GetBoneVertexInfluence,
|
||||
d3dx9_skin_info_GetMaxVertexInfluences,
|
||||
d3dx9_skin_info_GetNumBones,
|
||||
d3dx9_skin_info_FindBoneVertexInfluenceIndex,
|
||||
d3dx9_skin_info_GetMaxFaceInfluences,
|
||||
d3dx9_skin_info_SetMinBoneInfluence,
|
||||
d3dx9_skin_info_GetMinBoneInfluence,
|
||||
d3dx9_skin_info_SetBoneName,
|
||||
d3dx9_skin_info_GetBoneName,
|
||||
d3dx9_skin_info_SetBoneOffsetMatrix,
|
||||
d3dx9_skin_info_GetBoneOffsetMatrix,
|
||||
d3dx9_skin_info_Clone,
|
||||
d3dx9_skin_info_Remap,
|
||||
d3dx9_skin_info_SetFVF,
|
||||
d3dx9_skin_info_SetDeclaration,
|
||||
d3dx9_skin_info_GetFVF,
|
||||
d3dx9_skin_info_GetDeclaration,
|
||||
d3dx9_skin_info_UpdateSkinnedMesh,
|
||||
d3dx9_skin_info_ConvertToBlendedMesh,
|
||||
d3dx9_skin_info_ConvertToIndexedBlendedMesh,
|
||||
};
|
||||
|
||||
HRESULT WINAPI D3DXCreateSkinInfo(DWORD num_vertices, const D3DVERTEXELEMENT9 *declaration,
|
||||
DWORD num_bones, ID3DXSkinInfo **skin_info)
|
||||
{
|
||||
HRESULT hr;
|
||||
ID3DXSkinInfoImpl *object = NULL;
|
||||
static const D3DVERTEXELEMENT9 empty_declaration = D3DDECL_END();
|
||||
struct d3dx9_skin_info *object = NULL;
|
||||
|
||||
TRACE("(%u, %p, %u, %p)\n", num_vertices, declaration, num_bones, skin_info);
|
||||
TRACE("num_vertices %u, declaration %p, num_bones %u, skin_info %p.\n",
|
||||
num_vertices, declaration, num_bones, skin_info);
|
||||
|
||||
if (!skin_info || !declaration)
|
||||
return D3DERR_INVALIDCALL;
|
||||
|
@ -462,7 +452,7 @@ HRESULT WINAPI D3DXCreateSkinInfo(DWORD num_vertices, const D3DVERTEXELEMENT9 *d
|
|||
if (!object)
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
object->ID3DXSkinInfo_iface.lpVtbl = &ID3DXSkinInfoImpl_Vtbl;
|
||||
object->ID3DXSkinInfo_iface.lpVtbl = &d3dx9_skin_info_vtbl;
|
||||
object->ref = 1;
|
||||
object->num_vertices = num_vertices;
|
||||
object->num_bones = num_bones;
|
||||
|
@ -475,8 +465,8 @@ HRESULT WINAPI D3DXCreateSkinInfo(DWORD num_vertices, const D3DVERTEXELEMENT9 *d
|
|||
goto error;
|
||||
}
|
||||
|
||||
hr = ID3DXSkinInfoImpl_SetDeclaration(&object->ID3DXSkinInfo_iface, declaration);
|
||||
if (FAILED(hr)) goto error;
|
||||
if (FAILED(hr = d3dx9_skin_info_SetDeclaration(&object->ID3DXSkinInfo_iface, declaration)))
|
||||
goto error;
|
||||
|
||||
*skin_info = &object->ID3DXSkinInfo_iface;
|
||||
|
||||
|
|
|
@ -22,13 +22,15 @@
|
|||
/* the combination of all possible D3DXSPRITE flags */
|
||||
#define D3DXSPRITE_FLAGLIMIT 511
|
||||
|
||||
typedef struct _SPRITEVERTEX {
|
||||
struct sprite_vertex
|
||||
{
|
||||
D3DXVECTOR3 pos;
|
||||
DWORD col;
|
||||
D3DXVECTOR2 tex;
|
||||
} SPRITEVERTEX;
|
||||
};
|
||||
|
||||
typedef struct _SPRITE {
|
||||
struct sprite
|
||||
{
|
||||
IDirect3DTexture9 *texture;
|
||||
UINT texw, texh;
|
||||
RECT rect;
|
||||
|
@ -36,9 +38,9 @@ typedef struct _SPRITE {
|
|||
D3DXVECTOR3 pos;
|
||||
D3DCOLOR color;
|
||||
D3DXMATRIX transform;
|
||||
} SPRITE;
|
||||
};
|
||||
|
||||
typedef struct ID3DXSpriteImpl
|
||||
struct d3dx9_sprite
|
||||
{
|
||||
ID3DXSprite ID3DXSprite_iface;
|
||||
LONG ref;
|
||||
|
@ -56,17 +58,17 @@ typedef struct ID3DXSpriteImpl
|
|||
DWORD maxanisotropy;
|
||||
DWORD alphacmp_caps;
|
||||
|
||||
SPRITE *sprites;
|
||||
struct sprite *sprites;
|
||||
int sprite_count; /* number of sprites to be drawn */
|
||||
int allocated_sprites; /* number of (pre-)allocated sprites */
|
||||
} ID3DXSpriteImpl;
|
||||
};
|
||||
|
||||
static inline ID3DXSpriteImpl *impl_from_ID3DXSprite(ID3DXSprite *iface)
|
||||
static inline struct d3dx9_sprite *impl_from_ID3DXSprite(ID3DXSprite *iface)
|
||||
{
|
||||
return CONTAINING_RECORD(iface, ID3DXSpriteImpl, ID3DXSprite_iface);
|
||||
return CONTAINING_RECORD(iface, struct d3dx9_sprite, ID3DXSprite_iface);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ID3DXSpriteImpl_QueryInterface(ID3DXSprite *iface, REFIID riid, void **out)
|
||||
static HRESULT WINAPI d3dx9_sprite_QueryInterface(ID3DXSprite *iface, REFIID riid, void **out)
|
||||
{
|
||||
TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
|
||||
|
||||
|
@ -84,93 +86,108 @@ static HRESULT WINAPI ID3DXSpriteImpl_QueryInterface(ID3DXSprite *iface, REFIID
|
|||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
static ULONG WINAPI ID3DXSpriteImpl_AddRef(ID3DXSprite *iface)
|
||||
static ULONG WINAPI d3dx9_sprite_AddRef(ID3DXSprite *iface)
|
||||
{
|
||||
ID3DXSpriteImpl *This = impl_from_ID3DXSprite(iface);
|
||||
ULONG ref=InterlockedIncrement(&This->ref);
|
||||
TRACE("(%p)->(): AddRef from %d\n", This, ref-1);
|
||||
return ref;
|
||||
struct d3dx9_sprite *sprite = impl_from_ID3DXSprite(iface);
|
||||
ULONG refcount = InterlockedIncrement(&sprite->ref);
|
||||
|
||||
TRACE("%p increasing refcount to %u.\n", sprite, refcount);
|
||||
|
||||
return refcount;
|
||||
}
|
||||
|
||||
static ULONG WINAPI ID3DXSpriteImpl_Release(ID3DXSprite *iface)
|
||||
static ULONG WINAPI d3dx9_sprite_Release(ID3DXSprite *iface)
|
||||
{
|
||||
ID3DXSpriteImpl *This = impl_from_ID3DXSprite(iface);
|
||||
ULONG ref=InterlockedDecrement(&This->ref);
|
||||
struct d3dx9_sprite *sprite = impl_from_ID3DXSprite(iface);
|
||||
ULONG refcount = InterlockedDecrement(&sprite->ref);
|
||||
|
||||
TRACE("(%p)->(): ReleaseRef to %d\n", This, ref);
|
||||
TRACE("%p decreasing refcount to %u.\n", sprite, refcount);
|
||||
|
||||
if(ref==0) {
|
||||
if(This->sprites) {
|
||||
if (!refcount)
|
||||
{
|
||||
if (sprite->sprites)
|
||||
{
|
||||
int i;
|
||||
for(i=0;i<This->sprite_count;i++)
|
||||
if(This->sprites[i].texture)
|
||||
IDirect3DTexture9_Release(This->sprites[i].texture);
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, This->sprites);
|
||||
for (i = 0; i < sprite->sprite_count; ++i)
|
||||
{
|
||||
if (sprite->sprites[i].texture)
|
||||
IDirect3DTexture9_Release(sprite->sprites[i].texture);
|
||||
}
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, sprite->sprites);
|
||||
}
|
||||
if(This->stateblock) IDirect3DStateBlock9_Release(This->stateblock);
|
||||
if(This->vdecl) IDirect3DVertexDeclaration9_Release(This->vdecl);
|
||||
if(This->device) IDirect3DDevice9_Release(This->device);
|
||||
HeapFree(GetProcessHeap(), 0, This);
|
||||
|
||||
if (sprite->stateblock)
|
||||
IDirect3DStateBlock9_Release(sprite->stateblock);
|
||||
if (sprite->vdecl)
|
||||
IDirect3DVertexDeclaration9_Release(sprite->vdecl);
|
||||
if (sprite->device)
|
||||
IDirect3DDevice9_Release(sprite->device);
|
||||
HeapFree(GetProcessHeap(), 0, sprite);
|
||||
}
|
||||
return ref;
|
||||
|
||||
return refcount;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ID3DXSpriteImpl_GetDevice(struct ID3DXSprite *iface, struct IDirect3DDevice9 **device)
|
||||
static HRESULT WINAPI d3dx9_sprite_GetDevice(struct ID3DXSprite *iface, struct IDirect3DDevice9 **device)
|
||||
{
|
||||
ID3DXSpriteImpl *This = impl_from_ID3DXSprite(iface);
|
||||
struct d3dx9_sprite *sprite = impl_from_ID3DXSprite(iface);
|
||||
|
||||
TRACE("(%p)->(%p)\n", This, device);
|
||||
TRACE("iface %p, device %p.\n", iface, device);
|
||||
|
||||
if(device==NULL) return D3DERR_INVALIDCALL;
|
||||
*device=This->device;
|
||||
IDirect3DDevice9_AddRef(This->device);
|
||||
if (!device)
|
||||
return D3DERR_INVALIDCALL;
|
||||
*device = sprite->device;
|
||||
IDirect3DDevice9_AddRef(sprite->device);
|
||||
|
||||
return D3D_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ID3DXSpriteImpl_GetTransform(ID3DXSprite *iface, D3DXMATRIX *transform)
|
||||
static HRESULT WINAPI d3dx9_sprite_GetTransform(ID3DXSprite *iface, D3DXMATRIX *transform)
|
||||
{
|
||||
ID3DXSpriteImpl *This = impl_from_ID3DXSprite(iface);
|
||||
struct d3dx9_sprite *sprite = impl_from_ID3DXSprite(iface);
|
||||
|
||||
TRACE("(%p)->(%p)\n", This, transform);
|
||||
TRACE("iface %p, transform %p.\n", iface, transform);
|
||||
|
||||
if(transform==NULL) return D3DERR_INVALIDCALL;
|
||||
*transform=This->transform;
|
||||
if (!transform)
|
||||
return D3DERR_INVALIDCALL;
|
||||
*transform = sprite->transform;
|
||||
|
||||
return D3D_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ID3DXSpriteImpl_SetTransform(ID3DXSprite *iface, CONST D3DXMATRIX *transform)
|
||||
static HRESULT WINAPI d3dx9_sprite_SetTransform(ID3DXSprite *iface, const D3DXMATRIX *transform)
|
||||
{
|
||||
ID3DXSpriteImpl *This = impl_from_ID3DXSprite(iface);
|
||||
struct d3dx9_sprite *sprite = impl_from_ID3DXSprite(iface);
|
||||
|
||||
TRACE("(%p)->(%p)\n", This, transform);
|
||||
TRACE("iface %p, transform %p.\n", iface, transform);
|
||||
|
||||
if(transform==NULL) return D3DERR_INVALIDCALL;
|
||||
This->transform=*transform;
|
||||
if (!transform)
|
||||
return D3DERR_INVALIDCALL;
|
||||
sprite->transform = *transform;
|
||||
|
||||
return D3D_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ID3DXSpriteImpl_SetWorldViewRH(ID3DXSprite *iface, CONST D3DXMATRIX *world,
|
||||
CONST D3DXMATRIX *view)
|
||||
static HRESULT WINAPI d3dx9_sprite_SetWorldViewRH(ID3DXSprite *iface,
|
||||
const D3DXMATRIX *world, const D3DXMATRIX *view)
|
||||
{
|
||||
ID3DXSpriteImpl *This = impl_from_ID3DXSprite(iface);
|
||||
FIXME("(%p)->(%p, %p): stub\n", This, world, view);
|
||||
FIXME("iface %p, world %p, view %p stub!\n", iface, world, view);
|
||||
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ID3DXSpriteImpl_SetWorldViewLH(ID3DXSprite *iface, CONST D3DXMATRIX *world,
|
||||
CONST D3DXMATRIX *view)
|
||||
static HRESULT WINAPI d3dx9_sprite_SetWorldViewLH(ID3DXSprite *iface,
|
||||
const D3DXMATRIX *world, const D3DXMATRIX *view)
|
||||
{
|
||||
ID3DXSpriteImpl *This = impl_from_ID3DXSprite(iface);
|
||||
FIXME("(%p)->(%p, %p): stub\n", This, world, view);
|
||||
FIXME("iface %p, world %p, view %p stub!\n", iface, world, view);
|
||||
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
/* Helper function */
|
||||
static void set_states(ID3DXSpriteImpl *object)
|
||||
static void set_states(struct d3dx9_sprite *object)
|
||||
{
|
||||
D3DXMATRIX mat;
|
||||
D3DVIEWPORT9 vp;
|
||||
|
@ -251,12 +268,12 @@ static void set_states(ID3DXSpriteImpl *object)
|
|||
IDirect3DDevice9_SetTransform(object->device, D3DTS_PROJECTION, &mat);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ID3DXSpriteImpl_Begin(ID3DXSprite *iface, DWORD flags)
|
||||
static HRESULT WINAPI d3dx9_sprite_Begin(ID3DXSprite *iface, DWORD flags)
|
||||
{
|
||||
ID3DXSpriteImpl *This = impl_from_ID3DXSprite(iface);
|
||||
struct d3dx9_sprite *This = impl_from_ID3DXSprite(iface);
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("(%p)->(%#x)\n", This, flags);
|
||||
TRACE("iface %p, flags %#x.\n", iface, flags);
|
||||
|
||||
if(flags>D3DXSPRITE_FLAGLIMIT || This->ready) return D3DERR_INVALIDCALL;
|
||||
|
||||
|
@ -273,7 +290,7 @@ D3DXSPRITE_SORT_TEXTURE: sort by texture (so that it doesn't change too often)
|
|||
D3DXSPRITE_DONOTMODIFY_RENDERSTATE | D3DXSPRITE_OBJECTSPACE |
|
||||
D3DXSPRITE_SORT_DEPTH_BACKTOFRONT))
|
||||
FIXME("Flags unsupported: %#x\n", flags);
|
||||
/* These flags should only matter to performances */
|
||||
/* These flags should only matter to performance */
|
||||
else if(flags & (D3DXSPRITE_SORT_DEPTH_FRONTTOBACK | D3DXSPRITE_SORT_TEXTURE))
|
||||
TRACE("Flags unsupported: %#x\n", flags);
|
||||
|
||||
|
@ -297,7 +314,7 @@ D3DXSPRITE_SORT_TEXTURE: sort by texture (so that it doesn't change too often)
|
|||
set_states(This);
|
||||
|
||||
IDirect3DDevice9_SetVertexDeclaration(This->device, This->vdecl);
|
||||
IDirect3DDevice9_SetStreamSource(This->device, 0, NULL, 0, sizeof(SPRITEVERTEX));
|
||||
IDirect3DDevice9_SetStreamSource(This->device, 0, NULL, 0, sizeof(struct sprite_vertex));
|
||||
IDirect3DDevice9_SetIndices(This->device, NULL);
|
||||
IDirect3DDevice9_SetTexture(This->device, 0, NULL);
|
||||
|
||||
|
@ -315,10 +332,10 @@ D3DXSPRITE_SORT_TEXTURE: sort by texture (so that it doesn't change too often)
|
|||
return D3D_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ID3DXSpriteImpl_Draw(ID3DXSprite *iface, IDirect3DTexture9 *texture,
|
||||
static HRESULT WINAPI d3dx9_sprite_Draw(ID3DXSprite *iface, IDirect3DTexture9 *texture,
|
||||
const RECT *rect, const D3DXVECTOR3 *center, const D3DXVECTOR3 *position, D3DCOLOR color)
|
||||
{
|
||||
ID3DXSpriteImpl *This = impl_from_ID3DXSprite(iface);
|
||||
struct d3dx9_sprite *This = impl_from_ID3DXSprite(iface);
|
||||
D3DSURFACE_DESC texdesc;
|
||||
|
||||
TRACE("iface %p, texture %p, rect %s, center %p, position %p, color 0x%08x.\n",
|
||||
|
@ -327,12 +344,16 @@ static HRESULT WINAPI ID3DXSpriteImpl_Draw(ID3DXSprite *iface, IDirect3DTexture9
|
|||
if(texture==NULL) return D3DERR_INVALIDCALL;
|
||||
if(!This->ready) return D3DERR_INVALIDCALL;
|
||||
|
||||
if(This->allocated_sprites==0) {
|
||||
This->sprites=HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 32*sizeof(SPRITE));
|
||||
This->allocated_sprites=32;
|
||||
} else if(This->allocated_sprites<=This->sprite_count) {
|
||||
This->allocated_sprites=This->allocated_sprites*3/2;
|
||||
This->sprites=HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->sprites, This->allocated_sprites*sizeof(SPRITE));
|
||||
if (!This->allocated_sprites)
|
||||
{
|
||||
This->sprites = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 32 * sizeof(*This->sprites));
|
||||
This->allocated_sprites = 32;
|
||||
}
|
||||
else if (This->allocated_sprites <= This->sprite_count)
|
||||
{
|
||||
This->allocated_sprites += This->allocated_sprites / 2;
|
||||
This->sprites = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
||||
This->sprites, This->allocated_sprites * sizeof(*This->sprites));
|
||||
}
|
||||
This->sprites[This->sprite_count].texture=texture;
|
||||
if(!(This->flags & D3DXSPRITE_DO_NOT_ADDREF_TEXTURE))
|
||||
|
@ -377,19 +398,19 @@ static HRESULT WINAPI ID3DXSpriteImpl_Draw(ID3DXSprite *iface, IDirect3DTexture9
|
|||
return D3D_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ID3DXSpriteImpl_Flush(ID3DXSprite *iface)
|
||||
static HRESULT WINAPI d3dx9_sprite_Flush(ID3DXSprite *iface)
|
||||
{
|
||||
ID3DXSpriteImpl *This = impl_from_ID3DXSprite(iface);
|
||||
SPRITEVERTEX *vertices;
|
||||
struct d3dx9_sprite *This = impl_from_ID3DXSprite(iface);
|
||||
struct sprite_vertex *vertices;
|
||||
int i, count=0, start;
|
||||
|
||||
TRACE("(%p)->()\n", This);
|
||||
TRACE("iface %p.\n", iface);
|
||||
|
||||
if(!This->ready) return D3DERR_INVALIDCALL;
|
||||
if(!This->sprite_count) return D3D_OK;
|
||||
|
||||
/* TODO: use of a vertex buffer here */
|
||||
vertices=HeapAlloc(GetProcessHeap(), 0, sizeof(SPRITEVERTEX)*6*This->sprite_count);
|
||||
vertices = HeapAlloc(GetProcessHeap(), 0, sizeof(*vertices) * 6 * This->sprite_count);
|
||||
|
||||
for(start=0;start<This->sprite_count;start+=count,count=0) {
|
||||
i=start;
|
||||
|
@ -426,9 +447,8 @@ static HRESULT WINAPI ID3DXSpriteImpl_Flush(ID3DXSprite *iface)
|
|||
vertices[6*i+4]=vertices[6*i];
|
||||
vertices[6*i+5]=vertices[6*i+2];
|
||||
|
||||
D3DXVec3TransformCoordArray(&vertices[6*i].pos, sizeof(SPRITEVERTEX),
|
||||
&vertices[6*i].pos, sizeof(SPRITEVERTEX),
|
||||
&This->sprites[i].transform, 6);
|
||||
D3DXVec3TransformCoordArray(&vertices[6 * i].pos, sizeof(*vertices),
|
||||
&vertices[6 * i].pos, sizeof(*vertices), &This->sprites[i].transform, 6);
|
||||
count++;
|
||||
i++;
|
||||
}
|
||||
|
@ -436,7 +456,8 @@ static HRESULT WINAPI ID3DXSpriteImpl_Flush(ID3DXSprite *iface)
|
|||
IDirect3DDevice9_SetTexture(This->device, 0, (struct IDirect3DBaseTexture9 *)This->sprites[start].texture);
|
||||
IDirect3DDevice9_SetVertexDeclaration(This->device, This->vdecl);
|
||||
|
||||
IDirect3DDevice9_DrawPrimitiveUP(This->device, D3DPT_TRIANGLELIST, 2*count, vertices+6*start, sizeof(SPRITEVERTEX));
|
||||
IDirect3DDevice9_DrawPrimitiveUP(This->device, D3DPT_TRIANGLELIST,
|
||||
2 * count, vertices + 6 * start, sizeof(*vertices));
|
||||
}
|
||||
HeapFree(GetProcessHeap(), 0, vertices);
|
||||
|
||||
|
@ -451,34 +472,37 @@ static HRESULT WINAPI ID3DXSpriteImpl_Flush(ID3DXSprite *iface)
|
|||
return D3D_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ID3DXSpriteImpl_End(ID3DXSprite *iface)
|
||||
static HRESULT WINAPI d3dx9_sprite_End(ID3DXSprite *iface)
|
||||
{
|
||||
ID3DXSpriteImpl *This = impl_from_ID3DXSprite(iface);
|
||||
struct d3dx9_sprite *sprite = impl_from_ID3DXSprite(iface);
|
||||
|
||||
TRACE("(%p)->()\n", This);
|
||||
TRACE("iface %p.\n", iface);
|
||||
|
||||
if(!This->ready) return D3DERR_INVALIDCALL;
|
||||
if (!sprite->ready)
|
||||
return D3DERR_INVALIDCALL;
|
||||
|
||||
ID3DXSprite_Flush(iface);
|
||||
|
||||
if(!(This->flags & D3DXSPRITE_DONOTSAVESTATE))
|
||||
if(This->stateblock) IDirect3DStateBlock9_Apply(This->stateblock); /* Restore old state */
|
||||
if (sprite->stateblock && !(sprite->flags & D3DXSPRITE_DONOTSAVESTATE))
|
||||
IDirect3DStateBlock9_Apply(sprite->stateblock); /* Restore old state */
|
||||
|
||||
This->ready=FALSE;
|
||||
sprite->ready = FALSE;
|
||||
|
||||
return D3D_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ID3DXSpriteImpl_OnLostDevice(ID3DXSprite *iface)
|
||||
static HRESULT WINAPI d3dx9_sprite_OnLostDevice(ID3DXSprite *iface)
|
||||
{
|
||||
ID3DXSpriteImpl *This = impl_from_ID3DXSprite(iface);
|
||||
struct d3dx9_sprite *sprite = impl_from_ID3DXSprite(iface);
|
||||
|
||||
TRACE("(%p)->()\n", This);
|
||||
TRACE("iface %p.\n", iface);
|
||||
|
||||
if(This->stateblock) IDirect3DStateBlock9_Release(This->stateblock);
|
||||
if(This->vdecl) IDirect3DVertexDeclaration9_Release(This->vdecl);
|
||||
This->vdecl=NULL;
|
||||
This->stateblock=NULL;
|
||||
if (sprite->stateblock)
|
||||
IDirect3DStateBlock9_Release(sprite->stateblock);
|
||||
if (sprite->vdecl)
|
||||
IDirect3DVertexDeclaration9_Release(sprite->vdecl);
|
||||
sprite->vdecl = NULL;
|
||||
sprite->stateblock = NULL;
|
||||
|
||||
/* Reset some variables */
|
||||
ID3DXSprite_OnResetDevice(iface);
|
||||
|
@ -486,21 +510,22 @@ static HRESULT WINAPI ID3DXSpriteImpl_OnLostDevice(ID3DXSprite *iface)
|
|||
return D3D_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ID3DXSpriteImpl_OnResetDevice(ID3DXSprite *iface)
|
||||
static HRESULT WINAPI d3dx9_sprite_OnResetDevice(ID3DXSprite *iface)
|
||||
{
|
||||
ID3DXSpriteImpl *This = impl_from_ID3DXSprite(iface);
|
||||
struct d3dx9_sprite *sprite = impl_from_ID3DXSprite(iface);
|
||||
int i;
|
||||
|
||||
TRACE("(%p)->()\n", This);
|
||||
TRACE("iface %p.\n", iface);
|
||||
|
||||
for(i=0;i<This->sprite_count;i++)
|
||||
if(This->sprites[i].texture)
|
||||
IDirect3DTexture9_Release(This->sprites[i].texture);
|
||||
for (i = 0; i < sprite->sprite_count; ++i)
|
||||
{
|
||||
if (sprite->sprites[i].texture)
|
||||
IDirect3DTexture9_Release(sprite->sprites[i].texture);
|
||||
}
|
||||
|
||||
This->sprite_count=0;
|
||||
|
||||
This->flags=0;
|
||||
This->ready=FALSE;
|
||||
sprite->sprite_count = 0;
|
||||
sprite->flags = 0;
|
||||
sprite->ready = FALSE;
|
||||
|
||||
/* keep matrices */
|
||||
/* device objects get restored on Begin */
|
||||
|
@ -508,41 +533,39 @@ static HRESULT WINAPI ID3DXSpriteImpl_OnResetDevice(ID3DXSprite *iface)
|
|||
return D3D_OK;
|
||||
}
|
||||
|
||||
static const ID3DXSpriteVtbl D3DXSprite_Vtbl =
|
||||
static const ID3DXSpriteVtbl d3dx9_sprite_vtbl =
|
||||
{
|
||||
/*** IUnknown methods ***/
|
||||
ID3DXSpriteImpl_QueryInterface,
|
||||
ID3DXSpriteImpl_AddRef,
|
||||
ID3DXSpriteImpl_Release,
|
||||
/*** ID3DXSprite methods ***/
|
||||
ID3DXSpriteImpl_GetDevice,
|
||||
ID3DXSpriteImpl_GetTransform,
|
||||
ID3DXSpriteImpl_SetTransform,
|
||||
ID3DXSpriteImpl_SetWorldViewRH,
|
||||
ID3DXSpriteImpl_SetWorldViewLH,
|
||||
ID3DXSpriteImpl_Begin,
|
||||
ID3DXSpriteImpl_Draw,
|
||||
ID3DXSpriteImpl_Flush,
|
||||
ID3DXSpriteImpl_End,
|
||||
ID3DXSpriteImpl_OnLostDevice,
|
||||
ID3DXSpriteImpl_OnResetDevice
|
||||
d3dx9_sprite_QueryInterface,
|
||||
d3dx9_sprite_AddRef,
|
||||
d3dx9_sprite_Release,
|
||||
d3dx9_sprite_GetDevice,
|
||||
d3dx9_sprite_GetTransform,
|
||||
d3dx9_sprite_SetTransform,
|
||||
d3dx9_sprite_SetWorldViewRH,
|
||||
d3dx9_sprite_SetWorldViewLH,
|
||||
d3dx9_sprite_Begin,
|
||||
d3dx9_sprite_Draw,
|
||||
d3dx9_sprite_Flush,
|
||||
d3dx9_sprite_End,
|
||||
d3dx9_sprite_OnLostDevice,
|
||||
d3dx9_sprite_OnResetDevice,
|
||||
};
|
||||
|
||||
HRESULT WINAPI D3DXCreateSprite(struct IDirect3DDevice9 *device, struct ID3DXSprite **sprite)
|
||||
{
|
||||
ID3DXSpriteImpl *object;
|
||||
struct d3dx9_sprite *object;
|
||||
D3DCAPS9 caps;
|
||||
|
||||
TRACE("(%p, %p)\n", device, sprite);
|
||||
TRACE("device %p, sprite %p.\n", device, sprite);
|
||||
|
||||
if(device==NULL || sprite==NULL) return D3DERR_INVALIDCALL;
|
||||
|
||||
object=HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ID3DXSpriteImpl));
|
||||
if(object==NULL) {
|
||||
*sprite=NULL;
|
||||
if (!(object=HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
|
||||
{
|
||||
*sprite = NULL;
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
object->ID3DXSprite_iface.lpVtbl = &D3DXSprite_Vtbl;
|
||||
object->ID3DXSprite_iface.lpVtbl = &d3dx9_sprite_vtbl;
|
||||
object->ref=1;
|
||||
object->device=device;
|
||||
IUnknown_AddRef(device);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (C) 2009-2010 Tony Wasserka
|
||||
* Copyright (C) 2012 Jأ³zef Kucia
|
||||
* Copyright (C) 2012 Józef Kucia
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -149,7 +149,13 @@ static D3DFORMAT dds_fourcc_to_d3dformat(DWORD fourcc)
|
|||
MAKEFOURCC('D','X','T','2'),
|
||||
MAKEFOURCC('D','X','T','3'),
|
||||
MAKEFOURCC('D','X','T','4'),
|
||||
MAKEFOURCC('D','X','T','5')
|
||||
MAKEFOURCC('D','X','T','5'),
|
||||
D3DFMT_R16F,
|
||||
D3DFMT_G16R16F,
|
||||
D3DFMT_A16B16G16R16F,
|
||||
D3DFMT_R32F,
|
||||
D3DFMT_G32R32F,
|
||||
D3DFMT_A32B32G32R32F,
|
||||
};
|
||||
|
||||
for (i = 0; i < sizeof(known_fourcc) / sizeof(known_fourcc[0]); i++)
|
||||
|
@ -255,6 +261,11 @@ static D3DFORMAT dds_bump_to_d3dformat(const struct dds_pixel_format *pixel_form
|
|||
|
||||
static D3DFORMAT dds_pixel_format_to_d3dformat(const struct dds_pixel_format *pixel_format)
|
||||
{
|
||||
TRACE("pixel_format: size %u, flags %#x, fourcc %#x, bpp %u.\n", pixel_format->size,
|
||||
pixel_format->flags, pixel_format->fourcc, pixel_format->bpp);
|
||||
TRACE("rmask %#x, gmask %#x, bmask %#x, amask %#x.\n", pixel_format->rmask, pixel_format->gmask,
|
||||
pixel_format->bmask, pixel_format->amask);
|
||||
|
||||
if (pixel_format->flags & DDS_PF_FOURCC)
|
||||
return dds_fourcc_to_d3dformat(pixel_format->fourcc);
|
||||
if (pixel_format->flags & DDS_PF_RGB)
|
||||
|
@ -524,8 +535,8 @@ HRESULT load_volume_from_dds(IDirect3DVolume9 *dst_volume, const PALETTEENTRY *d
|
|||
}
|
||||
|
||||
HRESULT load_texture_from_dds(IDirect3DTexture9 *texture, const void *src_data, const PALETTEENTRY *palette,
|
||||
DWORD filter, D3DCOLOR color_key, const D3DXIMAGE_INFO *src_info)
|
||||
|
||||
DWORD filter, D3DCOLOR color_key, const D3DXIMAGE_INFO *src_info, unsigned int skip_levels,
|
||||
unsigned int *loaded_miplevels)
|
||||
{
|
||||
HRESULT hr;
|
||||
RECT src_rect;
|
||||
|
@ -538,31 +549,45 @@ HRESULT load_texture_from_dds(IDirect3DTexture9 *texture, const void *src_data,
|
|||
const struct dds_header *header = src_data;
|
||||
const BYTE *pixels = (BYTE *)(header + 1);
|
||||
|
||||
/* 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))
|
||||
/* Loading a cube texture as a simple texture is also supported
|
||||
* (only first face texture is taken). Same with volume textures. */
|
||||
if ((src_info->ResourceType != D3DRTYPE_TEXTURE)
|
||||
&& (src_info->ResourceType != D3DRTYPE_CUBETEXTURE)
|
||||
&& (src_info->ResourceType != D3DRTYPE_VOLUMETEXTURE))
|
||||
{
|
||||
WARN("Trying to load a %u resource as a 2D texture, returning failure.\n", src_info->ResourceType);
|
||||
return D3DXERR_INVALIDDATA;
|
||||
}
|
||||
|
||||
width = src_info->Width;
|
||||
height = src_info->Height;
|
||||
mip_levels = min(src_info->MipLevels, IDirect3DTexture9_GetLevelCount(texture));
|
||||
for (mip_level = 0; mip_level < mip_levels; mip_level++)
|
||||
if (src_info->ResourceType == D3DRTYPE_VOLUMETEXTURE)
|
||||
mip_levels = 1;
|
||||
for (mip_level = 0; mip_level < mip_levels + skip_levels; ++mip_level)
|
||||
{
|
||||
hr = calculate_dds_surface_size(src_info->Format, width, height, &src_pitch, &mip_level_size);
|
||||
if (FAILED(hr)) return hr;
|
||||
|
||||
SetRect(&src_rect, 0, 0, width, height);
|
||||
if (mip_level >= skip_levels)
|
||||
{
|
||||
SetRect(&src_rect, 0, 0, width, height);
|
||||
|
||||
IDirect3DTexture9_GetSurfaceLevel(texture, mip_level, &surface);
|
||||
hr = D3DXLoadSurfaceFromMemory(surface, palette, NULL, pixels, src_info->Format, src_pitch,
|
||||
NULL, &src_rect, filter, color_key);
|
||||
IDirect3DSurface9_Release(surface);
|
||||
if (FAILED(hr)) return hr;
|
||||
IDirect3DTexture9_GetSurfaceLevel(texture, mip_level - skip_levels, &surface);
|
||||
hr = D3DXLoadSurfaceFromMemory(surface, palette, NULL, pixels, src_info->Format, src_pitch,
|
||||
NULL, &src_rect, filter, color_key);
|
||||
IDirect3DSurface9_Release(surface);
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
}
|
||||
|
||||
pixels += mip_level_size;
|
||||
width = max(1, width / 2);
|
||||
height = max(1, height / 2);
|
||||
}
|
||||
|
||||
*loaded_miplevels = mip_levels - skip_levels;
|
||||
|
||||
return D3D_OK;
|
||||
}
|
||||
|
||||
|
@ -895,13 +920,13 @@ HRESULT WINAPI D3DXGetImageInfoFromFileInMemory(const void *data, UINT datasize,
|
|||
* D3DERR_INVALIDCALL, if file is NULL
|
||||
*
|
||||
*/
|
||||
HRESULT WINAPI D3DXGetImageInfoFromFileA(LPCSTR file, D3DXIMAGE_INFO *info)
|
||||
HRESULT WINAPI D3DXGetImageInfoFromFileA(const char *file, D3DXIMAGE_INFO *info)
|
||||
{
|
||||
LPWSTR widename;
|
||||
WCHAR *widename;
|
||||
HRESULT hr;
|
||||
int strlength;
|
||||
|
||||
TRACE("(%s, %p): relay\n", debugstr_a(file), info);
|
||||
TRACE("file %s, info %p.\n", debugstr_a(file), info);
|
||||
|
||||
if( !file ) return D3DERR_INVALIDCALL;
|
||||
|
||||
|
@ -1010,7 +1035,7 @@ HRESULT WINAPI D3DXLoadSurfaceFromFileInMemory(IDirect3DSurface9 *pDestSurface,
|
|||
const RECT *pSrcRect, DWORD dwFilter, D3DCOLOR Colorkey, D3DXIMAGE_INFO *pSrcInfo)
|
||||
{
|
||||
D3DXIMAGE_INFO imginfo;
|
||||
HRESULT hr;
|
||||
HRESULT hr, com_init;
|
||||
|
||||
IWICImagingFactory *factory = NULL;
|
||||
IWICBitmapDecoder *decoder;
|
||||
|
@ -1063,7 +1088,7 @@ HRESULT WINAPI D3DXLoadSurfaceFromFileInMemory(IDirect3DSurface9 *pDestSurface,
|
|||
if (imginfo.ImageFileFormat == D3DXIFF_DIB)
|
||||
convert_dib_to_bmp((void**)&pSrcData, &SrcDataSize);
|
||||
|
||||
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
|
||||
com_init = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
|
||||
|
||||
if (FAILED(CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, &IID_IWICImagingFactory, (void**)&factory)))
|
||||
goto cleanup_err;
|
||||
|
@ -1166,7 +1191,8 @@ cleanup_err:
|
|||
if (factory)
|
||||
IWICImagingFactory_Release(factory);
|
||||
|
||||
CoUninitialize();
|
||||
if (SUCCEEDED(com_init))
|
||||
CoUninitialize();
|
||||
|
||||
if (imginfo.ImageFileFormat == D3DXIFF_DIB)
|
||||
HeapFree(GetProcessHeap(), 0, (void*)pSrcData);
|
||||
|
@ -1184,7 +1210,7 @@ HRESULT WINAPI D3DXLoadSurfaceFromFileA(IDirect3DSurface9 *dst_surface,
|
|||
const PALETTEENTRY *dst_palette, const RECT *dst_rect, const char *src_file,
|
||||
const RECT *src_rect, DWORD filter, D3DCOLOR color_key, D3DXIMAGE_INFO *src_info)
|
||||
{
|
||||
LPWSTR pWidename;
|
||||
WCHAR *src_file_w;
|
||||
HRESULT hr;
|
||||
int strlength;
|
||||
|
||||
|
@ -1197,12 +1223,12 @@ HRESULT WINAPI D3DXLoadSurfaceFromFileA(IDirect3DSurface9 *dst_surface,
|
|||
return D3DERR_INVALIDCALL;
|
||||
|
||||
strlength = MultiByteToWideChar(CP_ACP, 0, src_file, -1, NULL, 0);
|
||||
pWidename = HeapAlloc(GetProcessHeap(), 0, strlength * sizeof(*pWidename));
|
||||
MultiByteToWideChar(CP_ACP, 0, src_file, -1, pWidename, strlength);
|
||||
src_file_w = HeapAlloc(GetProcessHeap(), 0, strlength * sizeof(*src_file_w));
|
||||
MultiByteToWideChar(CP_ACP, 0, src_file, -1, src_file_w, strlength);
|
||||
|
||||
hr = D3DXLoadSurfaceFromFileW(dst_surface, dst_palette, dst_rect,
|
||||
pWidename, src_rect, filter, color_key, src_info);
|
||||
HeapFree(GetProcessHeap(), 0, pWidename);
|
||||
src_file_w, src_rect, filter, color_key, src_info);
|
||||
HeapFree(GetProcessHeap(), 0, src_file_w);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
@ -1330,40 +1356,13 @@ static void init_argb_conversion_info(const struct pixel_format_desc *srcformat,
|
|||
}
|
||||
}
|
||||
|
||||
static DWORD dword_from_bytes(CONST BYTE *src, UINT bytes_per_pixel)
|
||||
{
|
||||
DWORD ret = 0;
|
||||
static BOOL fixme_once;
|
||||
|
||||
if(bytes_per_pixel > sizeof(DWORD)) {
|
||||
if(!fixme_once++) FIXME("Unsupported image: %u bytes per pixel\n", bytes_per_pixel);
|
||||
bytes_per_pixel = sizeof(DWORD);
|
||||
}
|
||||
|
||||
memcpy(&ret, src, bytes_per_pixel);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void dword_to_bytes(BYTE *dst, DWORD dword, UINT bytes_per_pixel)
|
||||
{
|
||||
static BOOL fixme_once;
|
||||
|
||||
if(bytes_per_pixel > sizeof(DWORD)) {
|
||||
if(!fixme_once++) FIXME("Unsupported image: %u bytes per pixel\n", bytes_per_pixel);
|
||||
ZeroMemory(dst, bytes_per_pixel);
|
||||
bytes_per_pixel = sizeof(DWORD);
|
||||
}
|
||||
|
||||
memcpy(dst, &dword, bytes_per_pixel);
|
||||
}
|
||||
|
||||
/************************************************************
|
||||
* get_relevant_argb_components
|
||||
*
|
||||
* Extracts the relevant components from the source color and
|
||||
* drops the less significant bits if they aren't used by the destination format.
|
||||
*/
|
||||
static void get_relevant_argb_components(CONST struct argb_conversion_info *info, CONST DWORD col, DWORD *out)
|
||||
static void get_relevant_argb_components(const struct argb_conversion_info *info, DWORD col, DWORD *out)
|
||||
{
|
||||
UINT i = 0;
|
||||
for(;i < 4;i++)
|
||||
|
@ -1377,7 +1376,7 @@ static void get_relevant_argb_components(CONST struct argb_conversion_info *info
|
|||
* Recombines the output of get_relevant_argb_components and converts
|
||||
* it to the destination format.
|
||||
*/
|
||||
static DWORD make_argb_color(CONST struct argb_conversion_info *info, CONST DWORD *in)
|
||||
static DWORD make_argb_color(const struct argb_conversion_info *info, const DWORD *in)
|
||||
{
|
||||
UINT i;
|
||||
DWORD val = 0;
|
||||
|
@ -1394,55 +1393,78 @@ static DWORD make_argb_color(CONST struct argb_conversion_info *info, CONST DWOR
|
|||
return val;
|
||||
}
|
||||
|
||||
static void format_to_vec4(const struct pixel_format_desc *format, const DWORD *src, struct vec4 *dst)
|
||||
/* It doesn't work for components bigger than 32 bits (or somewhat smaller but unaligned). */
|
||||
static void format_to_vec4(const struct pixel_format_desc *format, const BYTE *src, struct vec4 *dst)
|
||||
{
|
||||
DWORD mask;
|
||||
DWORD mask, tmp;
|
||||
unsigned int c;
|
||||
|
||||
if (format->bits[1])
|
||||
for (c = 0; c < 4; ++c)
|
||||
{
|
||||
mask = (1 << format->bits[1]) - 1;
|
||||
dst->x = (float)((*src >> format->shift[1]) & mask) / mask;
|
||||
}
|
||||
else
|
||||
dst->x = 1.0f;
|
||||
static const unsigned int component_offsets[4] = {3, 0, 1, 2};
|
||||
float *dst_component = (float *)dst + component_offsets[c];
|
||||
|
||||
if (format->bits[2])
|
||||
{
|
||||
mask = (1 << format->bits[2]) - 1;
|
||||
dst->y = (float)((*src >> format->shift[2]) & mask) / mask;
|
||||
}
|
||||
else
|
||||
dst->y = 1.0f;
|
||||
if (format->bits[c])
|
||||
{
|
||||
mask = ~0u >> (32 - format->bits[c]);
|
||||
|
||||
if (format->bits[3])
|
||||
{
|
||||
mask = (1 << format->bits[3]) - 1;
|
||||
dst->z = (float)((*src >> format->shift[3]) & mask) / mask;
|
||||
}
|
||||
else
|
||||
dst->z = 1.0f;
|
||||
memcpy(&tmp, src + format->shift[c] / 8,
|
||||
min(sizeof(DWORD), (format->shift[c] % 8 + format->bits[c] + 7) / 8));
|
||||
|
||||
if (format->bits[0])
|
||||
{
|
||||
mask = (1 << format->bits[0]) - 1;
|
||||
dst->w = (float)((*src >> format->shift[0]) & mask) / mask;
|
||||
if (format->type == FORMAT_ARGBF16)
|
||||
*dst_component = float_16_to_32(tmp);
|
||||
else if (format->type == FORMAT_ARGBF)
|
||||
*dst_component = *(float *)&tmp;
|
||||
else
|
||||
*dst_component = (float)((tmp >> format->shift[c] % 8) & mask) / mask;
|
||||
}
|
||||
else
|
||||
*dst_component = 1.0f;
|
||||
}
|
||||
else
|
||||
dst->w = 1.0f;
|
||||
}
|
||||
|
||||
static void format_from_vec4(const struct pixel_format_desc *format, const struct vec4 *src, DWORD *dst)
|
||||
/* It doesn't work for components bigger than 32 bits. */
|
||||
static void format_from_vec4(const struct pixel_format_desc *format, const struct vec4 *src, BYTE *dst)
|
||||
{
|
||||
*dst = 0;
|
||||
DWORD v, mask32;
|
||||
unsigned int c, i;
|
||||
|
||||
if (format->bits[1])
|
||||
*dst |= (DWORD)(src->x * ((1 << format->bits[1]) - 1) + 0.5f) << format->shift[1];
|
||||
if (format->bits[2])
|
||||
*dst |= (DWORD)(src->y * ((1 << format->bits[2]) - 1) + 0.5f) << format->shift[2];
|
||||
if (format->bits[3])
|
||||
*dst |= (DWORD)(src->z * ((1 << format->bits[3]) - 1) + 0.5f) << format->shift[3];
|
||||
if (format->bits[0])
|
||||
*dst |= (DWORD)(src->w * ((1 << format->bits[0]) - 1) + 0.5f) << format->shift[0];
|
||||
memset(dst, 0, format->bytes_per_pixel);
|
||||
|
||||
for (c = 0; c < 4; ++c)
|
||||
{
|
||||
static const unsigned int component_offsets[4] = {3, 0, 1, 2};
|
||||
const float src_component = *((const float *)src + component_offsets[c]);
|
||||
|
||||
if (!format->bits[c])
|
||||
continue;
|
||||
|
||||
mask32 = ~0u >> (32 - format->bits[c]);
|
||||
|
||||
if (format->type == FORMAT_ARGBF16)
|
||||
v = float_32_to_16(src_component);
|
||||
else if (format->type == FORMAT_ARGBF)
|
||||
v = *(DWORD *)&src_component;
|
||||
else
|
||||
v = (DWORD)(src_component * ((1 << format->bits[c]) - 1) + 0.5f);
|
||||
|
||||
for (i = format->shift[c] / 8 * 8; i < format->shift[c] + format->bits[c]; i += 8)
|
||||
{
|
||||
BYTE mask, byte;
|
||||
|
||||
if (format->shift[c] > i)
|
||||
{
|
||||
mask = mask32 << (format->shift[c] - i);
|
||||
byte = (v << (format->shift[c] - i)) & mask;
|
||||
}
|
||||
else
|
||||
{
|
||||
mask = mask32 >> (i - format->shift[c]);
|
||||
byte = (v >> (i - format->shift[c])) & mask;
|
||||
}
|
||||
dst[i / 8] |= byte;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************
|
||||
|
@ -1491,7 +1513,7 @@ void convert_argb_pixels(const BYTE *src, UINT src_row_pitch, UINT src_slice_pit
|
|||
{
|
||||
struct argb_conversion_info conv_info, ck_conv_info;
|
||||
const struct pixel_format_desc *ck_format = NULL;
|
||||
DWORD channels[4], pixel;
|
||||
DWORD channels[4];
|
||||
UINT min_width, min_height, min_depth;
|
||||
UINT x, y, z;
|
||||
|
||||
|
@ -1516,30 +1538,32 @@ void convert_argb_pixels(const BYTE *src, UINT src_row_pitch, UINT src_slice_pit
|
|||
for (y = 0; y < min_height; y++) {
|
||||
const BYTE *src_ptr = src_slice_ptr + y * src_row_pitch;
|
||||
BYTE *dst_ptr = dst_slice_ptr + y * dst_row_pitch;
|
||||
DWORD val;
|
||||
|
||||
for (x = 0; x < min_width; x++) {
|
||||
/* extract source color components */
|
||||
pixel = dword_from_bytes(src_ptr, src_format->bytes_per_pixel);
|
||||
|
||||
if (!src_format->to_rgba && !dst_format->from_rgba)
|
||||
if (!src_format->to_rgba && !dst_format->from_rgba
|
||||
&& src_format->bytes_per_pixel <= 4 && dst_format->bytes_per_pixel <= 4)
|
||||
{
|
||||
get_relevant_argb_components(&conv_info, pixel, channels);
|
||||
DWORD val;
|
||||
|
||||
get_relevant_argb_components(&conv_info, *(DWORD *)src_ptr, channels);
|
||||
val = make_argb_color(&conv_info, channels);
|
||||
|
||||
if (color_key)
|
||||
{
|
||||
get_relevant_argb_components(&ck_conv_info, pixel, channels);
|
||||
pixel = make_argb_color(&ck_conv_info, channels);
|
||||
if (pixel == color_key)
|
||||
DWORD ck_pixel;
|
||||
|
||||
get_relevant_argb_components(&ck_conv_info, *(DWORD *)src_ptr, channels);
|
||||
ck_pixel = make_argb_color(&ck_conv_info, channels);
|
||||
if (ck_pixel == color_key)
|
||||
val &= ~conv_info.destmask[0];
|
||||
}
|
||||
memcpy(dst_ptr, &val, dst_format->bytes_per_pixel);
|
||||
}
|
||||
else
|
||||
{
|
||||
struct vec4 color, tmp;
|
||||
|
||||
format_to_vec4(src_format, &pixel, &color);
|
||||
format_to_vec4(src_format, src_ptr, &color);
|
||||
if (src_format->to_rgba)
|
||||
src_format->to_rgba(&color, &tmp, palette);
|
||||
else
|
||||
|
@ -1547,8 +1571,10 @@ void convert_argb_pixels(const BYTE *src, UINT src_row_pitch, UINT src_slice_pit
|
|||
|
||||
if (ck_format)
|
||||
{
|
||||
format_from_vec4(ck_format, &tmp, &pixel);
|
||||
if (pixel == color_key)
|
||||
DWORD ck_pixel;
|
||||
|
||||
format_from_vec4(ck_format, &tmp, (BYTE *)&ck_pixel);
|
||||
if (ck_pixel == color_key)
|
||||
tmp.w = 0.0f;
|
||||
}
|
||||
|
||||
|
@ -1557,11 +1583,10 @@ void convert_argb_pixels(const BYTE *src, UINT src_row_pitch, UINT src_slice_pit
|
|||
else
|
||||
color = tmp;
|
||||
|
||||
format_from_vec4(dst_format, &color, &val);
|
||||
format_from_vec4(dst_format, &color, dst_ptr);
|
||||
}
|
||||
|
||||
dword_to_bytes(dst_ptr, val, dst_format->bytes_per_pixel);
|
||||
src_ptr += src_format->bytes_per_pixel;
|
||||
src_ptr += src_format->bytes_per_pixel;
|
||||
dst_ptr += dst_format->bytes_per_pixel;
|
||||
}
|
||||
|
||||
|
@ -1591,7 +1616,7 @@ void point_filter_argb_pixels(const BYTE *src, UINT src_row_pitch, UINT src_slic
|
|||
{
|
||||
struct argb_conversion_info conv_info, ck_conv_info;
|
||||
const struct pixel_format_desc *ck_format = NULL;
|
||||
DWORD channels[4], pixel;
|
||||
DWORD channels[4];
|
||||
UINT x, y, z;
|
||||
|
||||
ZeroMemory(channels, sizeof(channels));
|
||||
|
@ -1617,29 +1642,31 @@ void point_filter_argb_pixels(const BYTE *src, UINT src_row_pitch, UINT src_slic
|
|||
for (x = 0; x < dst_size->width; x++)
|
||||
{
|
||||
const BYTE *src_ptr = src_row_ptr + (x * src_size->width / dst_size->width) * src_format->bytes_per_pixel;
|
||||
DWORD val;
|
||||
|
||||
/* extract source color components */
|
||||
pixel = dword_from_bytes(src_ptr, src_format->bytes_per_pixel);
|
||||
|
||||
if (!src_format->to_rgba && !dst_format->from_rgba)
|
||||
if (!src_format->to_rgba && !dst_format->from_rgba
|
||||
&& src_format->bytes_per_pixel <= 4 && dst_format->bytes_per_pixel <= 4)
|
||||
{
|
||||
get_relevant_argb_components(&conv_info, pixel, channels);
|
||||
DWORD val;
|
||||
|
||||
get_relevant_argb_components(&conv_info, *(DWORD *)src_ptr, channels);
|
||||
val = make_argb_color(&conv_info, channels);
|
||||
|
||||
if (color_key)
|
||||
{
|
||||
get_relevant_argb_components(&ck_conv_info, pixel, channels);
|
||||
pixel = make_argb_color(&ck_conv_info, channels);
|
||||
if (pixel == color_key)
|
||||
DWORD ck_pixel;
|
||||
|
||||
get_relevant_argb_components(&ck_conv_info, *(DWORD *)src_ptr, channels);
|
||||
ck_pixel = make_argb_color(&ck_conv_info, channels);
|
||||
if (ck_pixel == color_key)
|
||||
val &= ~conv_info.destmask[0];
|
||||
}
|
||||
memcpy(dst_ptr, &val, dst_format->bytes_per_pixel);
|
||||
}
|
||||
else
|
||||
{
|
||||
struct vec4 color, tmp;
|
||||
|
||||
format_to_vec4(src_format, &pixel, &color);
|
||||
format_to_vec4(src_format, src_ptr, &color);
|
||||
if (src_format->to_rgba)
|
||||
src_format->to_rgba(&color, &tmp, palette);
|
||||
else
|
||||
|
@ -1647,8 +1674,10 @@ void point_filter_argb_pixels(const BYTE *src, UINT src_row_pitch, UINT src_slic
|
|||
|
||||
if (ck_format)
|
||||
{
|
||||
format_from_vec4(ck_format, &tmp, &pixel);
|
||||
if (pixel == color_key)
|
||||
DWORD ck_pixel;
|
||||
|
||||
format_from_vec4(ck_format, &tmp, (BYTE *)&ck_pixel);
|
||||
if (ck_pixel == color_key)
|
||||
tmp.w = 0.0f;
|
||||
}
|
||||
|
||||
|
@ -1657,10 +1686,9 @@ void point_filter_argb_pixels(const BYTE *src, UINT src_row_pitch, UINT src_slic
|
|||
else
|
||||
color = tmp;
|
||||
|
||||
format_from_vec4(dst_format, &color, &val);
|
||||
format_from_vec4(dst_format, &color, dst_ptr);
|
||||
}
|
||||
|
||||
dword_to_bytes(dst_ptr, val, dst_format->bytes_per_pixel);
|
||||
dst_ptr += dst_format->bytes_per_pixel;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -191,6 +191,7 @@ HRESULT WINAPI D3DXCheckTextureRequirements(struct IDirect3DDevice9 *device, UIN
|
|||
D3DDISPLAYMODE mode;
|
||||
HRESULT hr;
|
||||
D3DFORMAT usedformat = D3DFMT_UNKNOWN;
|
||||
const struct pixel_format_desc *fmt;
|
||||
|
||||
TRACE("(%p, %p, %p, %p, %u, %p, %u)\n", device, width, height, miplevels, usage, format, pool);
|
||||
|
||||
|
@ -207,73 +208,6 @@ HRESULT WINAPI D3DXCheckTextureRequirements(struct IDirect3DDevice9 *device, UIN
|
|||
if ((pool != D3DPOOL_DEFAULT) && (pool != D3DPOOL_MANAGED) && (pool != D3DPOOL_SYSTEMMEM) && (pool != D3DPOOL_SCRATCH))
|
||||
return D3DERR_INVALIDCALL;
|
||||
|
||||
/* width and height */
|
||||
if (FAILED(IDirect3DDevice9_GetDeviceCaps(device, &caps)))
|
||||
return D3DERR_INVALIDCALL;
|
||||
|
||||
/* 256 x 256 default width/height */
|
||||
if ((w == D3DX_DEFAULT) && (h == D3DX_DEFAULT))
|
||||
w = h = 256;
|
||||
else if (w == D3DX_DEFAULT)
|
||||
w = (height ? h : 256);
|
||||
else if (h == D3DX_DEFAULT)
|
||||
h = (width ? w : 256);
|
||||
|
||||
/* ensure width/height is power of 2 */
|
||||
if ((caps.TextureCaps & D3DPTEXTURECAPS_POW2) && (!is_pow2(w)))
|
||||
w = make_pow2(w);
|
||||
|
||||
if (w > caps.MaxTextureWidth)
|
||||
w = caps.MaxTextureWidth;
|
||||
|
||||
if ((caps.TextureCaps & D3DPTEXTURECAPS_POW2) && (!is_pow2(h)))
|
||||
h = make_pow2(h);
|
||||
|
||||
if (h > caps.MaxTextureHeight)
|
||||
h = caps.MaxTextureHeight;
|
||||
|
||||
/* texture must be square? */
|
||||
if (caps.TextureCaps & D3DPTEXTURECAPS_SQUAREONLY)
|
||||
{
|
||||
if (w > h)
|
||||
h = w;
|
||||
else
|
||||
w = h;
|
||||
}
|
||||
|
||||
if (width)
|
||||
*width = w;
|
||||
|
||||
if (height)
|
||||
*height = h;
|
||||
|
||||
/* miplevels */
|
||||
if (miplevels && (usage & D3DUSAGE_AUTOGENMIPMAP))
|
||||
{
|
||||
if (*miplevels > 1)
|
||||
*miplevels = 0;
|
||||
}
|
||||
else if (miplevels)
|
||||
{
|
||||
UINT max_mipmaps = 1;
|
||||
|
||||
if (!width && !height)
|
||||
max_mipmaps = 9; /* number of mipmaps in a 256x256 texture */
|
||||
else
|
||||
{
|
||||
UINT max_dimen = max(w, h);
|
||||
|
||||
while (max_dimen > 1)
|
||||
{
|
||||
max_dimen >>= 1;
|
||||
max_mipmaps++;
|
||||
}
|
||||
}
|
||||
|
||||
if (*miplevels == 0 || *miplevels > max_mipmaps)
|
||||
*miplevels = max_mipmaps;
|
||||
}
|
||||
|
||||
/* format */
|
||||
if (format)
|
||||
{
|
||||
|
@ -299,17 +233,18 @@ HRESULT WINAPI D3DXCheckTextureRequirements(struct IDirect3DDevice9 *device, UIN
|
|||
if ((usedformat == D3DFMT_UNKNOWN) || (usedformat == D3DX_DEFAULT))
|
||||
usedformat = D3DFMT_A8R8G8B8;
|
||||
|
||||
fmt = get_format_info(usedformat);
|
||||
|
||||
hr = IDirect3D9_CheckDeviceFormat(d3d, params.AdapterOrdinal, params.DeviceType, mode.Format,
|
||||
usage, D3DRTYPE_TEXTURE, usedformat);
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
/* Heuristic to choose the fallback format */
|
||||
const struct pixel_format_desc *fmt = get_format_info(usedformat);
|
||||
BOOL allow_24bits;
|
||||
int bestscore = INT_MIN, i = 0, j;
|
||||
unsigned int channels;
|
||||
const struct pixel_format_desc *curfmt;
|
||||
const struct pixel_format_desc *curfmt, *bestfmt = NULL;
|
||||
|
||||
TRACE("Requested format not supported, looking for a fallback.\n");
|
||||
|
||||
if (!fmt)
|
||||
{
|
||||
|
@ -354,11 +289,83 @@ HRESULT WINAPI D3DXCheckTextureRequirements(struct IDirect3DDevice9 *device, UIN
|
|||
{
|
||||
bestscore = score;
|
||||
usedformat = curfmt->format;
|
||||
bestfmt = curfmt;
|
||||
}
|
||||
}
|
||||
fmt = bestfmt;
|
||||
hr = D3D_OK;
|
||||
}
|
||||
|
||||
if (FAILED(IDirect3DDevice9_GetDeviceCaps(device, &caps)))
|
||||
return D3DERR_INVALIDCALL;
|
||||
|
||||
if ((w == D3DX_DEFAULT) && (h == D3DX_DEFAULT))
|
||||
w = h = 256;
|
||||
else if (w == D3DX_DEFAULT)
|
||||
w = (height ? h : 256);
|
||||
else if (h == D3DX_DEFAULT)
|
||||
h = (width ? w : 256);
|
||||
|
||||
if (fmt->block_width != 1 || fmt->block_height != 1)
|
||||
{
|
||||
if (w < fmt->block_width)
|
||||
w = fmt->block_width;
|
||||
if (h < fmt->block_height)
|
||||
h = fmt->block_height;
|
||||
}
|
||||
|
||||
if ((caps.TextureCaps & D3DPTEXTURECAPS_POW2) && (!is_pow2(w)))
|
||||
w = make_pow2(w);
|
||||
|
||||
if (w > caps.MaxTextureWidth)
|
||||
w = caps.MaxTextureWidth;
|
||||
|
||||
if ((caps.TextureCaps & D3DPTEXTURECAPS_POW2) && (!is_pow2(h)))
|
||||
h = make_pow2(h);
|
||||
|
||||
if (h > caps.MaxTextureHeight)
|
||||
h = caps.MaxTextureHeight;
|
||||
|
||||
if (caps.TextureCaps & D3DPTEXTURECAPS_SQUAREONLY)
|
||||
{
|
||||
if (w > h)
|
||||
h = w;
|
||||
else
|
||||
w = h;
|
||||
}
|
||||
|
||||
if (width)
|
||||
*width = w;
|
||||
|
||||
if (height)
|
||||
*height = h;
|
||||
|
||||
if (miplevels && (usage & D3DUSAGE_AUTOGENMIPMAP))
|
||||
{
|
||||
if (*miplevels > 1)
|
||||
*miplevels = 0;
|
||||
}
|
||||
else if (miplevels)
|
||||
{
|
||||
UINT max_mipmaps = 1;
|
||||
|
||||
if (!width && !height)
|
||||
max_mipmaps = 9; /* number of mipmaps in a 256x256 texture */
|
||||
else
|
||||
{
|
||||
UINT max_dimen = max(w, h);
|
||||
|
||||
while (max_dimen > 1)
|
||||
{
|
||||
max_dimen >>= 1;
|
||||
max_mipmaps++;
|
||||
}
|
||||
}
|
||||
|
||||
if (*miplevels == 0 || *miplevels > max_mipmaps)
|
||||
*miplevels = max_mipmaps;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
|
||||
if (d3d)
|
||||
|
@ -518,21 +525,24 @@ HRESULT WINAPI D3DXCreateTextureFromFileInMemoryEx(struct IDirect3DDevice9 *devi
|
|||
BOOL file_format = FALSE, file_miplevels = FALSE;
|
||||
BOOL dynamic_texture;
|
||||
D3DXIMAGE_INFO imginfo;
|
||||
UINT loaded_miplevels;
|
||||
UINT loaded_miplevels, skip_levels;
|
||||
D3DCAPS9 caps;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("(%p, %p, %u, %u, %u, %u, %x, %x, %x, %u, %u, %x, %p, %p, %p)\n", device, srcdata, srcdatasize, width,
|
||||
height, miplevels, usage, format, pool, filter, mipfilter, colorkey, srcinfo, palette, texture);
|
||||
TRACE("device %p, srcdata %p, srcdatasize %u, width %u, height %u, miplevels %u,"
|
||||
" usage %#x, format %#x, pool %#x, filter %#x, mipfilter %#x, colorkey %#x,"
|
||||
" srcinfo %p, palette %p, texture %p.\n",
|
||||
device, srcdata, srcdatasize, width, height, miplevels, usage, format, pool,
|
||||
filter, mipfilter, colorkey, srcinfo, palette, texture);
|
||||
|
||||
/* check for invalid parameters */
|
||||
if (!device || !texture || !srcdata || !srcdatasize)
|
||||
return D3DERR_INVALIDCALL;
|
||||
|
||||
hr = D3DXGetImageInfoFromFileInMemory(srcdata, srcdatasize, &imginfo);
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
FIXME("Unrecognized file format, returning failure.\n");
|
||||
*texture = NULL;
|
||||
return hr;
|
||||
}
|
||||
|
@ -577,11 +587,26 @@ HRESULT WINAPI D3DXCreateTextureFromFileInMemoryEx(struct IDirect3DDevice9 *devi
|
|||
miplevels = imginfo.MipLevels;
|
||||
}
|
||||
|
||||
skip_levels = mipfilter != D3DX_DEFAULT ? mipfilter >> D3DX_SKIP_DDS_MIP_LEVELS_SHIFT : 0;
|
||||
if (skip_levels && imginfo.MipLevels > skip_levels)
|
||||
{
|
||||
TRACE("Skipping the first %u (of %u) levels of a DDS mipmapped texture.\n",
|
||||
skip_levels, imginfo.MipLevels);
|
||||
TRACE("Texture level 0 dimensions are %ux%u.\n", imginfo.Width, imginfo.Height);
|
||||
width >>= skip_levels;
|
||||
height >>= skip_levels;
|
||||
miplevels -= skip_levels;
|
||||
}
|
||||
else
|
||||
{
|
||||
skip_levels = 0;
|
||||
}
|
||||
|
||||
/* fix texture creation parameters */
|
||||
hr = D3DXCheckTextureRequirements(device, &width, &height, &miplevels, usage, &format, pool);
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
FIXME("Couldn't find suitable texture parameters.\n");
|
||||
*texture = NULL;
|
||||
return hr;
|
||||
}
|
||||
|
@ -591,6 +616,12 @@ HRESULT WINAPI D3DXCreateTextureFromFileInMemoryEx(struct IDirect3DDevice9 *devi
|
|||
FIXME("Generation of mipmaps for compressed pixel formats is not implemented yet\n");
|
||||
miplevels = imginfo.MipLevels;
|
||||
}
|
||||
if (imginfo.ResourceType == D3DRTYPE_VOLUMETEXTURE
|
||||
&& D3DFMT_DXT1 <= imginfo.Format && imginfo.Format <= D3DFMT_DXT5 && miplevels > 1)
|
||||
{
|
||||
FIXME("Generation of mipmaps for compressed pixel formats is not implemented yet.\n");
|
||||
miplevels = 1;
|
||||
}
|
||||
|
||||
if (((file_width) && (width != imginfo.Width)) ||
|
||||
((file_height) && (height != imginfo.Height)) ||
|
||||
|
@ -618,34 +649,37 @@ HRESULT WINAPI D3DXCreateTextureFromFileInMemoryEx(struct IDirect3DDevice9 *devi
|
|||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
FIXME("Texture creation failed.\n");
|
||||
*texture = NULL;
|
||||
return hr;
|
||||
}
|
||||
|
||||
/* Load the file */
|
||||
TRACE("Texture created correctly. Now loading the texture data into it.\n");
|
||||
if (imginfo.ImageFileFormat != D3DXIFF_DDS)
|
||||
{
|
||||
IDirect3DTexture9_GetSurfaceLevel(*texptr, 0, &surface);
|
||||
hr = D3DXLoadSurfaceFromFileInMemory(surface, palette, NULL, srcdata, srcdatasize, NULL, filter, colorkey, NULL);
|
||||
IDirect3DSurface9_Release(surface);
|
||||
loaded_miplevels = min(IDirect3DTexture9_GetLevelCount(*texptr), imginfo.MipLevels);
|
||||
}
|
||||
else
|
||||
{
|
||||
hr = load_texture_from_dds(*texptr, srcdata, palette, filter, colorkey, &imginfo);
|
||||
hr = load_texture_from_dds(*texptr, srcdata, palette, filter, colorkey, &imginfo, skip_levels,
|
||||
&loaded_miplevels);
|
||||
}
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
FIXME("Texture loading failed.\n");
|
||||
IDirect3DTexture9_Release(*texptr);
|
||||
*texture = NULL;
|
||||
return hr;
|
||||
}
|
||||
|
||||
loaded_miplevels = min(IDirect3DTexture9_GetLevelCount(*texptr), imginfo.MipLevels);
|
||||
hr = D3DXFilterTexture((IDirect3DBaseTexture9*) *texptr, palette, loaded_miplevels - 1, mipfilter);
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
FIXME("Texture filtering failed.\n");
|
||||
IDirect3DTexture9_Release(*texptr);
|
||||
*texture = NULL;
|
||||
return hr;
|
||||
|
@ -687,13 +721,14 @@ HRESULT WINAPI D3DXCreateTextureFromFileExW(struct IDirect3DDevice9 *device, con
|
|||
D3DPOOL pool, DWORD filter, DWORD mipfilter, D3DCOLOR colorkey, D3DXIMAGE_INFO *srcinfo,
|
||||
PALETTEENTRY *palette, struct IDirect3DTexture9 **texture)
|
||||
{
|
||||
void *buffer;
|
||||
HRESULT hr;
|
||||
DWORD size;
|
||||
LPVOID buffer;
|
||||
|
||||
TRACE("(%p, %s, %u, %u, %u, %x, %x, %x, %u, %u, %x, %p, %p, %p): relay\n",
|
||||
device, debugstr_w(srcfile), width, height, miplevels, usage, format, pool, filter,
|
||||
mipfilter, colorkey, srcinfo, palette, texture);
|
||||
TRACE("device %p, srcfile %s, width %u, height %u, miplevels %u, usage %#x, format %#x, "
|
||||
"pool %#x, filter %#x, mipfilter %#x, colorkey 0x%08x, srcinfo %p, palette %p, texture %p.\n",
|
||||
device, debugstr_w(srcfile), width, height, miplevels, usage, format,
|
||||
pool, filter, mipfilter, colorkey, srcinfo, palette, texture);
|
||||
|
||||
if (!srcfile)
|
||||
return D3DERR_INVALIDCALL;
|
||||
|
@ -715,13 +750,14 @@ HRESULT WINAPI D3DXCreateTextureFromFileExA(struct IDirect3DDevice9 *device, con
|
|||
D3DPOOL pool, DWORD filter, DWORD mipfilter, D3DCOLOR colorkey, D3DXIMAGE_INFO *srcinfo,
|
||||
PALETTEENTRY *palette, struct IDirect3DTexture9 **texture)
|
||||
{
|
||||
LPWSTR widename;
|
||||
WCHAR *widename;
|
||||
HRESULT hr;
|
||||
DWORD len;
|
||||
|
||||
TRACE("(%p, %s, %u, %u, %u, %x, %x, %x, %u, %u, %x, %p, %p, %p): relay\n",
|
||||
device, debugstr_a(srcfile), width, height, miplevels, usage, format, pool, filter,
|
||||
mipfilter, colorkey, srcinfo, palette, texture);
|
||||
TRACE("device %p, srcfile %s, width %u, height %u, miplevels %u, usage %#x, format %#x, "
|
||||
"pool %#x, filter %#x, mipfilter %#x, colorkey 0x%08x, srcinfo %p, palette %p, texture %p.\n",
|
||||
device, debugstr_a(srcfile), width, height, miplevels, usage, format,
|
||||
pool, filter, mipfilter, colorkey, srcinfo, palette, texture);
|
||||
|
||||
if (!device || !srcfile || !texture)
|
||||
return D3DERR_INVALIDCALL;
|
||||
|
|
|
@ -78,7 +78,11 @@ static const struct pixel_format_desc formats[] =
|
|||
{D3DFMT_DXT3, { 0, 0, 0, 0}, { 0, 0, 0, 0}, 1, 4, 4, 16, FORMAT_DXT, NULL, NULL },
|
||||
{D3DFMT_DXT4, { 0, 0, 0, 0}, { 0, 0, 0, 0}, 1, 4, 4, 16, FORMAT_DXT, NULL, NULL },
|
||||
{D3DFMT_DXT5, { 0, 0, 0, 0}, { 0, 0, 0, 0}, 1, 4, 4, 16, FORMAT_DXT, NULL, NULL },
|
||||
{D3DFMT_R16F, { 0, 16, 0, 0}, { 0, 0, 0, 0}, 2, 1, 1, 2, FORMAT_ARGBF16, NULL, NULL },
|
||||
{D3DFMT_G16R16F, { 0, 16, 16, 0}, { 0, 0, 16, 0}, 4, 1, 1, 4, FORMAT_ARGBF16, NULL, NULL },
|
||||
{D3DFMT_A16B16G16R16F, {16, 16, 16, 16}, {48, 0, 16, 32}, 8, 1, 1, 8, FORMAT_ARGBF16, NULL, NULL },
|
||||
{D3DFMT_R32F, { 0, 32, 0, 0}, { 0, 0, 0, 0}, 4, 1, 1, 4, FORMAT_ARGBF, NULL, NULL },
|
||||
{D3DFMT_G32R32F, { 0, 32, 32, 0}, { 0, 0, 32, 0}, 8, 1, 1, 8, FORMAT_ARGBF, NULL, NULL },
|
||||
{D3DFMT_A32B32G32R32F, {32, 32, 32, 32}, {96, 0, 32, 64}, 16, 1, 1, 16, FORMAT_ARGBF, NULL, NULL },
|
||||
{D3DFMT_P8, { 8, 8, 8, 8}, { 0, 0, 0, 0}, 1, 1, 1, 1, FORMAT_INDEX, NULL, index_to_rgba},
|
||||
/* marks last element */
|
||||
|
@ -153,7 +157,7 @@ error:
|
|||
* The memory doesn't need to be freed by the caller manually
|
||||
*
|
||||
*/
|
||||
HRESULT load_resource_into_memory(HMODULE module, HRSRC resinfo, LPVOID *buffer, DWORD *length)
|
||||
HRESULT load_resource_into_memory(HMODULE module, HRSRC resinfo, void **buffer, DWORD *length)
|
||||
{
|
||||
HGLOBAL resource;
|
||||
|
||||
|
@ -282,7 +286,7 @@ const char *debug_d3dxparameter_registerset(D3DXREGISTER_SET r)
|
|||
#undef WINE_D3DX_TO_STR
|
||||
|
||||
/* parameter type conversion helpers */
|
||||
static BOOL get_bool(D3DXPARAMETER_TYPE type, LPCVOID data)
|
||||
static BOOL get_bool(D3DXPARAMETER_TYPE type, const void *data)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
|
@ -300,12 +304,12 @@ static BOOL get_bool(D3DXPARAMETER_TYPE type, LPCVOID data)
|
|||
}
|
||||
}
|
||||
|
||||
static INT get_int(D3DXPARAMETER_TYPE type, LPCVOID data)
|
||||
static INT get_int(D3DXPARAMETER_TYPE type, const void *data)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case D3DXPT_FLOAT:
|
||||
return *(FLOAT *)data;
|
||||
return (INT)(*(FLOAT *)data);
|
||||
|
||||
case D3DXPT_INT:
|
||||
case D3DXPT_VOID:
|
||||
|
@ -320,7 +324,7 @@ static INT get_int(D3DXPARAMETER_TYPE type, LPCVOID data)
|
|||
}
|
||||
}
|
||||
|
||||
static FLOAT get_float(D3DXPARAMETER_TYPE type, LPCVOID data)
|
||||
static FLOAT get_float(D3DXPARAMETER_TYPE type, const void *data)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
|
@ -329,10 +333,10 @@ static FLOAT get_float(D3DXPARAMETER_TYPE type, LPCVOID data)
|
|||
return *(FLOAT *)data;
|
||||
|
||||
case D3DXPT_INT:
|
||||
return *(INT *)data;
|
||||
return (FLOAT)(*(INT *)data);
|
||||
|
||||
case D3DXPT_BOOL:
|
||||
return get_bool(type, data);
|
||||
return (FLOAT)get_bool(type, data);
|
||||
|
||||
default:
|
||||
FIXME("Unhandled type %s.\n", debug_d3dxparameter_type(type));
|
||||
|
@ -340,10 +344,8 @@ static FLOAT get_float(D3DXPARAMETER_TYPE type, LPCVOID data)
|
|||
}
|
||||
}
|
||||
|
||||
void set_number(LPVOID outdata, D3DXPARAMETER_TYPE outtype, LPCVOID indata, D3DXPARAMETER_TYPE intype)
|
||||
void set_number(void *outdata, D3DXPARAMETER_TYPE outtype, const void *indata, D3DXPARAMETER_TYPE intype)
|
||||
{
|
||||
TRACE("Changing from type %s to type %s\n", debug_d3dxparameter_type(intype), debug_d3dxparameter_type(outtype));
|
||||
|
||||
if (outtype == intype)
|
||||
{
|
||||
*(DWORD *)outdata = *(DWORD *)indata;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
*/
|
||||
|
||||
#define WINE_FILEDESCRIPTION_STR "Wine D3DX9"
|
||||
#define WINE_FILENAME_STR "d3dx9.dll"
|
||||
#define WINE_FILENAME_STR "d3dx9_36.dll"
|
||||
#define WINE_FILEVERSION 9,19,949,2111
|
||||
#define WINE_FILEVERSION_STR "9.19.949.2111"
|
||||
#define WINE_PRODUCTVERSION 9,19,949,2111
|
||||
|
|
|
@ -235,6 +235,10 @@ HRESULT WINAPI D3DXLoadVolumeFromFileInMemory(IDirect3DVolume9 *dst_volume,
|
|||
D3DBOX box;
|
||||
D3DXIMAGE_INFO image_info;
|
||||
|
||||
TRACE("dst_volume %p, dst_palette %p, dst_box %p, src_data %p, src_data_size %u, src_box %p,\n",
|
||||
dst_volume, dst_palette, dst_box, src_data, src_data_size, src_box);
|
||||
TRACE("filter %#x, color_key %#x, src_info %p.\n", filter, color_key, src_info);
|
||||
|
||||
if (!dst_volume || !src_data) return D3DERR_INVALIDCALL;
|
||||
|
||||
hr = D3DXGetImageInfoFromFileInMemory(src_data, src_data_size, &image_info);
|
||||
|
|
|
@ -43,119 +43,119 @@ static HRESULT error_dxfile_to_d3dxfile(HRESULT error)
|
|||
}
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
struct d3dx9_file
|
||||
{
|
||||
ID3DXFile ID3DXFile_iface;
|
||||
LONG ref;
|
||||
IDirectXFile *dxfile;
|
||||
} ID3DXFileImpl;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
struct d3dx9_file_enum_object
|
||||
{
|
||||
ID3DXFileEnumObject ID3DXFileEnumObject_iface;
|
||||
LONG ref;
|
||||
ULONG nb_children;
|
||||
ID3DXFileData **children;
|
||||
} ID3DXFileEnumObjectImpl;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
struct d3dx9_file_data
|
||||
{
|
||||
ID3DXFileData ID3DXFileData_iface;
|
||||
LONG ref;
|
||||
BOOL reference;
|
||||
IDirectXFileData *dxfile_data;
|
||||
ULONG nb_children;
|
||||
ID3DXFileData **children;
|
||||
} ID3DXFileDataImpl;
|
||||
};
|
||||
|
||||
|
||||
static inline ID3DXFileImpl* impl_from_ID3DXFile(ID3DXFile *iface)
|
||||
static inline struct d3dx9_file *impl_from_ID3DXFile(ID3DXFile *iface)
|
||||
{
|
||||
return CONTAINING_RECORD(iface, ID3DXFileImpl, ID3DXFile_iface);
|
||||
return CONTAINING_RECORD(iface, struct d3dx9_file, ID3DXFile_iface);
|
||||
}
|
||||
|
||||
static inline ID3DXFileEnumObjectImpl* impl_from_ID3DXFileEnumObject(ID3DXFileEnumObject *iface)
|
||||
static inline struct d3dx9_file_enum_object *impl_from_ID3DXFileEnumObject(ID3DXFileEnumObject *iface)
|
||||
{
|
||||
return CONTAINING_RECORD(iface, ID3DXFileEnumObjectImpl, ID3DXFileEnumObject_iface);
|
||||
return CONTAINING_RECORD(iface, struct d3dx9_file_enum_object, ID3DXFileEnumObject_iface);
|
||||
}
|
||||
|
||||
static inline ID3DXFileDataImpl* impl_from_ID3DXFileData(ID3DXFileData *iface)
|
||||
static inline struct d3dx9_file_data *impl_from_ID3DXFileData(ID3DXFileData *iface)
|
||||
{
|
||||
return CONTAINING_RECORD(iface, ID3DXFileDataImpl, ID3DXFileData_iface);
|
||||
return CONTAINING_RECORD(iface, struct d3dx9_file_data, ID3DXFileData_iface);
|
||||
}
|
||||
|
||||
/*** IUnknown methods ***/
|
||||
|
||||
static HRESULT WINAPI ID3DXFileDataImpl_QueryInterface(ID3DXFileData *iface, REFIID riid, void **ret_iface)
|
||||
static HRESULT WINAPI d3dx9_file_data_QueryInterface(ID3DXFileData *iface, REFIID riid, void **out)
|
||||
{
|
||||
TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), ret_iface);
|
||||
TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
|
||||
|
||||
if (IsEqualGUID(riid, &IID_IUnknown) ||
|
||||
IsEqualGUID(riid, &IID_ID3DXFileData))
|
||||
if (IsEqualGUID(riid, &IID_ID3DXFileData)
|
||||
|| IsEqualGUID(riid, &IID_IUnknown))
|
||||
{
|
||||
iface->lpVtbl->AddRef(iface);
|
||||
*ret_iface = iface;
|
||||
*out = iface;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
WARN("(%p)->(%s, %p), not found\n", iface, debugstr_guid(riid), ret_iface);
|
||||
*ret_iface = NULL;
|
||||
WARN("Interface %s not found.\n", debugstr_guid(riid));
|
||||
|
||||
*out = NULL;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
static ULONG WINAPI ID3DXFileDataImpl_AddRef(ID3DXFileData *iface)
|
||||
static ULONG WINAPI d3dx9_file_data_AddRef(ID3DXFileData *iface)
|
||||
{
|
||||
ID3DXFileDataImpl *This = impl_from_ID3DXFileData(iface);
|
||||
ULONG ref = InterlockedIncrement(&This->ref);
|
||||
struct d3dx9_file_data *file_data = impl_from_ID3DXFileData(iface);
|
||||
ULONG refcount = InterlockedIncrement(&file_data->ref);
|
||||
|
||||
TRACE("(%p)->(): new ref = %u\n", iface, ref);
|
||||
TRACE("%p increasing refcount to %u.\n", file_data, refcount);
|
||||
|
||||
return ref;
|
||||
return refcount;
|
||||
}
|
||||
|
||||
static ULONG WINAPI ID3DXFileDataImpl_Release(ID3DXFileData *iface)
|
||||
static ULONG WINAPI d3dx9_file_data_Release(ID3DXFileData *iface)
|
||||
{
|
||||
ID3DXFileDataImpl *This = impl_from_ID3DXFileData(iface);
|
||||
ULONG ref = InterlockedDecrement(&This->ref);
|
||||
struct d3dx9_file_data *file_data = impl_from_ID3DXFileData(iface);
|
||||
ULONG refcount = InterlockedDecrement(&file_data->ref);
|
||||
|
||||
TRACE("(%p)->(): new ref = %u\n", iface, ref);
|
||||
TRACE("%p decreasing refcount to %u.\n", file_data, refcount);
|
||||
|
||||
if (!ref)
|
||||
if (!refcount)
|
||||
{
|
||||
ULONG i;
|
||||
|
||||
for (i = 0; i < This->nb_children; i++)
|
||||
(This->children[i])->lpVtbl->Release(This->children[i]);
|
||||
HeapFree(GetProcessHeap(), 0, This->children);
|
||||
IDirectXFileData_Release(This->dxfile_data);
|
||||
HeapFree(GetProcessHeap(), 0, This);
|
||||
for (i = 0; i < file_data->nb_children; ++i)
|
||||
{
|
||||
ID3DXFileData *child = file_data->children[i];
|
||||
child->lpVtbl->Release(child);
|
||||
}
|
||||
HeapFree(GetProcessHeap(), 0, file_data->children);
|
||||
IDirectXFileData_Release(file_data->dxfile_data);
|
||||
HeapFree(GetProcessHeap(), 0, file_data);
|
||||
}
|
||||
|
||||
return ref;
|
||||
return refcount;
|
||||
}
|
||||
|
||||
|
||||
/*** ID3DXFileData methods ***/
|
||||
|
||||
static HRESULT WINAPI ID3DXFileDataImpl_GetEnum(ID3DXFileData *iface, ID3DXFileEnumObject **enum_object)
|
||||
static HRESULT WINAPI d3dx9_file_data_GetEnum(ID3DXFileData *iface, ID3DXFileEnumObject **enum_object)
|
||||
{
|
||||
FIXME("(%p)->(%p): stub\n", iface, enum_object);
|
||||
FIXME("iface %p, enum_object %p stub!\n", iface, enum_object);
|
||||
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
|
||||
static HRESULT WINAPI ID3DXFileDataImpl_GetName(ID3DXFileData *iface, char *name, SIZE_T *size)
|
||||
static HRESULT WINAPI d3dx9_file_data_GetName(ID3DXFileData *iface, char *name, SIZE_T *size)
|
||||
{
|
||||
ID3DXFileDataImpl *This = impl_from_ID3DXFileData(iface);
|
||||
struct d3dx9_file_data *file_data = impl_from_ID3DXFileData(iface);
|
||||
DWORD dxfile_size;
|
||||
HRESULT ret;
|
||||
|
||||
TRACE("(%p)->(%p, %p)\n", iface, name, size);
|
||||
TRACE("iface %p, name %p, size %p.\n", iface, name, size);
|
||||
|
||||
if (!size)
|
||||
return D3DXFERR_BADVALUE;
|
||||
|
||||
dxfile_size = *size;
|
||||
|
||||
ret = IDirectXFileData_GetName(This->dxfile_data, name, &dxfile_size);
|
||||
ret = IDirectXFileData_GetName(file_data->dxfile_data, name, &dxfile_size);
|
||||
if (ret != DXFILE_OK)
|
||||
return error_dxfile_to_d3dxfile(ret);
|
||||
|
||||
|
@ -173,37 +173,35 @@ static HRESULT WINAPI ID3DXFileDataImpl_GetName(ID3DXFileData *iface, char *name
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
static HRESULT WINAPI ID3DXFileDataImpl_GetId(ID3DXFileData *iface, GUID *guid)
|
||||
static HRESULT WINAPI d3dx9_file_data_GetId(ID3DXFileData *iface, GUID *guid)
|
||||
{
|
||||
ID3DXFileDataImpl *This = impl_from_ID3DXFileData(iface);
|
||||
struct d3dx9_file_data *file_data = impl_from_ID3DXFileData(iface);
|
||||
HRESULT ret;
|
||||
|
||||
TRACE("(%p)->(%p)\n", iface, guid);
|
||||
TRACE("iface %p, guid %p.\n", iface, guid);
|
||||
|
||||
if (!guid)
|
||||
return E_POINTER;
|
||||
|
||||
ret = IDirectXFileData_GetId(This->dxfile_data, guid);
|
||||
ret = IDirectXFileData_GetId(file_data->dxfile_data, guid);
|
||||
if (ret != DXFILE_OK)
|
||||
return error_dxfile_to_d3dxfile(ret);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
static HRESULT WINAPI ID3DXFileDataImpl_Lock(ID3DXFileData *iface, SIZE_T *size, const void **data)
|
||||
static HRESULT WINAPI d3dx9_file_data_Lock(ID3DXFileData *iface, SIZE_T *size, const void **data)
|
||||
{
|
||||
ID3DXFileDataImpl *This = impl_from_ID3DXFileData(iface);
|
||||
struct d3dx9_file_data *file_data = impl_from_ID3DXFileData(iface);
|
||||
DWORD dxfile_size;
|
||||
HRESULT ret;
|
||||
|
||||
TRACE("(%p)->(%p, %p)\n", iface, size, data);
|
||||
TRACE("iface %p, size %p, data %p.\n", iface, size, data);
|
||||
|
||||
if (!size || !data)
|
||||
return E_POINTER;
|
||||
|
||||
ret = IDirectXFileData_GetData(This->dxfile_data, NULL, &dxfile_size, (void**)data);
|
||||
ret = IDirectXFileData_GetData(file_data->dxfile_data, NULL, &dxfile_size, (void **)data);
|
||||
if (ret != DXFILE_OK)
|
||||
return error_dxfile_to_d3dxfile(ret);
|
||||
|
||||
|
@ -212,26 +210,24 @@ static HRESULT WINAPI ID3DXFileDataImpl_Lock(ID3DXFileData *iface, SIZE_T *size,
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
static HRESULT WINAPI ID3DXFileDataImpl_Unlock(ID3DXFileData *iface)
|
||||
static HRESULT WINAPI d3dx9_file_data_Unlock(ID3DXFileData *iface)
|
||||
{
|
||||
TRACE("(%p)->()\n", iface);
|
||||
TRACE("iface %p.\n", iface);
|
||||
|
||||
/* Nothing to do */
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
static HRESULT WINAPI ID3DXFileDataImpl_GetType(ID3DXFileData *iface, GUID *guid)
|
||||
static HRESULT WINAPI d3dx9_file_data_GetType(ID3DXFileData *iface, GUID *guid)
|
||||
{
|
||||
ID3DXFileDataImpl *This = impl_from_ID3DXFileData(iface);
|
||||
struct d3dx9_file_data *file_data = impl_from_ID3DXFileData(iface);
|
||||
const GUID *dxfile_guid;
|
||||
HRESULT ret;
|
||||
|
||||
TRACE("(%p)->(%p)\n", iface, guid);
|
||||
TRACE("iface %p, guid %p.\n", iface, guid);
|
||||
|
||||
ret = IDirectXFileData_GetType(This->dxfile_data, &dxfile_guid);
|
||||
ret = IDirectXFileData_GetType(file_data->dxfile_data, &dxfile_guid);
|
||||
if (ret != DXFILE_OK)
|
||||
return error_dxfile_to_d3dxfile(ret);
|
||||
|
||||
|
@ -240,72 +236,67 @@ static HRESULT WINAPI ID3DXFileDataImpl_GetType(ID3DXFileData *iface, GUID *guid
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
static BOOL WINAPI ID3DXFileDataImpl_IsReference(ID3DXFileData *iface)
|
||||
static BOOL WINAPI d3dx9_file_data_IsReference(ID3DXFileData *iface)
|
||||
{
|
||||
ID3DXFileDataImpl *This = impl_from_ID3DXFileData(iface);
|
||||
struct d3dx9_file_data *file_data = impl_from_ID3DXFileData(iface);
|
||||
|
||||
TRACE("(%p)->()\n", iface);
|
||||
TRACE("iface %p.\n", iface);
|
||||
|
||||
return This->reference;
|
||||
return file_data->reference;
|
||||
}
|
||||
|
||||
|
||||
static HRESULT WINAPI ID3DXFileDataImpl_GetChildren(ID3DXFileData *iface, SIZE_T *children)
|
||||
static HRESULT WINAPI d3dx9_file_data_GetChildren(ID3DXFileData *iface, SIZE_T *children)
|
||||
{
|
||||
ID3DXFileDataImpl *This = impl_from_ID3DXFileData(iface);
|
||||
struct d3dx9_file_data *file_data = impl_from_ID3DXFileData(iface);
|
||||
|
||||
TRACE("(%p)->(%p)\n", iface, children);
|
||||
TRACE("iface %p, children %p.\n", iface, children);
|
||||
|
||||
if (!children)
|
||||
return E_POINTER;
|
||||
|
||||
*children = This->nb_children;
|
||||
*children = file_data->nb_children;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
static HRESULT WINAPI ID3DXFileDataImpl_GetChild(ID3DXFileData *iface, SIZE_T id, ID3DXFileData **object)
|
||||
static HRESULT WINAPI d3dx9_file_data_GetChild(ID3DXFileData *iface, SIZE_T id, ID3DXFileData **object)
|
||||
{
|
||||
ID3DXFileDataImpl *This = impl_from_ID3DXFileData(iface);
|
||||
struct d3dx9_file_data *file_data = impl_from_ID3DXFileData(iface);
|
||||
|
||||
TRACE("(%p)->(%lu, %p)\n", iface, id, object);
|
||||
TRACE("iface %p, id %#lx, object %p.\n", iface, id, object);
|
||||
|
||||
if (!object)
|
||||
return E_POINTER;
|
||||
|
||||
*object = This->children[id];
|
||||
*object = file_data->children[id];
|
||||
(*object)->lpVtbl->AddRef(*object);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
static const ID3DXFileDataVtbl ID3DXFileData_Vtbl =
|
||||
static const ID3DXFileDataVtbl d3dx9_file_data_vtbl =
|
||||
{
|
||||
ID3DXFileDataImpl_QueryInterface,
|
||||
ID3DXFileDataImpl_AddRef,
|
||||
ID3DXFileDataImpl_Release,
|
||||
ID3DXFileDataImpl_GetEnum,
|
||||
ID3DXFileDataImpl_GetName,
|
||||
ID3DXFileDataImpl_GetId,
|
||||
ID3DXFileDataImpl_Lock,
|
||||
ID3DXFileDataImpl_Unlock,
|
||||
ID3DXFileDataImpl_GetType,
|
||||
ID3DXFileDataImpl_IsReference,
|
||||
ID3DXFileDataImpl_GetChildren,
|
||||
ID3DXFileDataImpl_GetChild
|
||||
d3dx9_file_data_QueryInterface,
|
||||
d3dx9_file_data_AddRef,
|
||||
d3dx9_file_data_Release,
|
||||
d3dx9_file_data_GetEnum,
|
||||
d3dx9_file_data_GetName,
|
||||
d3dx9_file_data_GetId,
|
||||
d3dx9_file_data_Lock,
|
||||
d3dx9_file_data_Unlock,
|
||||
d3dx9_file_data_GetType,
|
||||
d3dx9_file_data_IsReference,
|
||||
d3dx9_file_data_GetChildren,
|
||||
d3dx9_file_data_GetChild,
|
||||
};
|
||||
|
||||
|
||||
static HRESULT ID3DXFileDataImpl_Create(IDirectXFileObject *dxfile_object, ID3DXFileData **ret_iface)
|
||||
static HRESULT d3dx9_file_data_create(IDirectXFileObject *dxfile_object, ID3DXFileData **ret_iface)
|
||||
{
|
||||
ID3DXFileDataImpl *object;
|
||||
struct d3dx9_file_data *object;
|
||||
IDirectXFileObject *data_object;
|
||||
HRESULT ret;
|
||||
|
||||
TRACE("(%p, %p)\n", dxfile_object, ret_iface);
|
||||
TRACE("dxfile_object %p, ret_iface %p.\n", dxfile_object, ret_iface);
|
||||
|
||||
*ret_iface = NULL;
|
||||
|
||||
|
@ -313,7 +304,7 @@ static HRESULT ID3DXFileDataImpl_Create(IDirectXFileObject *dxfile_object, ID3DX
|
|||
if (!object)
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
object->ID3DXFileData_iface.lpVtbl = &ID3DXFileData_Vtbl;
|
||||
object->ID3DXFileData_iface.lpVtbl = &d3dx9_file_data_vtbl;
|
||||
object->ref = 1;
|
||||
|
||||
ret = IDirectXFileObject_QueryInterface(dxfile_object, &IID_IDirectXFileData, (void **)&object->dxfile_data);
|
||||
|
@ -351,8 +342,7 @@ static HRESULT ID3DXFileDataImpl_Create(IDirectXFileObject *dxfile_object, ID3DX
|
|||
ret = E_OUTOFMEMORY;
|
||||
break;
|
||||
}
|
||||
ret = ID3DXFileDataImpl_Create(data_object, &object->children[object->nb_children]);
|
||||
if (ret != S_OK)
|
||||
if (FAILED(ret = d3dx9_file_data_create(data_object, &object->children[object->nb_children])))
|
||||
break;
|
||||
object->nb_children++;
|
||||
}
|
||||
|
@ -370,181 +360,170 @@ static HRESULT ID3DXFileDataImpl_Create(IDirectXFileObject *dxfile_object, ID3DX
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
/*** IUnknown methods ***/
|
||||
|
||||
static HRESULT WINAPI ID3DXFileEnumObjectImpl_QueryInterface(ID3DXFileEnumObject *iface, REFIID riid, void **ret_iface)
|
||||
static HRESULT WINAPI d3dx9_file_enum_object_QueryInterface(ID3DXFileEnumObject *iface, REFIID riid, void **out)
|
||||
{
|
||||
TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), ret_iface);
|
||||
TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
|
||||
|
||||
if (IsEqualGUID(riid, &IID_IUnknown) ||
|
||||
IsEqualGUID(riid, &IID_ID3DXFileEnumObject))
|
||||
if (IsEqualGUID(riid, &IID_ID3DXFileEnumObject)
|
||||
|| IsEqualGUID(riid, &IID_IUnknown))
|
||||
{
|
||||
iface->lpVtbl->AddRef(iface);
|
||||
*ret_iface = iface;
|
||||
*out = iface;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
WARN("(%p)->(%s, %p), not found\n", iface, debugstr_guid(riid), ret_iface);
|
||||
*ret_iface = NULL;
|
||||
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
|
||||
|
||||
*out = NULL;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
static ULONG WINAPI ID3DXFileEnumObjectImpl_AddRef(ID3DXFileEnumObject *iface)
|
||||
static ULONG WINAPI d3dx9_file_enum_object_AddRef(ID3DXFileEnumObject *iface)
|
||||
{
|
||||
ID3DXFileEnumObjectImpl *This = impl_from_ID3DXFileEnumObject(iface);
|
||||
ULONG ref = InterlockedIncrement(&This->ref);
|
||||
struct d3dx9_file_enum_object *file_enum = impl_from_ID3DXFileEnumObject(iface);
|
||||
ULONG refcount = InterlockedIncrement(&file_enum->ref);
|
||||
|
||||
TRACE("(%p)->(): new ref = %u\n", iface, ref);
|
||||
TRACE("%p increasing refcount to %u.\n", file_enum, refcount);
|
||||
|
||||
return ref;
|
||||
return refcount;
|
||||
}
|
||||
|
||||
static ULONG WINAPI ID3DXFileEnumObjectImpl_Release(ID3DXFileEnumObject *iface)
|
||||
static ULONG WINAPI d3dx9_file_enum_object_Release(ID3DXFileEnumObject *iface)
|
||||
{
|
||||
ID3DXFileEnumObjectImpl *This = impl_from_ID3DXFileEnumObject(iface);
|
||||
ULONG ref = InterlockedDecrement(&This->ref);
|
||||
struct d3dx9_file_enum_object *file_enum = impl_from_ID3DXFileEnumObject(iface);
|
||||
ULONG refcount = InterlockedDecrement(&file_enum->ref);
|
||||
|
||||
TRACE("(%p)->(): new ref = %u\n", iface, ref);
|
||||
TRACE("%p decreasing refcount to %u.\n", file_enum, refcount);
|
||||
|
||||
if (!ref)
|
||||
if (!refcount)
|
||||
{
|
||||
ULONG i;
|
||||
|
||||
for (i = 0; i < This->nb_children; i++)
|
||||
(This->children[i])->lpVtbl->Release(This->children[i]);
|
||||
HeapFree(GetProcessHeap(), 0, This->children);
|
||||
HeapFree(GetProcessHeap(), 0, This);
|
||||
for (i = 0; i < file_enum->nb_children; ++i)
|
||||
{
|
||||
ID3DXFileData *child = file_enum->children[i];
|
||||
child->lpVtbl->Release(child);
|
||||
}
|
||||
HeapFree(GetProcessHeap(), 0, file_enum->children);
|
||||
HeapFree(GetProcessHeap(), 0, file_enum);
|
||||
}
|
||||
|
||||
return ref;
|
||||
return refcount;
|
||||
}
|
||||
|
||||
|
||||
/*** ID3DXFileEnumObject methods ***/
|
||||
|
||||
static HRESULT WINAPI ID3DXFileEnumObjectImpl_GetFile(ID3DXFileEnumObject *iface, ID3DXFile **file)
|
||||
static HRESULT WINAPI d3dx9_file_enum_object_GetFile(ID3DXFileEnumObject *iface, ID3DXFile **file)
|
||||
{
|
||||
FIXME("(%p)->(%p): stub\n", iface, file);
|
||||
FIXME("iface %p, file %p stub!\n", iface, file);
|
||||
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
|
||||
static HRESULT WINAPI ID3DXFileEnumObjectImpl_GetChildren(ID3DXFileEnumObject *iface, SIZE_T *children)
|
||||
static HRESULT WINAPI d3dx9_file_enum_object_GetChildren(ID3DXFileEnumObject *iface, SIZE_T *children)
|
||||
{
|
||||
ID3DXFileEnumObjectImpl *This = impl_from_ID3DXFileEnumObject(iface);
|
||||
struct d3dx9_file_enum_object *file_enum = impl_from_ID3DXFileEnumObject(iface);
|
||||
|
||||
TRACE("(%p)->(%p)\n", iface, children);
|
||||
TRACE("iface %p, children %p.\n", iface, children);
|
||||
|
||||
if (!children)
|
||||
return E_POINTER;
|
||||
|
||||
*children = This->nb_children;
|
||||
*children = file_enum->nb_children;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
static HRESULT WINAPI ID3DXFileEnumObjectImpl_GetChild(ID3DXFileEnumObject *iface, SIZE_T id, ID3DXFileData **object)
|
||||
static HRESULT WINAPI d3dx9_file_enum_object_GetChild(ID3DXFileEnumObject *iface, SIZE_T id, ID3DXFileData **object)
|
||||
{
|
||||
ID3DXFileEnumObjectImpl *This = impl_from_ID3DXFileEnumObject(iface);
|
||||
struct d3dx9_file_enum_object *file_enum = impl_from_ID3DXFileEnumObject(iface);
|
||||
|
||||
TRACE("(%p)->(%lu, %p)\n", iface, id, object);
|
||||
TRACE("iface %p, id %#lx, object %p.\n", iface, id, object);
|
||||
|
||||
if (!object)
|
||||
return E_POINTER;
|
||||
|
||||
*object = This->children[id];
|
||||
*object = file_enum->children[id];
|
||||
(*object)->lpVtbl->AddRef(*object);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
static HRESULT WINAPI ID3DXFileEnumObjectImpl_GetDataObjectById(ID3DXFileEnumObject *iface, REFGUID guid, ID3DXFileData **object)
|
||||
static HRESULT WINAPI d3dx9_file_enum_object_GetDataObjectById(ID3DXFileEnumObject *iface,
|
||||
REFGUID guid, ID3DXFileData **object)
|
||||
{
|
||||
FIXME("(%p)->(%s, %p): stub\n", iface, debugstr_guid(guid), object);
|
||||
FIXME("iface %p, guid %s, object %p stub!\n", iface, debugstr_guid(guid), object);
|
||||
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
|
||||
static HRESULT WINAPI ID3DXFileEnumObjectImpl_GetDataObjectByName(ID3DXFileEnumObject *iface, const char *name, ID3DXFileData **object)
|
||||
static HRESULT WINAPI d3dx9_file_enum_object_GetDataObjectByName(ID3DXFileEnumObject *iface,
|
||||
const char *name, ID3DXFileData **object)
|
||||
{
|
||||
FIXME("(%p)->(%s, %p): stub\n", iface, debugstr_a(name), object);
|
||||
FIXME("iface %p, name %s, object %p stub!\n", iface, debugstr_a(name), object);
|
||||
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
|
||||
static const ID3DXFileEnumObjectVtbl ID3DXFileEnumObject_Vtbl =
|
||||
static const ID3DXFileEnumObjectVtbl d3dx9_file_enum_object_vtbl =
|
||||
{
|
||||
ID3DXFileEnumObjectImpl_QueryInterface,
|
||||
ID3DXFileEnumObjectImpl_AddRef,
|
||||
ID3DXFileEnumObjectImpl_Release,
|
||||
ID3DXFileEnumObjectImpl_GetFile,
|
||||
ID3DXFileEnumObjectImpl_GetChildren,
|
||||
ID3DXFileEnumObjectImpl_GetChild,
|
||||
ID3DXFileEnumObjectImpl_GetDataObjectById,
|
||||
ID3DXFileEnumObjectImpl_GetDataObjectByName
|
||||
d3dx9_file_enum_object_QueryInterface,
|
||||
d3dx9_file_enum_object_AddRef,
|
||||
d3dx9_file_enum_object_Release,
|
||||
d3dx9_file_enum_object_GetFile,
|
||||
d3dx9_file_enum_object_GetChildren,
|
||||
d3dx9_file_enum_object_GetChild,
|
||||
d3dx9_file_enum_object_GetDataObjectById,
|
||||
d3dx9_file_enum_object_GetDataObjectByName,
|
||||
};
|
||||
|
||||
|
||||
/*** IUnknown methods ***/
|
||||
|
||||
static HRESULT WINAPI ID3DXFileImpl_QueryInterface(ID3DXFile *iface, REFIID riid, void **ret_iface)
|
||||
static HRESULT WINAPI d3dx9_file_QueryInterface(ID3DXFile *iface, REFIID riid, void **out)
|
||||
{
|
||||
TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), ret_iface);
|
||||
TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
|
||||
|
||||
if (IsEqualGUID(riid, &IID_IUnknown) ||
|
||||
IsEqualGUID(riid, &IID_ID3DXFile))
|
||||
if (IsEqualGUID(riid, &IID_ID3DXFile)
|
||||
|| IsEqualGUID(riid, &IID_IUnknown))
|
||||
{
|
||||
iface->lpVtbl->AddRef(iface);
|
||||
*ret_iface = iface;
|
||||
*out = iface;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
WARN("(%p)->(%s, %p), not found\n", iface, debugstr_guid(riid), ret_iface);
|
||||
*ret_iface = NULL;
|
||||
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
|
||||
|
||||
*out = NULL;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
|
||||
static ULONG WINAPI ID3DXFileImpl_AddRef(ID3DXFile *iface)
|
||||
static ULONG WINAPI d3dx9_file_AddRef(ID3DXFile *iface)
|
||||
{
|
||||
ID3DXFileImpl *This = impl_from_ID3DXFile(iface);
|
||||
ULONG ref = InterlockedIncrement(&This->ref);
|
||||
struct d3dx9_file *file = impl_from_ID3DXFile(iface);
|
||||
ULONG refcount = InterlockedIncrement(&file->ref);
|
||||
|
||||
TRACE("(%p)->(): new ref = %u\n", iface, ref);
|
||||
TRACE("%p increasing refcount to %u.\n", file, refcount);
|
||||
|
||||
return ref;
|
||||
return refcount;
|
||||
}
|
||||
|
||||
|
||||
static ULONG WINAPI ID3DXFileImpl_Release(ID3DXFile *iface)
|
||||
static ULONG WINAPI d3dx9_file_Release(ID3DXFile *iface)
|
||||
{
|
||||
ID3DXFileImpl *This = impl_from_ID3DXFile(iface);
|
||||
ULONG ref = InterlockedDecrement(&This->ref);
|
||||
struct d3dx9_file *file = impl_from_ID3DXFile(iface);
|
||||
ULONG refcount = InterlockedDecrement(&file->ref);
|
||||
|
||||
TRACE("(%p)->(): new ref = %u\n", iface, ref);
|
||||
TRACE("%p decreasing refcount to %u.\n", file, refcount);
|
||||
|
||||
if (!ref)
|
||||
if (!refcount)
|
||||
{
|
||||
IDirectXFile_Release(This->dxfile);
|
||||
HeapFree(GetProcessHeap(), 0, This);
|
||||
IDirectXFile_Release(file->dxfile);
|
||||
HeapFree(GetProcessHeap(), 0, file);
|
||||
}
|
||||
|
||||
return ref;
|
||||
return refcount;
|
||||
}
|
||||
|
||||
|
||||
/*** ID3DXFile methods ***/
|
||||
|
||||
static HRESULT WINAPI ID3DXFileImpl_CreateEnumObject(ID3DXFile *iface, const void *source, D3DXF_FILELOADOPTIONS options, ID3DXFileEnumObject **enum_object)
|
||||
static HRESULT WINAPI d3dx9_file_CreateEnumObject(ID3DXFile *iface, const void *source,
|
||||
D3DXF_FILELOADOPTIONS options, ID3DXFileEnumObject **enum_object)
|
||||
{
|
||||
ID3DXFileImpl *This = impl_from_ID3DXFile(iface);
|
||||
ID3DXFileEnumObjectImpl *object;
|
||||
struct d3dx9_file *file = impl_from_ID3DXFile(iface);
|
||||
struct d3dx9_file_enum_object *object;
|
||||
IDirectXFileEnumObject *dxfile_enum_object;
|
||||
void *dxfile_source;
|
||||
DXFILELOADOPTIONS dxfile_options;
|
||||
|
@ -553,7 +532,7 @@ static HRESULT WINAPI ID3DXFileImpl_CreateEnumObject(ID3DXFile *iface, const voi
|
|||
IDirectXFileData *data_object;
|
||||
HRESULT ret;
|
||||
|
||||
TRACE("(%p)->(%p, %x, %p)\n", iface, source, options, enum_object);
|
||||
TRACE("iface %p, source %p, options %#x, enum_object %p.\n", iface, source, options, enum_object);
|
||||
|
||||
if (!enum_object)
|
||||
return E_POINTER;
|
||||
|
@ -594,10 +573,10 @@ static HRESULT WINAPI ID3DXFileImpl_CreateEnumObject(ID3DXFile *iface, const voi
|
|||
if (!object)
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
object->ID3DXFileEnumObject_iface.lpVtbl = &ID3DXFileEnumObject_Vtbl;
|
||||
object->ID3DXFileEnumObject_iface.lpVtbl = &d3dx9_file_enum_object_vtbl;
|
||||
object->ref = 1;
|
||||
|
||||
ret = IDirectXFile_CreateEnumObject(This->dxfile, dxfile_source, dxfile_options, &dxfile_enum_object);
|
||||
ret = IDirectXFile_CreateEnumObject(file->dxfile, dxfile_source, dxfile_options, &dxfile_enum_object);
|
||||
|
||||
if (ret != S_OK)
|
||||
{
|
||||
|
@ -617,8 +596,8 @@ static HRESULT WINAPI ID3DXFileImpl_CreateEnumObject(ID3DXFile *iface, const voi
|
|||
ret = E_OUTOFMEMORY;
|
||||
break;
|
||||
}
|
||||
ret = ID3DXFileDataImpl_Create((IDirectXFileObject*)data_object, &object->children[object->nb_children]);
|
||||
if (ret != S_OK)
|
||||
if (FAILED(ret = d3dx9_file_data_create((IDirectXFileObject*)data_object,
|
||||
&object->children[object->nb_children])))
|
||||
break;
|
||||
object->nb_children++;
|
||||
}
|
||||
|
@ -635,23 +614,23 @@ static HRESULT WINAPI ID3DXFileImpl_CreateEnumObject(ID3DXFile *iface, const voi
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
static HRESULT WINAPI ID3DXFileImpl_CreateSaveObject(ID3DXFile *iface, const void *data, D3DXF_FILESAVEOPTIONS options, D3DXF_FILEFORMAT format, ID3DXFileSaveObject **save_object)
|
||||
static HRESULT WINAPI d3dx9_file_CreateSaveObject(ID3DXFile *iface, const void *data,
|
||||
D3DXF_FILESAVEOPTIONS options, D3DXF_FILEFORMAT format, ID3DXFileSaveObject **save_object)
|
||||
{
|
||||
FIXME("(%p)->(%p, %x, %u, %p): stub\n", iface, data, options, format, save_object);
|
||||
FIXME("iface %p, data %p, options %#x, format %#x, save_object %p stub!\n",
|
||||
iface, data, options, format, save_object);
|
||||
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
|
||||
static HRESULT WINAPI ID3DXFileImpl_RegisterTemplates(ID3DXFile *iface, const void *data, SIZE_T size)
|
||||
static HRESULT WINAPI d3dx9_file_RegisterTemplates(ID3DXFile *iface, const void *data, SIZE_T size)
|
||||
{
|
||||
ID3DXFileImpl *This = impl_from_ID3DXFile(iface);
|
||||
struct d3dx9_file *file = impl_from_ID3DXFile(iface);
|
||||
HRESULT ret;
|
||||
|
||||
TRACE("(%p)->(%p, %lu)\n", iface, data, size);
|
||||
TRACE("iface %p, data %p, size %lu.\n", iface, data, size);
|
||||
|
||||
ret = IDirectXFile_RegisterTemplates(This->dxfile, (void*)data, size);
|
||||
ret = IDirectXFile_RegisterTemplates(file->dxfile, (void *)data, size);
|
||||
if (ret != DXFILE_OK)
|
||||
{
|
||||
WARN("Error %#x\n", ret);
|
||||
|
@ -661,32 +640,30 @@ static HRESULT WINAPI ID3DXFileImpl_RegisterTemplates(ID3DXFile *iface, const vo
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
static HRESULT WINAPI ID3DXFileImpl_RegisterEnumTemplates(ID3DXFile *iface, ID3DXFileEnumObject *enum_object)
|
||||
static HRESULT WINAPI d3dx9_file_RegisterEnumTemplates(ID3DXFile *iface, ID3DXFileEnumObject *enum_object)
|
||||
{
|
||||
FIXME("(%p)->(%p): stub\n", iface, enum_object);
|
||||
FIXME("iface %p, enum_object %p stub!\n", iface, enum_object);
|
||||
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
|
||||
static const ID3DXFileVtbl ID3DXFile_Vtbl =
|
||||
static const ID3DXFileVtbl d3dx9_file_vtbl =
|
||||
{
|
||||
ID3DXFileImpl_QueryInterface,
|
||||
ID3DXFileImpl_AddRef,
|
||||
ID3DXFileImpl_Release,
|
||||
ID3DXFileImpl_CreateEnumObject,
|
||||
ID3DXFileImpl_CreateSaveObject,
|
||||
ID3DXFileImpl_RegisterTemplates,
|
||||
ID3DXFileImpl_RegisterEnumTemplates
|
||||
d3dx9_file_QueryInterface,
|
||||
d3dx9_file_AddRef,
|
||||
d3dx9_file_Release,
|
||||
d3dx9_file_CreateEnumObject,
|
||||
d3dx9_file_CreateSaveObject,
|
||||
d3dx9_file_RegisterTemplates,
|
||||
d3dx9_file_RegisterEnumTemplates,
|
||||
};
|
||||
|
||||
HRESULT WINAPI D3DXFileCreate(ID3DXFile **d3dxfile)
|
||||
{
|
||||
ID3DXFileImpl *object;
|
||||
struct d3dx9_file *object;
|
||||
HRESULT ret;
|
||||
|
||||
TRACE("(%p)\n", d3dxfile);
|
||||
TRACE("d3dxfile %p.\n", d3dxfile);
|
||||
|
||||
if (!d3dxfile)
|
||||
return E_POINTER;
|
||||
|
@ -706,7 +683,7 @@ HRESULT WINAPI D3DXFileCreate(ID3DXFile **d3dxfile)
|
|||
return E_FAIL;
|
||||
}
|
||||
|
||||
object->ID3DXFile_iface.lpVtbl = &ID3DXFile_Vtbl;
|
||||
object->ID3DXFile_iface.lpVtbl = &d3dx9_file_vtbl;
|
||||
object->ref = 1;
|
||||
|
||||
*d3dxfile = &object->ID3DXFile_iface;
|
||||
|
|
|
@ -31,7 +31,7 @@ reactos/dll/directx/wine/amstream # Synced to Wine-1.7.17
|
|||
reactos/dll/directx/wine/d3d8 # Synced to Wine-1.7.17
|
||||
reactos/dll/directx/wine/d3d9 # Synced to Wine-1.7.17
|
||||
reactos/dll/directx/wine/d3dcompiler_43 # Synced to Wine-1.7.17
|
||||
reactos/dll/directx/wine/d3dx9_24 => 43 # Synced to Wine-1.7.1
|
||||
reactos/dll/directx/wine/d3dx9_24 => 43 # Synced to Wine-1.7.17
|
||||
reactos/dll/directx/wine/d3dxof # Synced to Wine-1.7.1
|
||||
reactos/dll/directx/wine/ddraw # Synced to Wine-1.7.17
|
||||
reactos/dll/directx/wine/devenum # Synced to Wine-1.7.1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue