2004-10-14 02:32:04 +02:00
|
|
|
/*
|
|
|
|
* IWineD3DVertexBuffer Implementation
|
|
|
|
*
|
2005-07-24 19:11:33 +02:00
|
|
|
* Copyright 2002-2005 Jason Edmeades
|
|
|
|
* Raphael Junqueira
|
2004-10-14 02:32:04 +02:00
|
|
|
* Copyright 2004 Christian Costa
|
|
|
|
*
|
|
|
|
* 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 "wined3d_private.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
|
2004-11-28 16:04:41 +01:00
|
|
|
#define GLINFO_LOCATION ((IWineD3DImpl *)(((IWineD3DDeviceImpl *)This->resource.wineD3DDevice)->wineD3D))->gl_info
|
2004-10-14 02:32:04 +02:00
|
|
|
|
|
|
|
/* *******************************************
|
|
|
|
IWineD3DVertexBuffer IUnknown parts follow
|
|
|
|
******************************************* */
|
|
|
|
HRESULT WINAPI IWineD3DVertexBufferImpl_QueryInterface(IWineD3DVertexBuffer *iface, REFIID riid, LPVOID *ppobj)
|
|
|
|
{
|
|
|
|
IWineD3DVertexBufferImpl *This = (IWineD3DVertexBufferImpl *)iface;
|
2005-03-02 14:44:58 +01:00
|
|
|
TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppobj);
|
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown)
|
2006-02-06 11:32:41 +01:00
|
|
|
|| IsEqualGUID(riid, &IID_IWineD3DBase)
|
2005-03-02 14:44:58 +01:00
|
|
|
|| IsEqualGUID(riid, &IID_IWineD3DResource)
|
|
|
|
|| IsEqualGUID(riid, &IID_IWineD3DVertexBuffer)){
|
|
|
|
IUnknown_AddRef(iface);
|
|
|
|
*ppobj = This;
|
|
|
|
return D3D_OK;
|
|
|
|
}
|
2004-10-14 02:32:04 +02:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
ULONG WINAPI IWineD3DVertexBufferImpl_AddRef(IWineD3DVertexBuffer *iface) {
|
|
|
|
IWineD3DVertexBufferImpl *This = (IWineD3DVertexBufferImpl *)iface;
|
2005-01-19 17:59:01 +01:00
|
|
|
ULONG ref = InterlockedIncrement(&This->resource.ref);
|
|
|
|
TRACE("(%p) : AddRef increasing from %ld\n", This, ref - 1);
|
|
|
|
return ref;
|
2004-10-14 02:32:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ULONG WINAPI IWineD3DVertexBufferImpl_Release(IWineD3DVertexBuffer *iface) {
|
|
|
|
IWineD3DVertexBufferImpl *This = (IWineD3DVertexBufferImpl *)iface;
|
2005-01-19 17:59:01 +01:00
|
|
|
ULONG ref = InterlockedDecrement(&This->resource.ref);
|
|
|
|
TRACE("(%p) : Releasing from %ld\n", This, ref + 1);
|
2004-10-14 02:32:04 +02:00
|
|
|
if (ref == 0) {
|
2005-03-29 21:01:00 +02:00
|
|
|
IWineD3DResourceImpl_CleanUp((IWineD3DResource *)iface);
|
2004-10-14 02:32:04 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
}
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ****************************************************
|
|
|
|
IWineD3DVertexBuffer IWineD3DResource parts follow
|
|
|
|
**************************************************** */
|
|
|
|
HRESULT WINAPI IWineD3DVertexBufferImpl_GetDevice(IWineD3DVertexBuffer *iface, IWineD3DDevice** ppDevice) {
|
2005-01-17 14:44:57 +01:00
|
|
|
return IWineD3DResourceImpl_GetDevice((IWineD3DResource *)iface, ppDevice);
|
2004-10-14 02:32:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI IWineD3DVertexBufferImpl_SetPrivateData(IWineD3DVertexBuffer *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
|
2005-01-17 14:44:57 +01:00
|
|
|
return IWineD3DResourceImpl_SetPrivateData((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
|
2004-10-14 02:32:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI IWineD3DVertexBufferImpl_GetPrivateData(IWineD3DVertexBuffer *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
|
2005-01-17 14:44:57 +01:00
|
|
|
return IWineD3DResourceImpl_GetPrivateData((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
|
2004-10-14 02:32:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI IWineD3DVertexBufferImpl_FreePrivateData(IWineD3DVertexBuffer *iface, REFGUID refguid) {
|
2005-01-17 14:44:57 +01:00
|
|
|
return IWineD3DResourceImpl_FreePrivateData((IWineD3DResource *)iface, refguid);
|
2004-10-14 02:32:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DWORD WINAPI IWineD3DVertexBufferImpl_SetPriority(IWineD3DVertexBuffer *iface, DWORD PriorityNew) {
|
2005-01-17 14:44:57 +01:00
|
|
|
return IWineD3DResourceImpl_SetPriority((IWineD3DResource *)iface, PriorityNew);
|
2004-10-14 02:32:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DWORD WINAPI IWineD3DVertexBufferImpl_GetPriority(IWineD3DVertexBuffer *iface) {
|
2005-01-17 14:44:57 +01:00
|
|
|
return IWineD3DResourceImpl_GetPriority((IWineD3DResource *)iface);
|
2004-10-14 02:32:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void WINAPI IWineD3DVertexBufferImpl_PreLoad(IWineD3DVertexBuffer *iface) {
|
2005-01-17 14:44:57 +01:00
|
|
|
return IWineD3DResourceImpl_PreLoad((IWineD3DResource *)iface);
|
2004-10-14 02:32:04 +02:00
|
|
|
}
|
|
|
|
|
2006-03-09 23:21:16 +01:00
|
|
|
WINED3DRESOURCETYPE WINAPI IWineD3DVertexBufferImpl_GetType(IWineD3DVertexBuffer *iface) {
|
2005-01-17 14:44:57 +01:00
|
|
|
return IWineD3DResourceImpl_GetType((IWineD3DResource *)iface);
|
2004-10-14 02:32:04 +02:00
|
|
|
}
|
|
|
|
|
2004-11-23 14:52:46 +01:00
|
|
|
HRESULT WINAPI IWineD3DVertexBufferImpl_GetParent(IWineD3DVertexBuffer *iface, IUnknown **pParent) {
|
2005-01-17 14:44:57 +01:00
|
|
|
return IWineD3DResourceImpl_GetParent((IWineD3DResource *)iface, pParent);
|
2004-11-23 14:52:46 +01:00
|
|
|
}
|
2004-10-14 02:32:04 +02:00
|
|
|
|
|
|
|
/* ******************************************************
|
|
|
|
IWineD3DVertexBuffer IWineD3DVertexBuffer parts follow
|
|
|
|
****************************************************** */
|
|
|
|
HRESULT WINAPI IWineD3DVertexBufferImpl_Lock(IWineD3DVertexBuffer *iface, UINT OffsetToLock, UINT SizeToLock, BYTE** ppbData, DWORD Flags) {
|
|
|
|
IWineD3DVertexBufferImpl *This = (IWineD3DVertexBufferImpl *)iface;
|
2005-03-29 21:01:00 +02:00
|
|
|
TRACE("(%p) : returning memory of %p (base:%p,offset:%u)\n", This, This->resource.allocatedMemory + OffsetToLock, This->resource.allocatedMemory, OffsetToLock);
|
2004-10-14 02:32:04 +02:00
|
|
|
/* TODO: check Flags compatibility with This->currentDesc.Usage (see MSDN) */
|
2005-03-29 21:01:00 +02:00
|
|
|
*ppbData = This->resource.allocatedMemory + OffsetToLock;
|
2004-10-14 02:32:04 +02:00
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
HRESULT WINAPI IWineD3DVertexBufferImpl_Unlock(IWineD3DVertexBuffer *iface) {
|
|
|
|
IWineD3DVertexBufferImpl *This = (IWineD3DVertexBufferImpl *)iface;
|
|
|
|
TRACE("(%p) : stub\n", This);
|
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
HRESULT WINAPI IWineD3DVertexBufferImpl_GetDesc(IWineD3DVertexBuffer *iface, D3DVERTEXBUFFER_DESC *pDesc) {
|
|
|
|
IWineD3DVertexBufferImpl *This = (IWineD3DVertexBufferImpl *)iface;
|
|
|
|
|
|
|
|
TRACE("(%p)\n", This);
|
2005-03-29 21:01:00 +02:00
|
|
|
pDesc->Format = This->resource.format;
|
2004-11-24 19:13:41 +01:00
|
|
|
pDesc->Type = This->resource.resourceType;
|
2005-03-29 21:01:00 +02:00
|
|
|
pDesc->Usage = This->resource.usage;
|
|
|
|
pDesc->Pool = This->resource.pool;
|
|
|
|
pDesc->Size = This->resource.size;
|
2005-07-13 13:34:55 +02:00
|
|
|
pDesc->FVF = This->fvf;
|
2004-10-14 02:32:04 +02:00
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
2005-06-06 21:50:35 +02:00
|
|
|
const IWineD3DVertexBufferVtbl IWineD3DVertexBuffer_Vtbl =
|
2004-10-14 02:32:04 +02:00
|
|
|
{
|
2005-07-13 16:15:54 +02:00
|
|
|
/* IUnknown */
|
2004-10-14 02:32:04 +02:00
|
|
|
IWineD3DVertexBufferImpl_QueryInterface,
|
|
|
|
IWineD3DVertexBufferImpl_AddRef,
|
|
|
|
IWineD3DVertexBufferImpl_Release,
|
2005-07-13 16:15:54 +02:00
|
|
|
/* IWineD3DResource */
|
2004-11-23 14:52:46 +01:00
|
|
|
IWineD3DVertexBufferImpl_GetParent,
|
2004-10-14 02:32:04 +02:00
|
|
|
IWineD3DVertexBufferImpl_GetDevice,
|
|
|
|
IWineD3DVertexBufferImpl_SetPrivateData,
|
|
|
|
IWineD3DVertexBufferImpl_GetPrivateData,
|
|
|
|
IWineD3DVertexBufferImpl_FreePrivateData,
|
|
|
|
IWineD3DVertexBufferImpl_SetPriority,
|
|
|
|
IWineD3DVertexBufferImpl_GetPriority,
|
|
|
|
IWineD3DVertexBufferImpl_PreLoad,
|
|
|
|
IWineD3DVertexBufferImpl_GetType,
|
2005-07-13 16:15:54 +02:00
|
|
|
/* IWineD3DVertexBuffer */
|
2004-10-14 02:32:04 +02:00
|
|
|
IWineD3DVertexBufferImpl_Lock,
|
|
|
|
IWineD3DVertexBufferImpl_Unlock,
|
|
|
|
IWineD3DVertexBufferImpl_GetDesc
|
|
|
|
};
|
2005-07-24 19:11:33 +02:00
|
|
|
|
|
|
|
BYTE* WINAPI IWineD3DVertexBufferImpl_GetMemory(IWineD3DVertexBuffer* iface, DWORD iOffset) {
|
|
|
|
IWineD3DVertexBufferImpl *This = (IWineD3DVertexBufferImpl *)iface;
|
|
|
|
|
|
|
|
return This->resource.allocatedMemory + iOffset;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI IWineD3DVertexBufferImpl_ReleaseMemory(IWineD3DVertexBuffer* iface) {
|
|
|
|
return D3D_OK;
|
|
|
|
}
|