/***************************************************************************** * IDirect3DVertexBuffer7::GetVertexBufferDesc * * Returns the description of a vertex buffer * * Params: * Desc: Address to write the description to * * Returns * DDERR_INVALIDPARAMS if Desc is NULL * D3D_OK on success * *****************************************************************************/ static HRESULT WINAPI IDirect3DVertexBufferImpl_GetVertexBufferDesc(IDirect3DVertexBuffer7 *iface, D3DVERTEXBUFFERDESC *Desc) { ICOM_THIS_FROM(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer7, iface); WINED3DVERTEXBUFFER_DESC WDesc; HRESULT hr; TRACE("(%p)->(%p)\n", This, Desc); if(!Desc) return DDERR_INVALIDPARAMS; EnterCriticalSection(&ddraw_cs); hr = IWineD3DVertexBuffer_GetDesc(This->wineD3DVertexBuffer, &WDesc); if(hr != D3D_OK) { ERR("(%p) IWineD3DVertexBuffer::GetDesc failed with hr=%08x\n", This, hr); LeaveCriticalSection(&ddraw_cs); return hr; } /* Now fill the Desc structure */ Desc->dwCaps = This->Caps; Desc->dwFVF = WDesc.FVF; Desc->dwNumVertices = WDesc.Size / get_flexible_vertex_size(WDesc.FVF); LeaveCriticalSection(&ddraw_cs); return D3D_OK; }
/***************************************************************************** * IDirect3DVertexBuffer7::Lock * * Locks the vertex buffer and returns a pointer to the vertex data * Locking vertex buffers is similar to locking surfaces, because Windows * uses surfaces to store vertex data internally (According to the DX sdk) * * Params: * Flags: Locking flags. Relevant here are DDLOCK_READONLY, DDLOCK_WRITEONLY, * DDLOCK_DISCARDCONTENTS and DDLOCK_NOOVERWRITE. * Data: Returns a pointer to the vertex data * Size: Returns the size of the buffer if not NULL * * Returns: * D3D_OK on success * DDERR_INVALIDPARAMS if Data is NULL * D3DERR_VERTEXBUFFEROPTIMIZED if called on an optimized buffer(WineD3D) * *****************************************************************************/ static HRESULT WINAPI IDirect3DVertexBufferImpl_Lock(IDirect3DVertexBuffer7 *iface, DWORD Flags, void **Data, DWORD *Size) { ICOM_THIS_FROM(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer7, iface); WINED3DVERTEXBUFFER_DESC Desc; HRESULT hr; TRACE("(%p)->(%08x,%p,%p)\n", This, Flags, Data, Size); EnterCriticalSection(&ddraw_cs); if(Size) { /* Get the size, for returning it, and for locking */ hr = IWineD3DVertexBuffer_GetDesc(This->wineD3DVertexBuffer, &Desc); if(hr != D3D_OK) { ERR("(%p) IWineD3DVertexBuffer::GetDesc failed with hr=%08x\n", This, hr); LeaveCriticalSection(&ddraw_cs); return hr; } *Size = Desc.Size; } hr = IWineD3DVertexBuffer_Lock(This->wineD3DVertexBuffer, 0 /* OffsetToLock */, 0 /* SizeToLock, 0 == Full lock */, (BYTE **) Data, Flags); LeaveCriticalSection(&ddraw_cs); return hr; }
static HRESULT WINAPI IDirect3DVertexBuffer9Impl_GetDesc(LPDIRECT3DVERTEXBUFFER9 iface, D3DVERTEXBUFFER_DESC* pDesc) { IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface; TRACE("(%p) Relay\n", This); return IWineD3DVertexBuffer_GetDesc(This->wineD3DVertexBuffer, (WINED3DVERTEXBUFFER_DESC *) pDesc); }
/***************************************************************************** * IDirect3DVertexBuffer7::ProcessVertices * * Processes untransformed Vertices into a transformed or optimized vertex * buffer. It can also perform other operations, such as lighting or clipping * * Params * VertexOp: Operation(s) to perform: D3DVOP_CLIP, _EXTENTS, _LIGHT, _TRANSFORM * DestIndex: Index in the destination buffer(This), where the vertices are * placed * Count: Number of Vertices in the Source buffer to process * SrcBuffer: Source vertex buffer * SrcIndex: Index of the first vertex in the src buffer to process * D3DDevice: Device to use for transformation * Flags: 0 for default, D3DPV_DONOTCOPYDATA to prevent copying * unchaned vertices * * Returns: * D3D_OK on success * DDERR_INVALIDPARAMS If D3DVOP_TRANSFORM wasn't passed * *****************************************************************************/ static HRESULT WINAPI IDirect3DVertexBufferImpl_ProcessVertices(IDirect3DVertexBuffer7 *iface, DWORD VertexOp, DWORD DestIndex, DWORD Count, IDirect3DVertexBuffer7 *SrcBuffer, DWORD SrcIndex, IDirect3DDevice7 *D3DDevice, DWORD Flags) { ICOM_THIS_FROM(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer7, iface); IDirect3DVertexBufferImpl *Src = ICOM_OBJECT(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer7, SrcBuffer); IDirect3DDeviceImpl *D3D = ICOM_OBJECT(IDirect3DDeviceImpl, IDirect3DDevice7, D3DDevice); BOOL oldClip, doClip; HRESULT hr; WINED3DVERTEXBUFFER_DESC Desc; TRACE("(%p)->(%08x,%d,%d,%p,%d,%p,%08x)\n", This, VertexOp, DestIndex, Count, Src, SrcIndex, D3D, Flags); /* Vertex operations: * D3DVOP_CLIP: Clips vertices outside the viewing frustrum. Needs clipping information * in the vertex buffer (Buffer may not be created with D3DVBCAPS_DONOTCLIP) * D3DVOP_EXTENTS: Causes the screen extents to be updated when rendering the vertices * D3DVOP_LIGHT: Lights the vertices * D3DVOP_TRANSFORM: Transform the vertices. This flag is necessary * * WineD3D only transforms and clips the vertices by now, so EXTENTS and LIGHT * are not implemented. Clipping is disabled ATM, because of unsure conditions. */ if( !(VertexOp & D3DVOP_TRANSFORM) ) return DDERR_INVALIDPARAMS; EnterCriticalSection(&ddraw_cs); /* WineD3D doesn't know d3d7 vertex operation, it uses * render states instead. Set the render states according to * the vertex ops */ doClip = VertexOp & D3DVOP_CLIP ? TRUE : FALSE; IWineD3DDevice_GetRenderState(D3D->wineD3DDevice, WINED3DRS_CLIPPING, (DWORD *) &oldClip); if(doClip != oldClip) { IWineD3DDevice_SetRenderState(D3D->wineD3DDevice, WINED3DRS_CLIPPING, doClip); } IWineD3DVertexBuffer_GetDesc(Src->wineD3DVertexBuffer, &Desc); IWineD3DDevice_SetStreamSource(D3D->wineD3DDevice, 0, /* Stream No */ Src->wineD3DVertexBuffer, 0, /* Offset */ get_flexible_vertex_size(Desc.FVF)); IWineD3DDevice_SetVertexDeclaration(D3D->wineD3DDevice, Src->wineD3DVertexDeclaration); hr = IWineD3DDevice_ProcessVertices(D3D->wineD3DDevice, SrcIndex, DestIndex, Count, This->wineD3DVertexBuffer, NULL /* Output vdecl */, Flags); /* Restore the states if needed */ if(doClip != oldClip) IWineD3DDevice_SetRenderState(D3D->wineD3DDevice, WINED3DRS_CLIPPING, oldClip); LeaveCriticalSection(&ddraw_cs); return hr; }