d3drm: Handle texture load proc when loading mesh data.

This commit is contained in:
Christian Costa 2012-12-14 08:37:38 +01:00 committed by Alexandre Julliard
parent 0f0f76ce6b
commit 53e37121a4
3 changed files with 32 additions and 16 deletions

View File

@ -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 */

View File

@ -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;

View File

@ -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,19 +1372,33 @@ HRESULT load_mesh_data(IDirect3DRMMeshBuilder3* iface, LPDIRECTXFILEDATA pData)
hr = IDirectXFileData_GetData(data, NULL, &size, (void**)&filename);
if (SUCCEEDED(hr))
{
HANDLE file;
/* If the texture file is not found, no texture is associated with the material */
file = CreateFileA(*filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
if (file != INVALID_HANDLE_VALUE)
if (load_texture_proc)
{
CloseHandle(file);
IDirect3DRMTexture *texture;
hr = Direct3DRMTexture_create(&IID_IDirect3DRMTexture3, (LPUNKNOWN*)&This->materials[i].texture);
if (FAILED(hr))
hr = load_texture_proc(*filename, arg, &texture);
if (SUCCEEDED(hr))
{
IDirectXFileData_Release(data);
goto end;
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 */
file = CreateFileA(*filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
if (file != INVALID_HANDLE_VALUE)
{
CloseHandle(file);
hr = Direct3DRMTexture_create(&IID_IDirect3DRMTexture3, (IUnknown**)&This->materials[i].texture);
if (FAILED(hr))
{
IDirectXFileData_Release(data);
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;