_open_osfhandle is expected to take the absence of either _O_TEXT or
[wine/gsoc_dplay.git] / dlls / d3d8 / vertexbuffer.c
blobc5a1e47d96727de39994eb134fccd35c2cbcacd6
1 /*
2 * IDirect3DResource8 implementation
4 * Copyright 2002 Jason Edmeades
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "config.h"
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winuser.h"
26 #include "wingdi.h"
27 #include "wine/debug.h"
29 #include "d3d8_private.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(d3d);
33 /* IDirect3DResource IUnknown parts follow: */
34 HRESULT WINAPI IDirect3DVertexBuffer8Impl_QueryInterface(LPDIRECT3DVERTEXBUFFER8 iface, REFIID riid, LPVOID *ppobj)
36 ICOM_THIS(IDirect3DVertexBuffer8Impl,iface);
38 if (IsEqualGUID(riid, &IID_IUnknown)
39 || IsEqualGUID(riid, &IID_IDirect3DResource8)
40 || IsEqualGUID(riid, &IID_IDirect3DVertexBuffer8)) {
41 IDirect3DVertexBuffer8Impl_AddRef(iface);
42 *ppobj = This;
43 return D3D_OK;
46 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
47 return E_NOINTERFACE;
50 ULONG WINAPI IDirect3DVertexBuffer8Impl_AddRef(LPDIRECT3DVERTEXBUFFER8 iface) {
51 ICOM_THIS(IDirect3DVertexBuffer8Impl,iface);
52 TRACE("(%p) : AddRef from %ld\n", This, This->ref);
53 return ++(This->ref);
56 ULONG WINAPI IDirect3DVertexBuffer8Impl_Release(LPDIRECT3DVERTEXBUFFER8 iface) {
57 ICOM_THIS(IDirect3DVertexBuffer8Impl,iface);
58 ULONG ref = --This->ref;
59 TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
60 if (ref == 0) {
61 if (NULL != This->allocatedMemory) HeapFree(GetProcessHeap(), 0, This->allocatedMemory);
62 HeapFree(GetProcessHeap(), 0, This);
64 return ref;
67 /* IDirect3DResource Interface follow: */
68 HRESULT WINAPI IDirect3DVertexBuffer8Impl_GetDevice(LPDIRECT3DVERTEXBUFFER8 iface, IDirect3DDevice8** ppDevice) {
69 ICOM_THIS(IDirect3DVertexBuffer8Impl,iface);
70 TRACE("(%p) : returning %p\n", This, This->Device);
71 *ppDevice = (LPDIRECT3DDEVICE8) This->Device;
72 return D3D_OK;
74 HRESULT WINAPI IDirect3DVertexBuffer8Impl_SetPrivateData(LPDIRECT3DVERTEXBUFFER8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
75 ICOM_THIS(IDirect3DVertexBuffer8Impl,iface);
76 FIXME("(%p) : stub\n", This); return D3D_OK;
78 HRESULT WINAPI IDirect3DVertexBuffer8Impl_GetPrivateData(LPDIRECT3DVERTEXBUFFER8 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
79 ICOM_THIS(IDirect3DVertexBuffer8Impl,iface);
80 FIXME("(%p) : stub\n", This); return D3D_OK;
82 HRESULT WINAPI IDirect3DVertexBuffer8Impl_FreePrivateData(LPDIRECT3DVERTEXBUFFER8 iface, REFGUID refguid) {
83 ICOM_THIS(IDirect3DVertexBuffer8Impl,iface);
84 FIXME("(%p) : stub\n", This); return D3D_OK;
86 DWORD WINAPI IDirect3DVertexBuffer8Impl_SetPriority(LPDIRECT3DVERTEXBUFFER8 iface, DWORD PriorityNew) {
87 ICOM_THIS(IDirect3DVertexBuffer8Impl,iface);
88 FIXME("(%p) : stub\n", This); return D3D_OK;
90 DWORD WINAPI IDirect3DVertexBuffer8Impl_GetPriority(LPDIRECT3DVERTEXBUFFER8 iface) {
91 ICOM_THIS(IDirect3DVertexBuffer8Impl,iface);
92 FIXME("(%p) : stub\n", This); return D3D_OK;
94 void WINAPI IDirect3DVertexBuffer8Impl_PreLoad(LPDIRECT3DVERTEXBUFFER8 iface) {
95 ICOM_THIS(IDirect3DVertexBuffer8Impl,iface);
96 FIXME("(%p) : stub\n", This);
98 D3DRESOURCETYPE WINAPI IDirect3DVertexBuffer8Impl_GetType(LPDIRECT3DVERTEXBUFFER8 iface) {
99 ICOM_THIS(IDirect3DVertexBuffer8Impl,iface);
100 TRACE("(%p) : returning %d\n", This, This->ResourceType);
101 return This->ResourceType;
104 /* IDirect3DVertexBuffer8 */
105 HRESULT WINAPI IDirect3DVertexBuffer8Impl_Lock(LPDIRECT3DVERTEXBUFFER8 iface, UINT OffsetToLock, UINT SizeToLock, BYTE** ppbData, DWORD Flags) {
106 ICOM_THIS(IDirect3DVertexBuffer8Impl,iface);
107 TRACE("(%p) : returning memory of %p (base:%p,offset:%u)\n", This, This->allocatedMemory + OffsetToLock, This->allocatedMemory, OffsetToLock);
108 /* TODO: check Flags compatibility with This->currentDesc.Usage (see MSDN) */
109 *ppbData = This->allocatedMemory + OffsetToLock;
110 return D3D_OK;
112 HRESULT WINAPI IDirect3DVertexBuffer8Impl_Unlock(LPDIRECT3DVERTEXBUFFER8 iface) {
113 ICOM_THIS(IDirect3DVertexBuffer8Impl,iface);
114 TRACE("(%p) : stub\n", This);
115 return D3D_OK;
117 HRESULT WINAPI IDirect3DVertexBuffer8Impl_GetDesc(LPDIRECT3DVERTEXBUFFER8 iface, D3DVERTEXBUFFER_DESC *pDesc) {
118 ICOM_THIS(IDirect3DVertexBuffer8Impl,iface);
120 TRACE("(%p)\n", This);
121 pDesc->Format= This->currentDesc.Format;
122 pDesc->Type= This->currentDesc.Type;
123 pDesc->Usage= This->currentDesc.Usage;
124 pDesc->Pool= This->currentDesc.Pool;
125 pDesc->Size= This->currentDesc.Size;
126 pDesc->FVF= This->currentDesc.FVF;
127 return D3D_OK;
130 ICOM_VTABLE(IDirect3DVertexBuffer8) Direct3DVertexBuffer8_Vtbl =
132 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
133 IDirect3DVertexBuffer8Impl_QueryInterface,
134 IDirect3DVertexBuffer8Impl_AddRef,
135 IDirect3DVertexBuffer8Impl_Release,
136 IDirect3DVertexBuffer8Impl_GetDevice,
137 IDirect3DVertexBuffer8Impl_SetPrivateData,
138 IDirect3DVertexBuffer8Impl_GetPrivateData,
139 IDirect3DVertexBuffer8Impl_FreePrivateData,
140 IDirect3DVertexBuffer8Impl_SetPriority,
141 IDirect3DVertexBuffer8Impl_GetPriority,
142 IDirect3DVertexBuffer8Impl_PreLoad,
143 IDirect3DVertexBuffer8Impl_GetType,
144 IDirect3DVertexBuffer8Impl_Lock,
145 IDirect3DVertexBuffer8Impl_Unlock,
146 IDirect3DVertexBuffer8Impl_GetDesc