d3d9: Add a separate function for cube texture initialization.
This commit is contained in:
parent
d84e2fa747
commit
c51fbe9293
|
@ -352,48 +352,26 @@ static const IDirect3DCubeTexture9Vtbl Direct3DCubeTexture9_Vtbl =
|
|||
IDirect3DCubeTexture9Impl_AddDirtyRect
|
||||
};
|
||||
|
||||
HRESULT cubetexture_init(IDirect3DCubeTexture9Impl *texture, IDirect3DDevice9Impl *device,
|
||||
UINT edge_length, UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
|
||||
|
||||
/* IDirect3DDevice9 IDirect3DCubeTexture9 Methods follow: */
|
||||
HRESULT WINAPI IDirect3DDevice9Impl_CreateCubeTexture(LPDIRECT3DDEVICE9EX iface,
|
||||
UINT EdgeLength, UINT Levels, DWORD Usage,
|
||||
D3DFORMAT Format, D3DPOOL Pool,
|
||||
IDirect3DCubeTexture9** ppCubeTexture, HANDLE* pSharedHandle) {
|
||||
|
||||
IDirect3DCubeTexture9Impl *object;
|
||||
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
||||
HRESULT hr = D3D_OK;
|
||||
|
||||
TRACE("(%p) : ELen(%d) Lvl(%d) Usage(%d) fmt(%u), Pool(%d) Shared(%p)\n", This, EdgeLength, Levels, Usage, Format, Pool, pSharedHandle);
|
||||
|
||||
/* Allocate the storage for the device */
|
||||
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
|
||||
|
||||
if (NULL == object) {
|
||||
ERR("(%p) allocation of CubeTexture failed\n", This);
|
||||
return D3DERR_OUTOFVIDEOMEMORY;
|
||||
}
|
||||
object->lpVtbl = &Direct3DCubeTexture9_Vtbl;
|
||||
object->ref = 1;
|
||||
texture->lpVtbl = &Direct3DCubeTexture9_Vtbl;
|
||||
texture->ref = 1;
|
||||
|
||||
wined3d_mutex_lock();
|
||||
hr = IWineD3DDevice_CreateCubeTexture(This->WineD3DDevice, EdgeLength, Levels, Usage,
|
||||
wined3dformat_from_d3dformat(Format), Pool, &object->wineD3DCubeTexture, (IUnknown *)object);
|
||||
hr = IWineD3DDevice_CreateCubeTexture(device->WineD3DDevice, edge_length, levels, usage,
|
||||
wined3dformat_from_d3dformat(format), pool, &texture->wineD3DCubeTexture, (IUnknown *)texture);
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
if (hr != D3D_OK){
|
||||
|
||||
/* free up object */
|
||||
WARN("(%p) call to IWineD3DDevice_CreateCubeTexture failed\n", This);
|
||||
HeapFree(GetProcessHeap(), 0, object);
|
||||
} else {
|
||||
IDirect3DDevice9Ex_AddRef(iface);
|
||||
object->parentDevice = iface;
|
||||
*ppCubeTexture = (LPDIRECT3DCUBETEXTURE9) object;
|
||||
TRACE("(%p) : Created cube texture %p\n", This, object);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
WARN("Failed to create wined3d cube texture, hr %#x.\n", hr);
|
||||
return hr;
|
||||
}
|
||||
|
||||
TRACE("(%p) returning %p\n",This, *ppCubeTexture);
|
||||
return hr;
|
||||
texture->parentDevice = (IDirect3DDevice9Ex *)device;
|
||||
IDirect3DDevice9Ex_AddRef(texture->parentDevice);
|
||||
|
||||
return D3D_OK;
|
||||
}
|
||||
|
|
|
@ -200,9 +200,6 @@ extern UINT WINAPI IDirect3DDevice9Impl_GetNumberOfSwapChains(IDirect3DDevice9Ex
|
|||
extern HRESULT WINAPI IDirect3DDevice9Impl_CreateTexture(IDirect3DDevice9Ex *iface,
|
||||
UINT Width, UINT Height, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool,
|
||||
IDirect3DTexture9 **ppTexture, HANDLE *pSharedHandle) DECLSPEC_HIDDEN;
|
||||
extern HRESULT WINAPI IDirect3DDevice9Impl_CreateCubeTexture(IDirect3DDevice9Ex *iface,
|
||||
UINT EdgeLength, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool,
|
||||
IDirect3DCubeTexture9 **ppCubeTexture, HANDLE *pSharedHandle) DECLSPEC_HIDDEN;
|
||||
extern HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexBuffer(IDirect3DDevice9Ex *iface,
|
||||
UINT Length, DWORD Usage, DWORD FVF, D3DPOOL Pool,
|
||||
IDirect3DVertexBuffer9 **ppVertexBuffer, HANDLE *pSharedHandle) DECLSPEC_HIDDEN;
|
||||
|
@ -421,6 +418,8 @@ typedef struct IDirect3DCubeTexture9Impl
|
|||
LPDIRECT3DDEVICE9EX parentDevice;
|
||||
} IDirect3DCubeTexture9Impl;
|
||||
|
||||
HRESULT cubetexture_init(IDirect3DCubeTexture9Impl *texture, IDirect3DDevice9Impl *device,
|
||||
UINT edge_length, UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool) DECLSPEC_HIDDEN;
|
||||
|
||||
/* ----------------- */
|
||||
/* IDirect3DTexture9 */
|
||||
|
|
|
@ -678,6 +678,38 @@ static HRESULT WINAPI IDirect3DDevice9Impl_CreateVolumeTexture(IDirect3DDevice9E
|
|||
return D3D_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI IDirect3DDevice9Impl_CreateCubeTexture(IDirect3DDevice9Ex *iface,
|
||||
UINT edge_length, UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool,
|
||||
IDirect3DCubeTexture9 **texture, HANDLE *shared_handle)
|
||||
{
|
||||
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
||||
IDirect3DCubeTexture9Impl *object;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("iface %p, edge_length %u, levels %u, usage %#x, format %#x, pool %#x, texture %p, shared_handle %p.\n",
|
||||
iface, edge_length, levels, usage, format, pool, texture, shared_handle);
|
||||
|
||||
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
|
||||
if (!object)
|
||||
{
|
||||
ERR("Failed to allocate cube texture memory.\n");
|
||||
return D3DERR_OUTOFVIDEOMEMORY;
|
||||
}
|
||||
|
||||
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);
|
||||
return hr;
|
||||
}
|
||||
|
||||
TRACE("Created cube texture %p.\n", object);
|
||||
*texture = (IDirect3DCubeTexture9 *)object;
|
||||
|
||||
return D3D_OK;
|
||||
}
|
||||
|
||||
static HRESULT IDirect3DDevice9Impl_CreateSurface(LPDIRECT3DDEVICE9EX iface, UINT Width, UINT Height,
|
||||
D3DFORMAT Format, BOOL Lockable, BOOL Discard, UINT Level, IDirect3DSurface9 **ppSurface,
|
||||
UINT Usage, D3DPOOL Pool, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality)
|
||||
|
|
Loading…
Reference in New Issue