Commit 3b0b4308 authored by Oliver Stieber's avatar Oliver Stieber Committed by Alexandre Julliard

Added support for vertex declarations to wined3d, it's the last patch

to give wined3d basic functionality.
parent 8a6799d4
......@@ -22,7 +22,7 @@
#include "config.h"
#include "d3d9_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
/* IDirect3DVertexDeclaration9 IUnknown parts follow: */
HRESULT WINAPI IDirect3DVertexDeclaration9Impl_QueryInterface(LPDIRECT3DVERTEXDECLARATION9 iface, REFIID riid, LPVOID* ppobj) {
......@@ -30,7 +30,7 @@ HRESULT WINAPI IDirect3DVertexDeclaration9Impl_QueryInterface(LPDIRECT3DVERTEXDE
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IDirect3DVertexDeclaration9)) {
IDirect3DVertexDeclaration9Impl_AddRef(iface);
IUnknown_AddRef(iface);
*ppobj = This;
return D3D_OK;
}
......@@ -65,23 +65,36 @@ ULONG WINAPI IDirect3DVertexDeclaration9Impl_Release(LPDIRECT3DVERTEXDECLARATION
HRESULT WINAPI IDirect3DVertexDeclaration9Impl_GetDevice(LPDIRECT3DVERTEXDECLARATION9 iface, IDirect3DDevice9** ppDevice) {
IDirect3DVertexDeclaration9Impl *This = (IDirect3DVertexDeclaration9Impl *)iface;
IWineD3DDevice *myDevice = NULL;
IWineD3DVertexDeclaration_GetDevice(This->wineD3DVertexDeclaration, &myDevice);
IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
IWineD3DDevice_Release(myDevice);
return D3D_OK;
HRESULT hr = D3D_OK;
TRACE("(%p) : Relay\n", iface);
hr = IWineD3DVertexDeclaration_GetDevice(This->wineD3DVertexDeclaration, &myDevice);
if (hr == D3D_OK && myDevice != NULL) {
hr = IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
IWineD3DDevice_Release(myDevice);
}
return hr;
}
HRESULT WINAPI IDirect3DVertexDeclaration9Impl_GetDeclaration(LPDIRECT3DVERTEXDECLARATION9 iface, D3DVERTEXELEMENT9* pDecl, UINT* pNumElements) {
IDirect3DVertexDeclaration9Impl *This = (IDirect3DVertexDeclaration9Impl *)iface;
return IWineD3DVertexDeclaration_GetDeclaration(This->wineD3DVertexDeclaration, 9, pDecl, (DWORD*) pNumElements);
}
DWORD NumElements;
HRESULT hr;
TRACE("(%p) : Relay\n", iface);
hr = IWineD3DVertexDeclaration_GetDeclaration(This->wineD3DVertexDeclaration, pDecl, &NumElements);
*pNumElements = NumElements;
return hr;
}
const IDirect3DVertexDeclaration9Vtbl Direct3DVertexDeclaration9_Vtbl =
{
/* IUnknown */
IDirect3DVertexDeclaration9Impl_QueryInterface,
IDirect3DVertexDeclaration9Impl_AddRef,
IDirect3DVertexDeclaration9Impl_Release,
/* IDirect3DVertexDeclaration9 */
IDirect3DVertexDeclaration9Impl_GetDevice,
IDirect3DVertexDeclaration9Impl_GetDeclaration
};
......@@ -93,7 +106,8 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexDeclaration(LPDIRECT3DDEVICE9
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
IDirect3DVertexDeclaration9Impl *object = NULL;
HRESULT hr = D3D_OK;
TRACE("(%p) : Relay\n", iface);
if (NULL == ppDecl) {
return D3DERR_INVALIDCALL;
}
......@@ -123,30 +137,34 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexDeclaration(LPDIRECT3DDEVICE9
HRESULT WINAPI IDirect3DDevice9Impl_SetVertexDeclaration(LPDIRECT3DDEVICE9 iface, IDirect3DVertexDeclaration9* pDecl) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
IDirect3DVertexDeclaration9Impl *pDeclImpl = (IDirect3DVertexDeclaration9Impl *)pDecl;
HRESULT hr = S_OK;
/* TODO: implement stateblocks */
FIXME("Disabled\n");
return D3DERR_INVALIDCALL;
if (NULL != pDecl) {
hr = IWineD3DDevice_SetVertexDeclaration(This->WineD3DDevice, pDeclImpl->wineD3DVertexDeclaration);
}
HRESULT hr = D3D_OK;
TRACE("(%p) : Relay\n", iface);
hr = IWineD3DDevice_SetVertexDeclaration(This->WineD3DDevice, pDeclImpl == NULL ? NULL : pDeclImpl->wineD3DVertexDeclaration);
return hr;
}
HRESULT WINAPI IDirect3DDevice9Impl_GetVertexDeclaration(LPDIRECT3DDEVICE9 iface, IDirect3DVertexDeclaration9** ppDecl) {
IDirect3DDevice9Impl* This = (IDirect3DDevice9Impl*) iface;
IWineD3DVertexDeclaration* pTest = NULL;
HRESULT hr = S_OK;
FIXME("Disabled\n");
return D3DERR_INVALIDCALL;
HRESULT hr = D3D_OK;
TRACE("(%p) : Relay+\n", iface);
if (NULL == ppDecl) {
return D3DERR_INVALIDCALL;
}
*ppDecl = NULL;
hr = IWineD3DDevice_GetVertexDeclaration(This->WineD3DDevice, &pTest);
if (SUCCEEDED(hr)) {
*ppDecl = NULL;
if (hr == D3D_OK && NULL != pTest) {
IWineD3DResource_GetParent(pTest, (IUnknown **)ppDecl);
IWineD3DResource_Release(pTest);
} else {
*ppDecl = NULL;
}
TRACE("(%p) : returning %p\n", This, *ppDecl);
return hr;
}
......@@ -1342,62 +1342,19 @@ HRESULT WINAPI IWineD3DDeviceImpl_Reset(IWineD3DDevice* iface, WINED3DPRESENT_PA
/*****
* Vertex Declaration
*****/
/* TODO: Get ridd of thease and put the functions in the IWineD3DVertexDeclaration interface */
#if 1
extern HRESULT IWineD3DVertexDeclarationImpl_ParseDeclaration8(IWineD3DDeviceImpl * This, const DWORD* pDecl, IWineD3DVertexDeclarationImpl * object);
extern HRESULT IWineD3DVertexDeclarationImpl_ParseDeclaration9(IWineD3DDeviceImpl * This, const D3DVERTEXELEMENT9* pDecl, IWineD3DVertexDeclarationImpl * object);
HRESULT WINAPI IWineD3DDeviceImpl_CreateVertexDeclaration(IWineD3DDevice* iface, CONST VOID* pDeclaration, IWineD3DVertexDeclaration** ppVertexDeclaration, IUnknown *parent) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
IWineD3DVertexDeclarationImpl *object = NULL;
HRESULT hr = D3D_OK;
TRACE("(%p) : directXVersion=%u, pFunction=%p, ppDecl=%p\n", This, ((IWineD3DImpl *)This->wineD3D)->dxVersion, pDeclaration, ppVertexDeclaration);
TRACE("(%p) : directXVersion=%u, pFunction=%p, ppDecl=%p\n", This, ((IWineD3DImpl *)This->wineD3D)->dxVersion, pDeclaration, ppVertexDeclaration);
D3DCREATEOBJECTINSTANCE(object, VertexDeclaration)
object->allFVF = 0;
if (8 == ((IWineD3DImpl *)This->wineD3D)->dxVersion) {
/** @TODO */
hr = IWineD3DVertexDeclarationImpl_ParseDeclaration8(This, (const DWORD*) pDeclaration, object);
} else {
hr = IWineD3DVertexDeclarationImpl_ParseDeclaration9(This, (const D3DVERTEXELEMENT9*) pDeclaration, object);
}
hr = IWineD3DVertexDeclaration_SetDeclaration((IWineD3DVertexDeclaration *)object, (void *)pDeclaration);
return hr;
}
#else
HRESULT WINAPI IWineD3DDeviceImpl_CreateVertexDeclaration8(IWineD3DDevice* iface, const DWORD* pDeclaration, IWineD3DVertexDeclaration** ppVertexDeclaration, IUnknown *parent){
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
IWineD3DVertexDeclarationImpl *object = NULL; /* NOTE: impl allowed, this is a create */
HRESULT hr = D3D_OK;
/* TODO: replace impl usage with a call to Version*/
TRACE("(%p) : directXVersion=%u, pFunction=%p, ppDecl=%p\n", This, ((IWineD3DImpl *)This->wineD3D)->dxVersion, pDeclaration, ppVertexDeclaration);
D3DCREATEOBJECTINSTANCE(object, VertexDeclaration)
object->allFVF = 0;
/* TODO: get ridd of the impl usage, we should only be using interfaces */
hr = IWineD3DVertexDeclarationImpl_ParseDeclaration8(This, pDeclaration, object);
return hr;
}
HRESULT WINAPI IWineD3DDeviceImpl_CreateVertexDeclaration9(IWineD3DDevice* iface, const D3DVERTEXELEMENT9* pDeclaration, IWineD3DVertexDeclaration** ppVertexDeclaration, IUnknown *parent){
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
IWineD3DVertexDeclarationImpl *object = NULL; /* NOTE: impl allowed, this is a create */
HRESULT hr = D3D_OK;
/* TODO: replace impl usage with a call to Version*/
TRACE("(%p) : directXVersion=%u, pFunction=%p, ppDecl=%p\n", This, ((IWineD3DImpl *)This->wineD3D)->dxVersion, pDeclaration, ppVertexDeclaration);
D3DCREATEOBJECTINSTANCE(object, VertexDeclaration)
object->allFVF = 0;
/* TODO: get ridd of the impl usage, we should only be using interfaces */
hr = IWineD3DVertexDeclarationImpl_ParseDeclaration9(This, pDeclaration, object);
return hr;
}
#endif
/* http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/directx9_c/directx/graphics/programmingguide/programmable/vertexshaders/vscreate.asp */
HRESULT WINAPI IWineD3DDeviceImpl_CreateVertexShader(IWineD3DDevice* iface, CONST DWORD* pFunction, IWineD3DVertexShader** ppVertexShader, IUnknown *parent){
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
......@@ -1443,10 +1400,16 @@ HRESULT WINAPI IWineD3DDeviceImpl_SetFVF(IWineD3DDevice *iface, DWORD fvf) {
This->updateStateBlock->set.fvf = TRUE;
TRACE("(%p) : FVF Shader FVF set to %lx\n", This, fvf);
/* clear down the vertex declaration
NOTE: Axis and Allies doesn't work properly otherwise
(may be a stateblock problem though!)
*/
/* No difference if recording or not */
return D3D_OK;
return IWineD3DDevice_SetVertexDeclaration(iface, NULL);
}
HRESULT WINAPI IWineD3DDeviceImpl_GetFVF(IWineD3DDevice *iface, DWORD *pfvf) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
TRACE("(%p) : GetFVF returning %lx\n", This, This->stateBlock->fvf);
......@@ -3554,10 +3517,11 @@ HRESULT WINAPI IWineD3DDeviceImpl_GetScissorRect(IWineD3DDevice *iface, RECT* pR
}
HRESULT WINAPI IWineD3DDeviceImpl_SetVertexDeclaration(IWineD3DDevice* iface, IWineD3DVertexDeclaration* pDecl) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
TRACE("(%p) : pDecl=%p\n", This, pDecl);
/* TODO: what about recording stateblocks? */
IWineD3DVertexDeclaration_AddRef(pDecl);
if (NULL != This->updateStateBlock->vertexDecl) {
IWineD3DVertexDeclaration_Release(This->updateStateBlock->vertexDecl);
......
......@@ -1083,12 +1083,14 @@ DECLARE_INTERFACE_(IWineD3DVolume,IWineD3DResource)
DECLARE_INTERFACE_(IWineD3DVertexDeclaration,IUnknown)
{
/*** IUnknown methods ***/
STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void **ppvObject) PURE;
STDMETHOD_(ULONG,AddRef)(THIS) PURE;
STDMETHOD_(ULONG,Release)(THIS) PURE;
/*** IWineD3DVertexDeclaration methods ***/
STDMETHOD(GetDevice)(THIS_ IWineD3DDevice ** ppDevice) PURE;
STDMETHOD(GetDeclaration)(THIS_ UINT iDeclVersion, VOID*, DWORD* pSize) PURE;
STDMETHOD(GetParent)(THIS_ IUnknown **pParent) PURE;
STDMETHOD(GetDevice)(THIS_ IWineD3DDevice **ppDevice) PURE;
STDMETHOD(GetDeclaration)(THIS_ VOID *pDecl, DWORD *pSize) PURE;
STDMETHOD(SetDeclaration)(THIS_ VOID *pDecl) PURE;
};
#undef INTERFACE
......@@ -1098,8 +1100,10 @@ DECLARE_INTERFACE_(IWineD3DVertexDeclaration,IUnknown)
#define IWineD3DVertexDeclaration_AddRef(p) (p)->lpVtbl->AddRef(p)
#define IWineD3DVertexDeclaration_Release(p) (p)->lpVtbl->Release(p)
/*** IWineD3DVertexDeclaration methods ***/
#define IWineD3DVertexDeclaration_GetParent(p,a) (p)->lpVtbl->GetParent(p,a)
#define IWineD3DVertexDeclaration_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a)
#define IWineD3DVertexDeclaration_GetDeclaration(p,a,b,c) (p)->lpVtbl->GetDeclaration(p,a,b,c)
#define IWineD3DVertexDeclaration_GetDeclaration(p,a,b) (p)->lpVtbl->GetDeclaration(p,a,b)
#define IWineD3DVertexDeclaration_SetDeclaration(p,b) (p)->lpVtbl->SetDeclaration(p,b)
#endif
/*****************************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment