📄 device.c
字号:
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
HRESULT hr;
TRACE("(%p) Relay %d %p\n" , This, Stage, pTexture);
EnterCriticalSection(&d3d8_cs);
hr = IWineD3DDevice_SetTexture(This->WineD3DDevice, Stage,
pTexture==NULL ? NULL : ((IDirect3DBaseTexture8Impl *)pTexture)->wineD3DBaseTexture);
LeaveCriticalSection(&d3d8_cs);
return hr;
}
static HRESULT WINAPI IDirect3DDevice8Impl_GetTextureStageState(LPDIRECT3DDEVICE8 iface, DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD* pValue) {
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
HRESULT hr;
TRACE("(%p) Relay\n" , This);
switch(Type) {
case D3DTSS_ADDRESSU:
Type = WINED3DSAMP_ADDRESSU;
break;
case D3DTSS_ADDRESSV:
Type = WINED3DSAMP_ADDRESSV;
break;
case D3DTSS_ADDRESSW:
Type = WINED3DSAMP_ADDRESSW;
break;
case D3DTSS_BORDERCOLOR:
Type = WINED3DSAMP_BORDERCOLOR;
break;
case D3DTSS_MAGFILTER:
Type = WINED3DSAMP_MAGFILTER;
break;
case D3DTSS_MAXANISOTROPY:
Type = WINED3DSAMP_MAXANISOTROPY;
break;
case D3DTSS_MAXMIPLEVEL:
Type = WINED3DSAMP_MAXMIPLEVEL;
break;
case D3DTSS_MINFILTER:
Type = WINED3DSAMP_MINFILTER;
break;
case D3DTSS_MIPFILTER:
Type = WINED3DSAMP_MIPFILTER;
break;
case D3DTSS_MIPMAPLODBIAS:
Type = WINED3DSAMP_MIPMAPLODBIAS;
break;
default:
EnterCriticalSection(&d3d8_cs);
hr = IWineD3DDevice_GetTextureStageState(This->WineD3DDevice, Stage, Type, pValue);
LeaveCriticalSection(&d3d8_cs);
return hr;
}
EnterCriticalSection(&d3d8_cs);
hr = IWineD3DDevice_GetSamplerState(This->WineD3DDevice, Stage, Type, pValue);
LeaveCriticalSection(&d3d8_cs);
return hr;
}
static HRESULT WINAPI IDirect3DDevice8Impl_SetTextureStageState(LPDIRECT3DDEVICE8 iface, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value) {
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
HRESULT hr;
TRACE("(%p) Relay\n" , This);
switch(Type) {
case D3DTSS_ADDRESSU:
Type = WINED3DSAMP_ADDRESSU;
break;
case D3DTSS_ADDRESSV:
Type = WINED3DSAMP_ADDRESSV;
break;
case D3DTSS_ADDRESSW:
Type = WINED3DSAMP_ADDRESSW;
break;
case D3DTSS_BORDERCOLOR:
Type = WINED3DSAMP_BORDERCOLOR;
break;
case D3DTSS_MAGFILTER:
Type = WINED3DSAMP_MAGFILTER;
break;
case D3DTSS_MAXANISOTROPY:
Type = WINED3DSAMP_MAXANISOTROPY;
break;
case D3DTSS_MAXMIPLEVEL:
Type = WINED3DSAMP_MAXMIPLEVEL;
break;
case D3DTSS_MINFILTER:
Type = WINED3DSAMP_MINFILTER;
break;
case D3DTSS_MIPFILTER:
Type = WINED3DSAMP_MIPFILTER;
break;
case D3DTSS_MIPMAPLODBIAS:
Type = WINED3DSAMP_MIPMAPLODBIAS;
break;
default:
EnterCriticalSection(&d3d8_cs);
hr = IWineD3DDevice_SetTextureStageState(This->WineD3DDevice, Stage, Type, Value);
LeaveCriticalSection(&d3d8_cs);
return hr;
}
EnterCriticalSection(&d3d8_cs);
hr = IWineD3DDevice_SetSamplerState(This->WineD3DDevice, Stage, Type, Value);
LeaveCriticalSection(&d3d8_cs);
return hr;
}
static HRESULT WINAPI IDirect3DDevice8Impl_ValidateDevice(LPDIRECT3DDEVICE8 iface, DWORD* pNumPasses) {
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
HRESULT hr;
TRACE("(%p) Relay\n" , This);
EnterCriticalSection(&d3d8_cs);
hr = IWineD3DDevice_ValidateDevice(This->WineD3DDevice, pNumPasses);
LeaveCriticalSection(&d3d8_cs);
return hr;
}
static HRESULT WINAPI IDirect3DDevice8Impl_GetInfo(LPDIRECT3DDEVICE8 iface, DWORD DevInfoID, void* pDevInfoStruct, DWORD DevInfoStructSize) {
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
FIXME("(%p) : stub\n", This);
return D3D_OK;
}
static HRESULT WINAPI IDirect3DDevice8Impl_SetPaletteEntries(LPDIRECT3DDEVICE8 iface, UINT PaletteNumber, CONST PALETTEENTRY* pEntries) {
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
HRESULT hr;
TRACE("(%p) Relay\n" , This);
EnterCriticalSection(&d3d8_cs);
hr = IWineD3DDevice_SetPaletteEntries(This->WineD3DDevice, PaletteNumber, pEntries);
LeaveCriticalSection(&d3d8_cs);
return hr;
}
static HRESULT WINAPI IDirect3DDevice8Impl_GetPaletteEntries(LPDIRECT3DDEVICE8 iface, UINT PaletteNumber, PALETTEENTRY* pEntries) {
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
HRESULT hr;
TRACE("(%p) Relay\n" , This);
EnterCriticalSection(&d3d8_cs);
hr = IWineD3DDevice_GetPaletteEntries(This->WineD3DDevice, PaletteNumber, pEntries);
LeaveCriticalSection(&d3d8_cs);
return hr;
}
static HRESULT WINAPI IDirect3DDevice8Impl_SetCurrentTexturePalette(LPDIRECT3DDEVICE8 iface, UINT PaletteNumber) {
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
HRESULT hr;
TRACE("(%p) Relay\n" , This);
EnterCriticalSection(&d3d8_cs);
hr = IWineD3DDevice_SetCurrentTexturePalette(This->WineD3DDevice, PaletteNumber);
LeaveCriticalSection(&d3d8_cs);
return hr;
}
static HRESULT WINAPI IDirect3DDevice8Impl_GetCurrentTexturePalette(LPDIRECT3DDEVICE8 iface, UINT *PaletteNumber) {
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
HRESULT hr;
TRACE("(%p) Relay\n" , This);
EnterCriticalSection(&d3d8_cs);
hr = IWineD3DDevice_GetCurrentTexturePalette(This->WineD3DDevice, PaletteNumber);
LeaveCriticalSection(&d3d8_cs);
return hr;
}
static HRESULT WINAPI IDirect3DDevice8Impl_DrawPrimitive(LPDIRECT3DDEVICE8 iface, D3DPRIMITIVETYPE PrimitiveType, UINT StartVertex, UINT PrimitiveCount) {
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
HRESULT hr;
TRACE("(%p) Relay\n" , This);
EnterCriticalSection(&d3d8_cs);
hr = IWineD3DDevice_DrawPrimitive(This->WineD3DDevice, PrimitiveType, StartVertex, PrimitiveCount);
LeaveCriticalSection(&d3d8_cs);
return hr;
}
static HRESULT WINAPI IDirect3DDevice8Impl_DrawIndexedPrimitive(LPDIRECT3DDEVICE8 iface, D3DPRIMITIVETYPE PrimitiveType,
UINT MinVertexIndex,UINT NumVertices,UINT startIndex,UINT primCount) {
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
HRESULT hr;
TRACE("(%p) Relay\n" , This);
EnterCriticalSection(&d3d8_cs);
hr = IWineD3DDevice_DrawIndexedPrimitive(This->WineD3DDevice, PrimitiveType, MinVertexIndex, NumVertices, startIndex, primCount);
LeaveCriticalSection(&d3d8_cs);
return hr;
}
static HRESULT WINAPI IDirect3DDevice8Impl_DrawPrimitiveUP(LPDIRECT3DDEVICE8 iface, D3DPRIMITIVETYPE PrimitiveType,UINT PrimitiveCount,CONST void* pVertexStreamZeroData,UINT VertexStreamZeroStride) {
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
HRESULT hr;
TRACE("(%p) Relay\n" , This);
EnterCriticalSection(&d3d8_cs);
hr = IWineD3DDevice_DrawPrimitiveUP(This->WineD3DDevice, PrimitiveType, PrimitiveCount, pVertexStreamZeroData, VertexStreamZeroStride);
LeaveCriticalSection(&d3d8_cs);
return hr;
}
static HRESULT WINAPI IDirect3DDevice8Impl_DrawIndexedPrimitiveUP(LPDIRECT3DDEVICE8 iface, D3DPRIMITIVETYPE PrimitiveType,UINT MinVertexIndex,
UINT NumVertexIndices,UINT PrimitiveCount,CONST void* pIndexData,
D3DFORMAT IndexDataFormat,CONST void* pVertexStreamZeroData,
UINT VertexStreamZeroStride) {
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
HRESULT hr;
TRACE("(%p) Relay\n" , This);
EnterCriticalSection(&d3d8_cs);
hr = IWineD3DDevice_DrawIndexedPrimitiveUP(This->WineD3DDevice, PrimitiveType, MinVertexIndex, NumVertexIndices, PrimitiveCount,
pIndexData, IndexDataFormat, pVertexStreamZeroData, VertexStreamZeroStride);
LeaveCriticalSection(&d3d8_cs);
return hr;
}
static HRESULT WINAPI IDirect3DDevice8Impl_ProcessVertices(LPDIRECT3DDEVICE8 iface, UINT SrcStartIndex,UINT DestIndex,UINT VertexCount,IDirect3DVertexBuffer8* pDestBuffer,DWORD Flags) {
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
HRESULT hr;
TRACE("(%p) Relay\n" , This);
EnterCriticalSection(&d3d8_cs);
hr = IWineD3DDevice_ProcessVertices(This->WineD3DDevice,SrcStartIndex, DestIndex, VertexCount, ((IDirect3DVertexBuffer8Impl *)pDestBuffer)->wineD3DVertexBuffer, NULL, Flags);
LeaveCriticalSection(&d3d8_cs);
return hr;
}
static HRESULT WINAPI IDirect3DDevice8Impl_CreateVertexDeclaration(IDirect3DDevice8 *iface, CONST DWORD *declaration, IDirect3DVertexDeclaration8 **decl_ptr) {
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
IDirect3DVertexDeclaration8Impl *object;
WINED3DVERTEXELEMENT *wined3d_elements;
size_t wined3d_element_count;
HRESULT hr = D3D_OK;
TRACE("(%p) : declaration %p\n", This, declaration);
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object) {
ERR("Memory allocation failed\n");
*decl_ptr = NULL;
return D3DERR_OUTOFVIDEOMEMORY;
}
object->ref_count = 1;
object->lpVtbl = &Direct3DVertexDeclaration8_Vtbl;
wined3d_element_count = convert_to_wined3d_declaration(declaration, &object->elements_size, &wined3d_elements);
object->elements = HeapAlloc(GetProcessHeap(), 0, object->elements_size);
if (!object->elements) {
ERR("Memory allocation failed\n");
HeapFree(GetProcessHeap(), 0, wined3d_elements);
HeapFree(GetProcessHeap(), 0, object);
*decl_ptr = NULL;
return D3DERR_OUTOFVIDEOMEMORY;
}
CopyMemory(object->elements, declaration, object->elements_size);
EnterCriticalSection(&d3d8_cs);
hr = IWineD3DDevice_CreateVertexDeclaration(This->WineD3DDevice, &object->wined3d_vertex_declaration,
(IUnknown *)object, wined3d_elements, wined3d_element_count);
LeaveCriticalSection(&d3d8_cs);
HeapFree(GetProcessHeap(), 0, wined3d_elements);
if (FAILED(hr)) {
ERR("(%p) : IWineD3DDevice_CreateVertexDeclaration call failed\n", This);
HeapFree(GetProcessHeap(), 0, object->elements);
HeapFree(GetProcessHeap(), 0, object);
} else {
*decl_ptr = (IDirect3DVertexDeclaration8 *)object;
TRACE("(%p) : Created vertex declaration %p\n", This, object);
}
return hr;
}
static HRESULT WINAPI IDirect3DDevice8Impl_CreateVertexShader(LPDIRECT3DDEVICE8 iface, CONST DWORD* pDeclaration, CONST DWORD* pFunction, DWORD* ppShader, DWORD Usage) {
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
HRESULT hrc = D3D_OK;
IDirect3DVertexShader8Impl *object;
IWineD3DVertexDeclaration *wined3d_vertex_declaration;
/* Setup a stub object for now */
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
TRACE("(%p) : pFunction(%p), ppShader(%p)\n", This, pFunction, ppShader);
if (NULL == object) {
FIXME("Allocation of memory failed\n");
*ppShader = 0;
return D3DERR_OUTOFVIDEOMEMORY;
}
object->ref = 1;
object->lpVtbl = &Direct3DVertexShader8_Vtbl;
EnterCriticalSection(&d3d8_cs);
hrc = IDirect3DDevice8Impl_CreateVertexDeclaration(iface, pDeclaration, &object->vertex_declaration);
if (FAILED(hrc)) {
ERR("(%p) : IDirect3DDeviceImpl_CreateVertexDeclaration call failed\n", This);
LeaveCriticalSection(&d3d8_cs);
HeapFree(GetProcessHeap(), 0, object);
*ppShader = 0;
return D3DERR_INVALIDCALL;
}
wined3d_vertex_declaration = ((IDirect3DVertexDeclaration8Impl *)object->vertex_declaration)->wined3d_vertex_declaration;
/* Usag
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -