2003-07-01 03:09:17 +02:00
|
|
|
/*
|
2004-10-14 02:32:04 +02:00
|
|
|
* IDirect3DVertexBuffer9 implementation
|
2003-07-01 03:09:17 +02:00
|
|
|
*
|
2004-10-14 02:32:04 +02:00
|
|
|
* Copyright 2002-2004 Jason Edmeades
|
2003-07-01 03:09:17 +02:00
|
|
|
* Raphael Junqueira
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "d3d9_private.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
|
|
|
|
|
|
|
|
/* IDirect3DVertexBuffer9 IUnknown parts follow: */
|
|
|
|
HRESULT WINAPI IDirect3DVertexBuffer9Impl_QueryInterface(LPDIRECT3DVERTEXBUFFER9 iface, REFIID riid, LPVOID* ppobj) {
|
2004-09-08 03:50:37 +02:00
|
|
|
IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
|
2003-07-01 03:09:17 +02:00
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown)
|
|
|
|
|| IsEqualGUID(riid, &IID_IDirect3DResource9)
|
|
|
|
|| IsEqualGUID(riid, &IID_IDirect3DVertexBuffer9)) {
|
|
|
|
IDirect3DVertexBuffer9Impl_AddRef(iface);
|
|
|
|
*ppobj = This;
|
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
ULONG WINAPI IDirect3DVertexBuffer9Impl_AddRef(LPDIRECT3DVERTEXBUFFER9 iface) {
|
2004-09-08 03:50:37 +02:00
|
|
|
IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
|
2005-01-24 12:31:45 +01:00
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) : AddRef from %ld\n", This, ref - 1);
|
|
|
|
|
|
|
|
return ref;
|
2003-07-01 03:09:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ULONG WINAPI IDirect3DVertexBuffer9Impl_Release(LPDIRECT3DVERTEXBUFFER9 iface) {
|
2004-09-08 03:50:37 +02:00
|
|
|
IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
|
2004-10-14 02:32:04 +02:00
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
2005-01-24 12:31:45 +01:00
|
|
|
|
|
|
|
TRACE("(%p) : ReleaseRef to %ld\n", This, ref);
|
|
|
|
|
2003-07-01 03:09:17 +02:00
|
|
|
if (ref == 0) {
|
2004-10-14 02:32:04 +02:00
|
|
|
IWineD3DVertexBuffer_Release(This->wineD3DVertexBuffer);
|
2003-07-01 03:09:17 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
}
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* IDirect3DVertexBuffer9 IDirect3DResource9 Interface follow: */
|
|
|
|
HRESULT WINAPI IDirect3DVertexBuffer9Impl_GetDevice(LPDIRECT3DVERTEXBUFFER9 iface, IDirect3DDevice9** ppDevice) {
|
2004-09-08 03:50:37 +02:00
|
|
|
IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
|
2003-07-01 03:09:17 +02:00
|
|
|
return IDirect3DResource9Impl_GetDevice((LPDIRECT3DRESOURCE9) This, ppDevice);
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI IDirect3DVertexBuffer9Impl_SetPrivateData(LPDIRECT3DVERTEXBUFFER9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
|
2004-09-08 03:50:37 +02:00
|
|
|
IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
|
2004-10-14 02:32:04 +02:00
|
|
|
return IWineD3DVertexBuffer_SetPrivateData(This->wineD3DVertexBuffer, refguid, pData, SizeOfData, Flags);
|
2003-07-01 03:09:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI IDirect3DVertexBuffer9Impl_GetPrivateData(LPDIRECT3DVERTEXBUFFER9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
|
2004-09-08 03:50:37 +02:00
|
|
|
IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
|
2004-10-14 02:32:04 +02:00
|
|
|
return IWineD3DVertexBuffer_GetPrivateData(This->wineD3DVertexBuffer, refguid, pData, pSizeOfData);
|
2003-07-01 03:09:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI IDirect3DVertexBuffer9Impl_FreePrivateData(LPDIRECT3DVERTEXBUFFER9 iface, REFGUID refguid) {
|
2004-09-08 03:50:37 +02:00
|
|
|
IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
|
2004-10-14 02:32:04 +02:00
|
|
|
return IWineD3DVertexBuffer_FreePrivateData(This->wineD3DVertexBuffer, refguid);
|
2003-07-01 03:09:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DWORD WINAPI IDirect3DVertexBuffer9Impl_SetPriority(LPDIRECT3DVERTEXBUFFER9 iface, DWORD PriorityNew) {
|
2004-09-08 03:50:37 +02:00
|
|
|
IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
|
2004-10-14 02:32:04 +02:00
|
|
|
return IWineD3DVertexBuffer_SetPriority(This->wineD3DVertexBuffer, PriorityNew);
|
2003-07-01 03:09:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DWORD WINAPI IDirect3DVertexBuffer9Impl_GetPriority(LPDIRECT3DVERTEXBUFFER9 iface) {
|
2004-09-08 03:50:37 +02:00
|
|
|
IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
|
2004-10-14 02:32:04 +02:00
|
|
|
return IWineD3DVertexBuffer_GetPriority(This->wineD3DVertexBuffer);
|
2003-07-01 03:09:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void WINAPI IDirect3DVertexBuffer9Impl_PreLoad(LPDIRECT3DVERTEXBUFFER9 iface) {
|
2004-09-08 03:50:37 +02:00
|
|
|
IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
|
2004-10-14 02:32:04 +02:00
|
|
|
IWineD3DVertexBuffer_PreLoad(This->wineD3DVertexBuffer);
|
2003-07-01 03:09:17 +02:00
|
|
|
return ;
|
|
|
|
}
|
|
|
|
|
|
|
|
D3DRESOURCETYPE WINAPI IDirect3DVertexBuffer9Impl_GetType(LPDIRECT3DVERTEXBUFFER9 iface) {
|
2004-09-08 03:50:37 +02:00
|
|
|
IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
|
2004-10-14 02:32:04 +02:00
|
|
|
return IWineD3DVertexBuffer_GetType(This->wineD3DVertexBuffer);
|
2003-07-01 03:09:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* IDirect3DVertexBuffer9 Interface follow: */
|
|
|
|
HRESULT WINAPI IDirect3DVertexBuffer9Impl_Lock(LPDIRECT3DVERTEXBUFFER9 iface, UINT OffsetToLock, UINT SizeToLock, void** ppbData, DWORD Flags) {
|
2004-09-08 03:50:37 +02:00
|
|
|
IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
|
2004-10-14 02:32:04 +02:00
|
|
|
return IWineD3DVertexBuffer_Lock(This->wineD3DVertexBuffer, OffsetToLock, SizeToLock, (BYTE **)ppbData, Flags);
|
2003-07-01 03:09:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI IDirect3DVertexBuffer9Impl_Unlock(LPDIRECT3DVERTEXBUFFER9 iface) {
|
2004-09-08 03:50:37 +02:00
|
|
|
IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
|
2004-10-14 02:32:04 +02:00
|
|
|
return IWineD3DVertexBuffer_Unlock(This->wineD3DVertexBuffer);
|
2003-07-01 03:09:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI IDirect3DVertexBuffer9Impl_GetDesc(LPDIRECT3DVERTEXBUFFER9 iface, D3DVERTEXBUFFER_DESC* pDesc) {
|
2004-09-08 03:50:37 +02:00
|
|
|
IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
|
2004-10-14 02:32:04 +02:00
|
|
|
return IWineD3DVertexBuffer_GetDesc(This->wineD3DVertexBuffer, pDesc);
|
2003-07-01 03:09:17 +02:00
|
|
|
}
|
|
|
|
|
2004-08-13 01:00:51 +02:00
|
|
|
IDirect3DVertexBuffer9Vtbl Direct3DVertexBuffer9_Vtbl =
|
2003-07-01 03:09:17 +02:00
|
|
|
{
|
|
|
|
IDirect3DVertexBuffer9Impl_QueryInterface,
|
|
|
|
IDirect3DVertexBuffer9Impl_AddRef,
|
|
|
|
IDirect3DVertexBuffer9Impl_Release,
|
|
|
|
IDirect3DVertexBuffer9Impl_GetDevice,
|
|
|
|
IDirect3DVertexBuffer9Impl_SetPrivateData,
|
|
|
|
IDirect3DVertexBuffer9Impl_GetPrivateData,
|
|
|
|
IDirect3DVertexBuffer9Impl_FreePrivateData,
|
|
|
|
IDirect3DVertexBuffer9Impl_SetPriority,
|
|
|
|
IDirect3DVertexBuffer9Impl_GetPriority,
|
|
|
|
IDirect3DVertexBuffer9Impl_PreLoad,
|
|
|
|
IDirect3DVertexBuffer9Impl_GetType,
|
|
|
|
IDirect3DVertexBuffer9Impl_Lock,
|
|
|
|
IDirect3DVertexBuffer9Impl_Unlock,
|
|
|
|
IDirect3DVertexBuffer9Impl_GetDesc
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* IDirect3DDevice9 IDirect3DVertexBuffer9 Methods follow: */
|
|
|
|
HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexBuffer(LPDIRECT3DDEVICE9 iface,
|
|
|
|
UINT Size, DWORD Usage, DWORD FVF, D3DPOOL Pool,
|
|
|
|
IDirect3DVertexBuffer9** ppVertexBuffer, HANDLE* pSharedHandle) {
|
2004-10-14 02:32:04 +02:00
|
|
|
|
2003-07-01 03:09:17 +02:00
|
|
|
IDirect3DVertexBuffer9Impl *object;
|
2004-09-08 03:50:37 +02:00
|
|
|
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
2005-01-18 12:42:29 +01:00
|
|
|
HRESULT hrc = D3D_OK;
|
2003-07-01 03:09:17 +02:00
|
|
|
|
|
|
|
/* Allocate the storage for the device */
|
|
|
|
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DVertexBuffer9Impl));
|
2005-01-18 12:42:29 +01:00
|
|
|
if (NULL == object) {
|
|
|
|
FIXME("Allocation of memory failed\n");
|
|
|
|
*ppVertexBuffer = NULL;
|
|
|
|
return D3DERR_OUTOFVIDEOMEMORY;
|
|
|
|
}
|
|
|
|
|
2003-07-01 03:09:17 +02:00
|
|
|
object->lpVtbl = &Direct3DVertexBuffer9_Vtbl;
|
|
|
|
object->ref = 1;
|
2005-01-18 12:42:29 +01:00
|
|
|
hrc = IWineD3DDevice_CreateVertexBuffer(This->WineD3DDevice, Size, Usage, FVF, Pool, &(object->wineD3DVertexBuffer), pSharedHandle, (IUnknown *)object);
|
|
|
|
|
|
|
|
if (hrc != D3D_OK) {
|
|
|
|
/* free up object */
|
|
|
|
FIXME("(%p) call to IWineD3DDevice_CreateVertexBuffer failed\n", This);
|
|
|
|
HeapFree(GetProcessHeap(), 0, object);
|
|
|
|
*ppVertexBuffer = NULL;
|
|
|
|
} else {
|
|
|
|
*ppVertexBuffer = (LPDIRECT3DVERTEXBUFFER9) object;
|
|
|
|
}
|
|
|
|
return hrc;
|
2003-07-01 03:09:17 +02:00
|
|
|
}
|