mscms: Handle errors from lcms more gracefully.
[wine] / dlls / ddraw / vertexbuffer.c
1 /* Direct3D Vertex Buffer
2  * Copyright (c) 2002 Lionel ULMER
3  * Copyright (c) 2006 Stefan DÖSINGER
4  *
5  * This file contains the implementation of Direct3DVertexBuffer COM object
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20  */
21
22 #include "config.h"
23 #include "wine/port.h"
24 #include "wine/debug.h"
25
26 #include <assert.h>
27 #include <stdarg.h>
28 #include <string.h>
29 #include <stdlib.h>
30
31 #define COBJMACROS
32
33 #include "windef.h"
34 #include "winbase.h"
35 #include "winerror.h"
36 #include "wingdi.h"
37 #include "wine/exception.h"
38
39 #include "ddraw.h"
40 #include "d3d.h"
41
42 #include "ddraw_private.h"
43
44 WINE_DEFAULT_DEBUG_CHANNEL(d3d7);
45 WINE_DECLARE_DEBUG_CHANNEL(ddraw_thunk);
46
47 /*****************************************************************************
48  * IUnknown Methods
49  *****************************************************************************/
50
51 /*****************************************************************************
52  * IDirect3DVertexBuffer7::QueryInterface
53  *
54  * The QueryInterface Method for Vertex Buffers
55  * For a link to QueryInterface rules, see IDirectDraw7::QueryInterface
56  *
57  * Params
58  *  riid: Queryied Interface id
59  *  obj: Address to return the interface pointer
60  *
61  * Returns:
62  *  S_OK on success
63  *  E_NOINTERFACE if the interface wasn't found
64  *
65  *****************************************************************************/
66 static HRESULT WINAPI
67 IDirect3DVertexBufferImpl_QueryInterface(IDirect3DVertexBuffer7 *iface,
68                                          REFIID riid,
69                                          void  **obj)
70 {
71     IDirect3DVertexBufferImpl *This = (IDirect3DVertexBufferImpl *)iface;
72     TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), obj);
73
74     /* By default, set the object pointer to NULL */
75     *obj = NULL;
76
77     if ( IsEqualGUID( &IID_IUnknown,  riid ) )
78     {
79         IUnknown_AddRef(iface);
80         *obj = iface;
81         TRACE("  Creating IUnknown interface at %p.\n", *obj);
82         return S_OK;
83     }
84     if ( IsEqualGUID( &IID_IDirect3DVertexBuffer, riid ) )
85     {
86         IUnknown_AddRef(iface);
87         *obj = &This->IDirect3DVertexBuffer_vtbl;
88         TRACE("  Creating IDirect3DVertexBuffer interface %p\n", *obj);
89         return S_OK;
90     }
91     if ( IsEqualGUID( &IID_IDirect3DVertexBuffer7, riid ) )
92     {
93         IUnknown_AddRef(iface);
94         *obj = iface;
95         TRACE("  Creating IDirect3DVertexBuffer7 interface %p\n", *obj);
96         return S_OK;
97     }
98     FIXME("(%p): interface for IID %s NOT found!\n", This, debugstr_guid(riid));
99     return E_NOINTERFACE;
100 }
101
102 static HRESULT WINAPI
103 Thunk_IDirect3DVertexBufferImpl_1_QueryInterface(IDirect3DVertexBuffer *iface,
104                                                  REFIID riid,
105                                                  void **obj)
106 {
107     IDirect3DVertexBufferImpl *This = vb_from_vb1(iface);
108     TRACE_(ddraw_thunk)("(%p)->(%s,%p) thunking to IDirect3DVertexBuffer7 interface.\n", This, debugstr_guid(riid), obj);
109
110     return IDirect3DVertexBuffer7_QueryInterface((IDirect3DVertexBuffer7 *)This, riid, obj);
111 }
112
113 /*****************************************************************************
114  * IDirect3DVertexBuffer7::AddRef
115  *
116  * AddRef for Vertex Buffers
117  *
118  * Returns:
119  *  The new refcount
120  *
121  *****************************************************************************/
122 static ULONG WINAPI
123 IDirect3DVertexBufferImpl_AddRef(IDirect3DVertexBuffer7 *iface)
124 {
125     IDirect3DVertexBufferImpl *This = (IDirect3DVertexBufferImpl *)iface;
126     ULONG ref = InterlockedIncrement(&This->ref);
127
128     TRACE("(%p/%p)->() incrementing from %u.\n", This, iface, ref - 1);
129
130     return ref;
131 }
132
133 static ULONG WINAPI
134 Thunk_IDirect3DVertexBufferImpl_1_AddRef(IDirect3DVertexBuffer *iface)
135 {
136     IDirect3DVertexBufferImpl *This = vb_from_vb1(iface);
137     TRACE_(ddraw_thunk)("(%p)->() thunking to IDirect3DVertexBuffer7 interface.\n", This);
138
139     return IDirect3DVertexBuffer7_AddRef((IDirect3DVertexBuffer7 *)This);
140 }
141
142
143 /*****************************************************************************
144  * IDirect3DVertexBuffer7::Release
145  *
146  * Release for Vertex Buffers
147  *
148  * Returns:
149  *  The new refcount
150  *
151  *****************************************************************************/
152 static ULONG WINAPI
153 IDirect3DVertexBufferImpl_Release(IDirect3DVertexBuffer7 *iface)
154 {
155     IDirect3DVertexBufferImpl *This = (IDirect3DVertexBufferImpl *)iface;
156     ULONG ref = InterlockedDecrement(&This->ref);
157
158     TRACE("(%p)->() decrementing from %u.\n", This, ref + 1);
159
160     if (ref == 0)
161     {
162         IWineD3DVertexBuffer *curVB = NULL;
163         UINT offset, stride;
164
165         EnterCriticalSection(&ddraw_cs);
166         /* D3D7 Vertex buffers don't stay bound in the device, they are passed as a parameter
167          * to drawPrimitiveVB. DrawPrimitiveVB sets them as the stream source in wined3d,
168          * and they should get unset there before they are destroyed
169          */
170         IWineD3DDevice_GetStreamSource(This->ddraw->wineD3DDevice,
171                                        0 /* Stream number */,
172                                        &curVB,
173                                        &offset,
174                                        &stride);
175         if(curVB == This->wineD3DVertexBuffer)
176         {
177             IWineD3DDevice_SetStreamSource(This->ddraw->wineD3DDevice,
178                                         0 /* Steam number */,
179                                         NULL /* stream data */,
180                                         0 /* Offset */,
181                                         0 /* stride */);
182         }
183         if(curVB)
184         {
185             IWineD3DVertexBuffer_Release(curVB); /* For the GetStreamSource */
186         }
187
188         IWineD3DVertexDeclaration_Release(This->wineD3DVertexDeclaration);
189         IWineD3DVertexBuffer_Release(This->wineD3DVertexBuffer);
190         LeaveCriticalSection(&ddraw_cs);
191         HeapFree(GetProcessHeap(), 0, This);
192
193         return 0;
194     }
195     return ref;
196 }
197
198 static ULONG WINAPI
199 Thunk_IDirect3DVertexBufferImpl_1_Release(IDirect3DVertexBuffer *iface)
200 {
201     IDirect3DVertexBufferImpl *This = vb_from_vb1(iface);
202     TRACE_(ddraw_thunk)("(%p)->() thunking to IDirect3DVertexBuffer7 interface.\n", This);
203
204     return IDirect3DVertexBuffer7_Release((IDirect3DVertexBuffer7 *)This);
205 }
206
207 /*****************************************************************************
208  * IDirect3DVertexBuffer Methods
209  *****************************************************************************/
210
211 /*****************************************************************************
212  * IDirect3DVertexBuffer7::Lock
213  *
214  * Locks the vertex buffer and returns a pointer to the vertex data
215  * Locking vertex buffers is similar to locking surfaces, because Windows
216  * uses surfaces to store vertex data internally (According to the DX sdk)
217  *
218  * Params:
219  *  Flags: Locking flags. Relevant here are DDLOCK_READONLY, DDLOCK_WRITEONLY,
220  *         DDLOCK_DISCARDCONTENTS and DDLOCK_NOOVERWRITE.
221  *  Data:  Returns a pointer to the vertex data
222  *  Size:  Returns the size of the buffer if not NULL
223  *
224  * Returns:
225  *  D3D_OK on success
226  *  DDERR_INVALIDPARAMS if Data is NULL
227  *  D3DERR_VERTEXBUFFEROPTIMIZED if called on an optimized buffer(WineD3D)
228  *
229  *****************************************************************************/
230 static HRESULT WINAPI
231 IDirect3DVertexBufferImpl_Lock(IDirect3DVertexBuffer7 *iface,
232                                DWORD Flags,
233                                void **Data,
234                                DWORD *Size)
235 {
236     IDirect3DVertexBufferImpl *This = (IDirect3DVertexBufferImpl *)iface;
237     WINED3DVERTEXBUFFER_DESC Desc;
238     HRESULT hr;
239     TRACE("(%p)->(%08x,%p,%p)\n", This, Flags, Data, Size);
240
241     EnterCriticalSection(&ddraw_cs);
242     if(Size)
243     {
244         /* Get the size, for returning it, and for locking */
245         hr = IWineD3DVertexBuffer_GetDesc(This->wineD3DVertexBuffer,
246                                           &Desc);
247         if(hr != D3D_OK)
248         {
249             ERR("(%p) IWineD3DVertexBuffer::GetDesc failed with hr=%08x\n", This, hr);
250             LeaveCriticalSection(&ddraw_cs);
251             return hr;
252         }
253         *Size = Desc.Size;
254     }
255
256     hr = IWineD3DVertexBuffer_Lock(This->wineD3DVertexBuffer,
257                                    0 /* OffsetToLock */,
258                                    0 /* SizeToLock, 0 == Full lock */,
259                                    (BYTE **) Data,
260                                    Flags);
261     LeaveCriticalSection(&ddraw_cs);
262     return hr;
263 }
264
265 static HRESULT WINAPI
266 Thunk_IDirect3DVertexBufferImpl_1_Lock(IDirect3DVertexBuffer *iface,
267                                        DWORD Flags,
268                                        void **Data,
269                                        DWORD *Size)
270 {
271     IDirect3DVertexBufferImpl *This = vb_from_vb1(iface);
272     TRACE_(ddraw_thunk)("(%p)->(%08x,%p,%p) thunking to IDirect3DVertexBuffer7 interface.\n", This, Flags, Data, Size);
273
274     return IDirect3DVertexBuffer7_Lock((IDirect3DVertexBuffer7 *)This, Flags, Data, Size);
275 }
276
277 /*****************************************************************************
278  * IDirect3DVertexBuffer7::Unlock
279  *
280  * Unlocks a vertex Buffer
281  *
282  * Returns:
283  *  D3D_OK on success
284  *
285  *****************************************************************************/
286 static HRESULT WINAPI
287 IDirect3DVertexBufferImpl_Unlock(IDirect3DVertexBuffer7 *iface)
288 {
289     IDirect3DVertexBufferImpl *This = (IDirect3DVertexBufferImpl *)iface;
290     HRESULT hr;
291     TRACE("(%p)->()\n", This);
292
293     EnterCriticalSection(&ddraw_cs);
294     hr = IWineD3DVertexBuffer_Unlock(This->wineD3DVertexBuffer);
295     LeaveCriticalSection(&ddraw_cs);
296
297     return hr;
298 }
299
300 static HRESULT WINAPI
301 Thunk_IDirect3DVertexBufferImpl_1_Unlock(IDirect3DVertexBuffer *iface)
302 {
303     IDirect3DVertexBufferImpl *This = vb_from_vb1(iface);
304     TRACE_(ddraw_thunk)("(%p)->() thunking to IDirect3DVertexBuffer7 interface.\n", This);
305
306     return IDirect3DVertexBuffer7_Unlock((IDirect3DVertexBuffer7 *)This);
307 }
308
309
310 /*****************************************************************************
311  * IDirect3DVertexBuffer7::ProcessVertices
312  *
313  * Processes untransformed Vertices into a transformed or optimized vertex
314  * buffer. It can also perform other operations, such as lighting or clipping
315  *
316  * Params
317  *  VertexOp: Operation(s) to perform: D3DVOP_CLIP, _EXTENTS, _LIGHT, _TRANSFORM
318  *  DestIndex: Index in the destination buffer(This), where the vertices are
319  *             placed
320  *  Count: Number of Vertices in the Source buffer to process
321  *  SrcBuffer: Source vertex buffer
322  *  SrcIndex: Index of the first vertex in the src buffer to process
323  *  D3DDevice: Device to use for transformation
324  *  Flags: 0 for default, D3DPV_DONOTCOPYDATA to prevent copying
325  *         unchaned vertices
326  *
327  * Returns:
328  *  D3D_OK on success
329  *  DDERR_INVALIDPARAMS If D3DVOP_TRANSFORM wasn't passed
330  *
331  *****************************************************************************/
332 static HRESULT WINAPI
333 IDirect3DVertexBufferImpl_ProcessVertices(IDirect3DVertexBuffer7 *iface,
334                                           DWORD VertexOp,
335                                           DWORD DestIndex,
336                                           DWORD Count,
337                                           IDirect3DVertexBuffer7 *SrcBuffer,
338                                           DWORD SrcIndex,
339                                           IDirect3DDevice7 *D3DDevice,
340                                           DWORD Flags)
341 {
342     IDirect3DVertexBufferImpl *This = (IDirect3DVertexBufferImpl *)iface;
343     IDirect3DVertexBufferImpl *Src = (IDirect3DVertexBufferImpl *)SrcBuffer;
344     IDirect3DDeviceImpl *D3D = (IDirect3DDeviceImpl *)D3DDevice;
345     BOOL oldClip, doClip;
346     HRESULT hr;
347     WINED3DVERTEXBUFFER_DESC Desc;
348
349     TRACE("(%p)->(%08x,%d,%d,%p,%d,%p,%08x)\n", This, VertexOp, DestIndex, Count, Src, SrcIndex, D3D, Flags);
350
351     /* Vertex operations:
352      * D3DVOP_CLIP: Clips vertices outside the viewing frustrum. Needs clipping information
353      * in the vertex buffer (Buffer may not be created with D3DVBCAPS_DONOTCLIP)
354      * D3DVOP_EXTENTS: Causes the screen extents to be updated when rendering the vertices
355      * D3DVOP_LIGHT: Lights the vertices
356      * D3DVOP_TRANSFORM: Transform the vertices. This flag is necessary
357      *
358      * WineD3D only transforms and clips the vertices by now, so EXTENTS and LIGHT
359      * are not implemented. Clipping is disabled ATM, because of unsure conditions.
360      */
361     if( !(VertexOp & D3DVOP_TRANSFORM) ) return DDERR_INVALIDPARAMS;
362
363     EnterCriticalSection(&ddraw_cs);
364     /* WineD3D doesn't know d3d7 vertex operation, it uses
365      * render states instead. Set the render states according to
366      * the vertex ops
367      */
368     doClip = VertexOp & D3DVOP_CLIP ? TRUE : FALSE;
369     IWineD3DDevice_GetRenderState(D3D->wineD3DDevice,
370                                   WINED3DRS_CLIPPING,
371                                   (DWORD *) &oldClip);
372     if(doClip != oldClip)
373     {
374         IWineD3DDevice_SetRenderState(D3D->wineD3DDevice,
375                                       WINED3DRS_CLIPPING,
376                                       doClip);
377     }
378
379     IWineD3DVertexBuffer_GetDesc(Src->wineD3DVertexBuffer,
380                                  &Desc);
381     IWineD3DDevice_SetStreamSource(D3D->wineD3DDevice,
382                                    0, /* Stream No */
383                                    Src->wineD3DVertexBuffer,
384                                    0, /* Offset */
385                                    get_flexible_vertex_size(Desc.FVF));
386     IWineD3DDevice_SetVertexDeclaration(D3D->wineD3DDevice,
387                                         Src->wineD3DVertexDeclaration);
388     hr = IWineD3DDevice_ProcessVertices(D3D->wineD3DDevice,
389                                         SrcIndex,
390                                         DestIndex,
391                                         Count,
392                                         This->wineD3DVertexBuffer,
393                                         NULL /* Output vdecl */,
394                                         Flags);
395
396     /* Restore the states if needed */
397     if(doClip != oldClip)
398         IWineD3DDevice_SetRenderState(D3D->wineD3DDevice,
399                                       WINED3DRS_CLIPPING,
400                                       oldClip);
401     LeaveCriticalSection(&ddraw_cs);
402     return hr;
403 }
404
405 static HRESULT WINAPI
406 Thunk_IDirect3DVertexBufferImpl_1_ProcessVertices(IDirect3DVertexBuffer *iface,
407                                                   DWORD VertexOp,
408                                                   DWORD DestIndex,
409                                                   DWORD Count,
410                                                   IDirect3DVertexBuffer *SrcBuffer,
411                                                   DWORD SrcIndex,
412                                                   IDirect3DDevice3 *D3DDevice,
413                                                   DWORD Flags)
414 {
415     IDirect3DVertexBufferImpl *This = vb_from_vb1(iface);
416     IDirect3DVertexBufferImpl *Src = SrcBuffer ? vb_from_vb1(SrcBuffer) : NULL;
417     IDirect3DDeviceImpl *D3D = D3DDevice ? device_from_device3(D3DDevice) : NULL;
418
419     TRACE_(ddraw_thunk)("(%p)->(%08x,%08x,%08x,%p,%08x,%p,%08x) thunking to IDirect3DVertexBuffer7 interface.\n", This, VertexOp, DestIndex, Count, Src, SrcIndex, D3D, Flags);
420
421     return IDirect3DVertexBuffer7_ProcessVertices((IDirect3DVertexBuffer7 *)This, VertexOp, DestIndex,
422             Count, (IDirect3DVertexBuffer7 *)Src, SrcIndex, (IDirect3DDevice7 *)D3D, Flags);
423 }
424
425 /*****************************************************************************
426  * IDirect3DVertexBuffer7::GetVertexBufferDesc
427  *
428  * Returns the description of a vertex buffer
429  *
430  * Params:
431  *  Desc: Address to write the description to
432  *
433  * Returns
434  *  DDERR_INVALIDPARAMS if Desc is NULL
435  *  D3D_OK on success
436  *
437  *****************************************************************************/
438 static HRESULT WINAPI
439 IDirect3DVertexBufferImpl_GetVertexBufferDesc(IDirect3DVertexBuffer7 *iface,
440                                               D3DVERTEXBUFFERDESC *Desc)
441 {
442     IDirect3DVertexBufferImpl *This = (IDirect3DVertexBufferImpl *)iface;
443     WINED3DVERTEXBUFFER_DESC WDesc;
444     HRESULT hr;
445     TRACE("(%p)->(%p)\n", This, Desc);
446
447     if(!Desc) return DDERR_INVALIDPARAMS;
448
449     EnterCriticalSection(&ddraw_cs);
450     hr = IWineD3DVertexBuffer_GetDesc(This->wineD3DVertexBuffer,
451                                       &WDesc);
452     if(hr != D3D_OK)
453     {
454         ERR("(%p) IWineD3DVertexBuffer::GetDesc failed with hr=%08x\n", This, hr);
455         LeaveCriticalSection(&ddraw_cs);
456         return hr;
457     }
458
459     /* Now fill the Desc structure */
460     Desc->dwCaps = This->Caps;
461     Desc->dwFVF = WDesc.FVF;
462     Desc->dwNumVertices = WDesc.Size / get_flexible_vertex_size(WDesc.FVF);
463     LeaveCriticalSection(&ddraw_cs);
464
465     return D3D_OK;
466 }
467
468 static HRESULT WINAPI
469 Thunk_IDirect3DVertexBufferImpl_1_GetVertexBufferDesc(IDirect3DVertexBuffer *iface,
470                                                       D3DVERTEXBUFFERDESC *Desc)
471 {
472     IDirect3DVertexBufferImpl *This = vb_from_vb1(iface);
473     TRACE_(ddraw_thunk)("(%p)->(%p) thunking to IDirect3DVertexBuffer7 interface.\n", This, Desc);
474
475     return IDirect3DVertexBuffer7_GetVertexBufferDesc((IDirect3DVertexBuffer7 *)This, Desc);
476 }
477
478
479 /*****************************************************************************
480  * IDirect3DVertexBuffer7::Optimize
481  *
482  * Converts an unoptimized vertex buffer into an optimized buffer
483  *
484  * Params:
485  *  D3DDevice: Device for which this buffer is optimized
486  *  Flags: Not used, should be set to 0
487  *
488  * Returns
489  *  D3D_OK, because it's a stub
490  *
491  *****************************************************************************/
492 static HRESULT WINAPI
493 IDirect3DVertexBufferImpl_Optimize(IDirect3DVertexBuffer7 *iface,
494                                    IDirect3DDevice7 *D3DDevice,
495                                    DWORD Flags)
496 {
497     IDirect3DVertexBufferImpl *This = (IDirect3DVertexBufferImpl *)iface;
498     IDirect3DDeviceImpl *D3D = (IDirect3DDeviceImpl *)D3DDevice;
499     static BOOL hide = FALSE;
500
501     if (!hide)
502     {
503         FIXME("(%p)->(%p,%08x): stub!\n", This, D3D, Flags);
504         hide = TRUE;
505     }
506
507     /* We could forward this call to WineD3D and take advantage
508      * of it once we use OpenGL vertex buffers
509      */
510     EnterCriticalSection(&ddraw_cs);
511     This->Caps |= D3DVBCAPS_OPTIMIZED;
512     LeaveCriticalSection(&ddraw_cs);
513
514     return DD_OK;
515 }
516
517 static HRESULT WINAPI
518 Thunk_IDirect3DVertexBufferImpl_1_Optimize(IDirect3DVertexBuffer *iface,
519                                            IDirect3DDevice3 *D3DDevice,
520                                            DWORD Flags)
521 {
522     IDirect3DVertexBufferImpl *This = vb_from_vb1(iface);
523     IDirect3DDeviceImpl *D3D = D3DDevice ? device_from_device3(D3DDevice) : NULL;
524     TRACE_(ddraw_thunk)("(%p)->(%p,%08x) thunking to IDirect3DVertexBuffer7 interface.\n", This, D3D, Flags);
525
526     return IDirect3DVertexBuffer7_Optimize((IDirect3DVertexBuffer7 *)This, (IDirect3DDevice7 *)D3D, Flags);
527 }
528
529 /*****************************************************************************
530  * IDirect3DVertexBuffer7::ProcessVerticesStrided
531  *
532  * This method processes untransformed strided vertices into a processed
533  * or optimized vertex buffer.
534  *
535  * For more details on the parameters, see
536  * IDirect3DVertexBuffer7::ProcessVertices
537  *
538  * Params:
539  *  VertexOp: Operations to perform
540  *  DestIndex: Destination index to write the vertices to
541  *  Count: Number of input vertices
542  *  StrideData: Array containing the input vertices
543  *  VertexTypeDesc: Vertex Description or source index?????????
544  *  D3DDevice: IDirect3DDevice7 to use for processing
545  *  Flags: Can be D3DPV_DONOTCOPYDATA to avoid copying unmodified vertices
546  *
547  * Returns
548  *  D3D_OK on success, or DDERR_*
549  *
550  *****************************************************************************/
551 static HRESULT WINAPI
552 IDirect3DVertexBufferImpl_ProcessVerticesStrided(IDirect3DVertexBuffer7 *iface,
553                                                  DWORD VertexOp,
554                                                  DWORD DestIndex,
555                                                  DWORD Count,
556                                                  D3DDRAWPRIMITIVESTRIDEDDATA *StrideData,
557                                                  DWORD VertexTypeDesc,
558                                                  IDirect3DDevice7 *D3DDevice,
559                                                  DWORD Flags)
560 {
561     IDirect3DVertexBufferImpl *This = (IDirect3DVertexBufferImpl *)iface;
562     IDirect3DDeviceImpl *D3D = (IDirect3DDeviceImpl *)D3DDevice;
563     FIXME("(%p)->(%08x,%08x,%08x,%p,%08x,%p,%08x): stub!\n", This, VertexOp, DestIndex, Count, StrideData, VertexTypeDesc, D3D, Flags);
564     return DD_OK;
565 }
566
567 /*****************************************************************************
568  * The VTables
569  *****************************************************************************/
570
571 const IDirect3DVertexBuffer7Vtbl IDirect3DVertexBuffer7_Vtbl =
572 {
573     /*** IUnknown Methods ***/
574     IDirect3DVertexBufferImpl_QueryInterface,
575     IDirect3DVertexBufferImpl_AddRef,
576     IDirect3DVertexBufferImpl_Release,
577     /*** IDirect3DVertexBuffer Methods ***/
578     IDirect3DVertexBufferImpl_Lock,
579     IDirect3DVertexBufferImpl_Unlock,
580     IDirect3DVertexBufferImpl_ProcessVertices,
581     IDirect3DVertexBufferImpl_GetVertexBufferDesc,
582     IDirect3DVertexBufferImpl_Optimize,
583     /*** IDirect3DVertexBuffer7 Methods ***/
584     IDirect3DVertexBufferImpl_ProcessVerticesStrided
585 };
586
587 const IDirect3DVertexBufferVtbl IDirect3DVertexBuffer1_Vtbl =
588 {
589     /*** IUnknown Methods ***/
590     Thunk_IDirect3DVertexBufferImpl_1_QueryInterface,
591     Thunk_IDirect3DVertexBufferImpl_1_AddRef,
592     Thunk_IDirect3DVertexBufferImpl_1_Release,
593     /*** IDirect3DVertexBuffer Methods ***/
594     Thunk_IDirect3DVertexBufferImpl_1_Lock,
595     Thunk_IDirect3DVertexBufferImpl_1_Unlock,
596     Thunk_IDirect3DVertexBufferImpl_1_ProcessVertices,
597     Thunk_IDirect3DVertexBufferImpl_1_GetVertexBufferDesc,
598     Thunk_IDirect3DVertexBufferImpl_1_Optimize
599 };