d3d8: Add a separate function for cube texture initialization.

This commit is contained in:
Henri Verbeet 2009-09-17 12:35:24 +02:00 committed by Alexandre Julliard
parent c51fbe9293
commit b5b58e423d
3 changed files with 45 additions and 35 deletions

View File

@ -286,8 +286,7 @@ static HRESULT WINAPI IDirect3DCubeTexture8Impl_AddDirtyRect(LPDIRECT3DCUBETEXTU
return hr; return hr;
} }
static const IDirect3DCubeTexture8Vtbl Direct3DCubeTexture8_Vtbl =
const IDirect3DCubeTexture8Vtbl Direct3DCubeTexture8_Vtbl =
{ {
/* IUnknown */ /* IUnknown */
IDirect3DCubeTexture8Impl_QueryInterface, IDirect3DCubeTexture8Impl_QueryInterface,
@ -313,3 +312,27 @@ const IDirect3DCubeTexture8Vtbl Direct3DCubeTexture8_Vtbl =
IDirect3DCubeTexture8Impl_UnlockRect, IDirect3DCubeTexture8Impl_UnlockRect,
IDirect3DCubeTexture8Impl_AddDirtyRect 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;
}

View File

@ -389,11 +389,6 @@ struct IDirect3DBaseTexture8Impl
/* IDirect3DCubeTexture8 */ /* IDirect3DCubeTexture8 */
/* --------------------- */ /* --------------------- */
/*****************************************************************************
* Predeclare the interface implementation structures
*/
extern const IDirect3DCubeTexture8Vtbl Direct3DCubeTexture8_Vtbl DECLSPEC_HIDDEN;
/***************************************************************************** /*****************************************************************************
* IDirect3DCubeTexture8 implementation structure * IDirect3DCubeTexture8 implementation structure
*/ */
@ -410,6 +405,9 @@ struct IDirect3DCubeTexture8Impl
LPDIRECT3DDEVICE8 parentDevice; LPDIRECT3DDEVICE8 parentDevice;
}; };
HRESULT cubetexture_init(IDirect3DCubeTexture8Impl *texture, IDirect3DDevice8Impl *device,
UINT edge_length, UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool) DECLSPEC_HIDDEN;
/* ----------------- */ /* ----------------- */
/* IDirect3DTexture8 */ /* IDirect3DTexture8 */
/* ----------------- */ /* ----------------- */

View File

@ -726,45 +726,34 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreateVolumeTexture(IDirect3DDevice8
return D3D_OK; return D3D_OK;
} }
static HRESULT WINAPI IDirect3DDevice8Impl_CreateCubeTexture(IDirect3DDevice8 *iface, UINT EdgeLength, static HRESULT WINAPI IDirect3DDevice8Impl_CreateCubeTexture(IDirect3DDevice8 *iface, UINT edge_length,
UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DCubeTexture8 **ppCubeTexture) UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool, IDirect3DCubeTexture8 **texture)
{ {
IDirect3DCubeTexture8Impl *object;
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface; 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)); object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object)
if (NULL == object) { {
FIXME("(%p) allocation of CubeTexture failed\n", This); ERR("Failed to allocate cube texture memory.\n");
*ppCubeTexture = NULL;
return D3DERR_OUTOFVIDEOMEMORY; return D3DERR_OUTOFVIDEOMEMORY;
} }
object->lpVtbl = &Direct3DCubeTexture8_Vtbl; hr = cubetexture_init(object, This, edge_length, levels, usage, format, pool);
object->ref = 1; if (FAILED(hr))
{
wined3d_mutex_lock(); WARN("Failed to initialize cube texture, hr %#x.\n", hr);
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);
HeapFree(GetProcessHeap(), 0, object); HeapFree(GetProcessHeap(), 0, object);
*ppCubeTexture = NULL; return hr;
} else {
IUnknown_AddRef(iface);
object->parentDevice = iface;
*ppCubeTexture = (LPDIRECT3DCUBETEXTURE8) object;
} }
TRACE("(%p) returning %p\n",This, *ppCubeTexture); TRACE("Created cube texture %p.\n", object);
*texture = (IDirect3DCubeTexture8 *)object;
return hr; return hr;
} }