~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/ddraw/vertexbuffer.c

Version: ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~ [ wine-1.0-rc5 ] ~ [ wine-1.0-rc4 ] ~ [ wine-1.0-rc3 ] ~ [ wine-1.0-rc2 ] ~ [ wine-1.0-rc1 ] ~ [ wine-0.9.61 ] ~ [ wine-0.9.60 ] ~ [ wine-0.9.59 ] ~ [ wine-0.9.58 ] ~ [ wine-0.9.57 ] ~ [ wine-0.9.56 ] ~ [ wine-0.9.55 ] ~ [ wine-0.9.54 ] ~ [ wine-0.9.53 ] ~ [ wine-0.9.52 ] ~ [ wine-0.9.51 ] ~ [ wine-0.9.50 ] ~ [ wine-0.9.49 ] ~ [ wine-0.9.48 ] ~ [ wine-0.9.47 ] ~ [ wine-0.9.46 ] ~ [ wine-0.9.45 ] ~ [ wine-0.9.44 ] ~ [ wine-0.9.43 ] ~ [ wine-0.9.42 ] ~ [ wine-0.9.41 ] ~ [ wine-0.9.40 ] ~ [ wine-0.9.39 ] ~ [ wine-0.9.38 ] ~ [ wine-0.9.37 ] ~ [ wine-0.9.36 ] ~ [ wine-0.9.35 ] ~ [ wine-0.9.34 ] ~ [ wine-0.9.33 ] ~ [ wine-0.9.32 ] ~ [ wine-0.9.31 ] ~ [ wine-0.9.30 ] ~ [ wine-0.9.29 ] ~ [ wine-0.9.28 ] ~ [ wine-0.9.27 ] ~ [ wine-0.9.26 ] ~ [ wine-0.9.25 ] ~ [ wine-0.9.24 ] ~ [ wine-0.9.23 ] ~ [ wine-0.9.22 ] ~ [ wine-0.9.21 ] ~ [ wine-0.9.20 ] ~ [ wine-0.9.19 ] ~ [ wine-0.9.18 ] ~ [ wine-0.9.17 ] ~ [ wine-0.9.16 ] ~ [ wine-0.9.15 ] ~ [ wine-0.9.14 ] ~ [ wine-0.9.13 ] ~ [ wine-0.9.12 ] ~ [ wine-0.9.11 ] ~ [ wine-0.9.10 ] ~ [ wine-0.9.9 ] ~ [ wine-0.9.8 ] ~ [ wine-0.9.7 ] ~ [ wine-0.9.6 ] ~ [ wine-0.9.5 ] ~ [ wine-0.9.4 ] ~ [ wine-0.9.3 ] ~ [ wine-0.9.2 ] ~ [ wine-0.9.1 ] ~ [ wine-0.9 ] ~ [ wine20050930 ] ~ [ wine20050830 ] ~ [ wine20050725 ] ~ [ wine20050628 ] ~ [ wine20050524 ] ~ [ wine20050419 ] ~ [ wine20050310 ] ~ [ wine20050211 ] ~ [ wine20050111 ] ~ [ wine20041201 ] ~ [ wine20041019 ] ~ [ wine20040914 ] ~ [ wine20040813 ] ~ [ wine20040716 ] ~ [ wine20040615 ] ~ [ wine20040505 ] ~ [ wine20040408 ] ~ [ wine20040309 ] ~ [ wine20040213 ] ~ [ wine20040121 ] ~ [ wine20031212 ] ~ [ wine20031118 ] ~ [ wine20031016 ] ~ [ wine20030911 ] ~ [ wine20030813 ] ~ [ wine20030709 ] ~ [ wine20030618 ] ~ [ wine20030508 ] ~ [ wine20030408 ] ~ [ wine20030318 ] ~ [ wine20030219 ] ~ [ wine20030115 ] ~ [ wine20021219 ] ~ [ wine20021125 ] ~ [ wine20021031 ] ~ [ wine20021007 ] ~ [ wine20020904 ] ~ [ wine20020804 ] ~ [ wine20020710 ] ~ [ wine20020605 ] ~ [ wine20020509 ] ~ [ wine20020411 ] ~ [ wine20020310 ] ~ [ wine20020228 ] ~ [ wine20011226 ] ~ [ wine20011108 ] ~ [ wine20011004 ] ~ [ wine20010824 ] ~ [ wine20010731 ] ~ [ wine20010629 ] ~ [ wine20010510 ] ~ [ wine20010418 ] ~ [ wine20010326 ] ~ [ wine20010305 ] ~ [ wine20010216 ] ~ [ wine20010112 ] ~ [ wine20001222 ] ~ [ wine20001202 ] ~ [ wine20001026 ] ~ [ wine20001002 ] ~ [ wine20000909 ] ~ [ wine20000821 ] ~ [ wine20000801 ] ~ [ wine20000716 ] ~ [ wine20000326 ] ~ [ wine20000227 ] ~ [ wine20000130 ] ~ [ wine20000109 ] ~

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

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.