mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-18 11:58:14 +00:00
d3d8: Add a separate function for cube texture initialization.
This commit is contained in:
parent
c51fbe9293
commit
b5b58e423d
|
@ -286,8 +286,7 @@ static HRESULT WINAPI IDirect3DCubeTexture8Impl_AddDirtyRect(LPDIRECT3DCUBETEXTU
|
|||
return hr;
|
||||
}
|
||||
|
||||
|
||||
const IDirect3DCubeTexture8Vtbl Direct3DCubeTexture8_Vtbl =
|
||||
static const IDirect3DCubeTexture8Vtbl Direct3DCubeTexture8_Vtbl =
|
||||
{
|
||||
/* IUnknown */
|
||||
IDirect3DCubeTexture8Impl_QueryInterface,
|
||||
|
@ -313,3 +312,27 @@ const IDirect3DCubeTexture8Vtbl Direct3DCubeTexture8_Vtbl =
|
|||
IDirect3DCubeTexture8Impl_UnlockRect,
|
||||
IDirect3DCubeTexture8Impl_AddDirtyRect
|
||||
};
|
||||
|
||||
HRESULT cubetexture_init(IDirect3DCubeTexture8Impl *texture, IDirect3DDevice8Impl *device,
|
||||
UINT edge_length, UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
texture->lpVtbl = &Direct3DCubeTexture8_Vtbl;
|
||||
texture->ref = 1;
|
||||
|
||||
wined3d_mutex_lock();
|
||||
hr = IWineD3DDevice_CreateCubeTexture(device->WineD3DDevice, edge_length, levels, usage & WINED3DUSAGE_MASK,
|
||||
wined3dformat_from_d3dformat(format), pool, &texture->wineD3DCubeTexture, (IUnknown *)texture);
|
||||
wined3d_mutex_unlock();
|
||||
if (FAILED(hr))
|
||||
{
|
||||
WARN("Failed to create wined3d cube texture, hr %#x.\n", hr);
|
||||
return hr;
|
||||
}
|
||||
|
||||
texture->parentDevice = (IDirect3DDevice8 *)device;
|
||||
IDirect3DDevice8_AddRef(texture->parentDevice);
|
||||
|
||||
return D3D_OK;
|
||||
}
|
||||
|
|
|
@ -389,11 +389,6 @@ struct IDirect3DBaseTexture8Impl
|
|||
/* IDirect3DCubeTexture8 */
|
||||
/* --------------------- */
|
||||
|
||||
/*****************************************************************************
|
||||
* Predeclare the interface implementation structures
|
||||
*/
|
||||
extern const IDirect3DCubeTexture8Vtbl Direct3DCubeTexture8_Vtbl DECLSPEC_HIDDEN;
|
||||
|
||||
/*****************************************************************************
|
||||
* IDirect3DCubeTexture8 implementation structure
|
||||
*/
|
||||
|
@ -410,6 +405,9 @@ struct IDirect3DCubeTexture8Impl
|
|||
LPDIRECT3DDEVICE8 parentDevice;
|
||||
};
|
||||
|
||||
HRESULT cubetexture_init(IDirect3DCubeTexture8Impl *texture, IDirect3DDevice8Impl *device,
|
||||
UINT edge_length, UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool) DECLSPEC_HIDDEN;
|
||||
|
||||
/* ----------------- */
|
||||
/* IDirect3DTexture8 */
|
||||
/* ----------------- */
|
||||
|
|
|
@ -726,45 +726,34 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreateVolumeTexture(IDirect3DDevice8
|
|||
return D3D_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI IDirect3DDevice8Impl_CreateCubeTexture(IDirect3DDevice8 *iface, UINT EdgeLength,
|
||||
UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DCubeTexture8 **ppCubeTexture)
|
||||
static HRESULT WINAPI IDirect3DDevice8Impl_CreateCubeTexture(IDirect3DDevice8 *iface, UINT edge_length,
|
||||
UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool, IDirect3DCubeTexture8 **texture)
|
||||
{
|
||||
IDirect3DCubeTexture8Impl *object;
|
||||
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
|
||||
HRESULT hr = D3D_OK;
|
||||
IDirect3DCubeTexture8Impl *object;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("(%p) : ELen(%d) Lvl(%d) Usage(%d) fmt(%u), Pool(%d)\n" , This, EdgeLength, Levels, Usage, Format, Pool);
|
||||
TRACE("iface %p, edge_length %u, levels %u, usage %#x, format %#x, pool %#x, texture %p.\n",
|
||||
iface, edge_length, levels, usage, format, pool, texture);
|
||||
|
||||
/* Allocate the storage for the device */
|
||||
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
|
||||
|
||||
if (NULL == object) {
|
||||
FIXME("(%p) allocation of CubeTexture failed\n", This);
|
||||
*ppCubeTexture = NULL;
|
||||
if (!object)
|
||||
{
|
||||
ERR("Failed to allocate cube texture memory.\n");
|
||||
return D3DERR_OUTOFVIDEOMEMORY;
|
||||
}
|
||||
|
||||
object->lpVtbl = &Direct3DCubeTexture8_Vtbl;
|
||||
object->ref = 1;
|
||||
|
||||
wined3d_mutex_lock();
|
||||
hr = IWineD3DDevice_CreateCubeTexture(This->WineD3DDevice, EdgeLength, Levels, Usage & WINED3DUSAGE_MASK,
|
||||
wined3dformat_from_d3dformat(Format), Pool, &object->wineD3DCubeTexture, (IUnknown *)object);
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
if (hr != D3D_OK){
|
||||
|
||||
/* free up object */
|
||||
FIXME("(%p) call to IWineD3DDevice_CreateCubeTexture failed\n", This);
|
||||
hr = cubetexture_init(object, This, edge_length, levels, usage, format, pool);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
WARN("Failed to initialize cube texture, hr %#x.\n", hr);
|
||||
HeapFree(GetProcessHeap(), 0, object);
|
||||
*ppCubeTexture = NULL;
|
||||
} else {
|
||||
IUnknown_AddRef(iface);
|
||||
object->parentDevice = iface;
|
||||
*ppCubeTexture = (LPDIRECT3DCUBETEXTURE8) object;
|
||||
return hr;
|
||||
}
|
||||
|
||||
TRACE("(%p) returning %p\n",This, *ppCubeTexture);
|
||||
TRACE("Created cube texture %p.\n", object);
|
||||
*texture = (IDirect3DCubeTexture8 *)object;
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue