Commit 53e37121 authored by Christian Costa's avatar Christian Costa Committed by Alexandre Julliard

d3drm: Handle texture load proc when loading mesh data.

parent 0f0f76ce
......@@ -1257,8 +1257,8 @@ static HRESULT WINAPI IDirect3DRM3Impl_EnumerateObjects(IDirect3DRM3* iface, D3D
return E_NOTIMPL;
}
static HRESULT load_data(IDirect3DRM3* iface, LPDIRECTXFILEDATA data_object, LPIID* GUIDs, DWORD nb_GUIDs, D3DRMLOADCALLBACK LoadProc,
LPVOID ArgLP, D3DRMLOADTEXTURECALLBACK LoadTextureProc, LPVOID ArgLTP, LPDIRECT3DRMFRAME3 parent_frame)
static HRESULT load_data(IDirect3DRM3 *iface, IDirectXFileData *data_object, IID **GUIDs, DWORD nb_GUIDs, D3DRMLOADCALLBACK LoadProc,
void *ArgLP, D3DRMLOADTEXTURECALLBACK LoadTextureProc, void *ArgLTP, IDirect3DRMFrame3 *parent_frame)
{
HRESULT ret = D3DRMERR_BADOBJECT;
HRESULT hr;
......@@ -1296,7 +1296,7 @@ static HRESULT load_data(IDirect3DRM3* iface, LPDIRECTXFILEDATA data_object, LPI
hr = IDirect3DRM3_CreateMeshBuilder(iface, &meshbuilder);
if (SUCCEEDED(hr))
{
hr = load_mesh_data(meshbuilder, data_object);
hr = load_mesh_data(meshbuilder, data_object, LoadTextureProc, ArgLTP);
if (SUCCEEDED(hr))
{
/* Only top level objects are notified */
......
......@@ -36,7 +36,8 @@ HRESULT Direct3DRMViewport_create(REFIID riid, IUnknown** ppObj) DECLSPEC_HIDDEN
HRESULT Direct3DRMMaterial_create(IDirect3DRMMaterial2** ret_iface) DECLSPEC_HIDDEN;
HRESULT Direct3DRMTexture_create(REFIID riid, IUnknown** ret_iface) DECLSPEC_HIDDEN;
HRESULT load_mesh_data(IDirect3DRMMeshBuilder3* iface, LPDIRECTXFILEDATA pData) DECLSPEC_HIDDEN;
HRESULT load_mesh_data(IDirect3DRMMeshBuilder3 *iface, IDirectXFileData *data,
D3DRMLOADTEXTURECALLBACK load_texture_proc, void *arg) DECLSPEC_HIDDEN;
typedef struct {
WORD major;
......
......@@ -1129,7 +1129,7 @@ static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetClassName(IDirect3DRMMeshBu
return D3DRM_OK;
}
HRESULT load_mesh_data(IDirect3DRMMeshBuilder3* iface, LPDIRECTXFILEDATA pData)
HRESULT load_mesh_data(IDirect3DRMMeshBuilder3* iface, IDirectXFileData *pData, D3DRMLOADTEXTURECALLBACK load_texture_proc, void *arg)
{
IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
LPDIRECTXFILEOBJECT pObject = NULL;
......@@ -1372,6 +1372,19 @@ HRESULT load_mesh_data(IDirect3DRMMeshBuilder3* iface, LPDIRECTXFILEDATA pData)
hr = IDirectXFileData_GetData(data, NULL, &size, (void**)&filename);
if (SUCCEEDED(hr))
{
if (load_texture_proc)
{
IDirect3DRMTexture *texture;
hr = load_texture_proc(*filename, arg, &texture);
if (SUCCEEDED(hr))
{
hr = IDirect3DTexture_QueryInterface(texture, &IID_IDirect3DRMTexture3, (void**)&This->materials[i].texture);
IDirect3DTexture_Release(texture);
}
}
else
{
HANDLE file;
/* If the texture file is not found, no texture is associated with the material */
......@@ -1380,7 +1393,7 @@ HRESULT load_mesh_data(IDirect3DRMMeshBuilder3* iface, LPDIRECTXFILEDATA pData)
{
CloseHandle(file);
hr = Direct3DRMTexture_create(&IID_IDirect3DRMTexture3, (LPUNKNOWN*)&This->materials[i].texture);
hr = Direct3DRMTexture_create(&IID_IDirect3DRMTexture3, (IUnknown**)&This->materials[i].texture);
if (FAILED(hr))
{
IDirectXFileData_Release(data);
......@@ -1389,6 +1402,7 @@ HRESULT load_mesh_data(IDirect3DRMMeshBuilder3* iface, LPDIRECTXFILEDATA pData)
}
}
}
}
else if (hr != DXFILEERR_NOMOREOBJECTS)
{
goto end;
......@@ -1630,7 +1644,8 @@ static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Load(IDirect3DRMMeshBuilder3*
goto end;
}
hr = load_mesh_data(iface, pData);
/* We don't care about the texture interface version since we rely on QueryInterface */
hr = load_mesh_data(iface, pData, (D3DRMLOADTEXTURECALLBACK)cb, arg);
if (hr == S_OK)
ret = D3DRM_OK;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment