diff --git a/dlls/ddraw/d3d_private.h b/dlls/ddraw/d3d_private.h index 37b10b2bdbd..284ce9215af 100644 --- a/dlls/ddraw/d3d_private.h +++ b/dlls/ddraw/d3d_private.h @@ -1,5 +1,6 @@ /* Direct3D private include file - * Copyright (c) 1998 Lionel ULMER + * Copyright (c) 1998-2004 Lionel ULMER + * Copyright (c) 2002-2004 Christian Costa * * This file contains all the structure that are not exported * through d3d.h and all common macros. @@ -195,6 +196,7 @@ struct IDirect3DDeviceImpl ICOM_VFIELD_MULTI(IDirect3DDevice2); ICOM_VFIELD_MULTI(IDirect3DDevice); DWORD ref; + /* IDirect3DDevice fields */ IDirectDrawImpl *d3d; IDirectDrawSurfaceImpl *surface; @@ -216,6 +218,9 @@ struct IDirect3DDeviceImpl /* Current material used in D3D7 mode */ D3DMATERIAL7 current_material; + /* Light state */ + DWORD material; + /* Light parameters */ DWORD active_lights, set_lights; D3DLIGHT7 light_parameters[MAX_LIGHTS]; diff --git a/dlls/ddraw/d3ddevice/main.c b/dlls/ddraw/d3ddevice/main.c index 4de426e501b..f903c524c78 100644 --- a/dlls/ddraw/d3ddevice/main.c +++ b/dlls/ddraw/d3ddevice/main.c @@ -1,5 +1,6 @@ /* Direct3D Device - * Copyright (c) 1998 Lionel ULMER + * Copyright (c) 1998-2004 Lionel ULMER + * Copyright (c) 2002-2004 Christian Costa * * This file contains all the common stuff for D3D devices. * diff --git a/dlls/ddraw/d3ddevice/mesa.c b/dlls/ddraw/d3ddevice/mesa.c index 4b21b2ff921..602033e953b 100644 --- a/dlls/ddraw/d3ddevice/mesa.c +++ b/dlls/ddraw/d3ddevice/mesa.c @@ -1,5 +1,6 @@ /* Direct3D Device - * Copyright (c) 1998 Lionel ULMER + * Copyright (c) 1998-2004 Lionel ULMER + * Copyright (c) 2002-2004 Christian Costa * * This file contains the MESA implementation of all the D3D devices that * Wine supports. @@ -723,6 +724,57 @@ GL_IDirect3DDeviceImpl_7_3T_2T_GetRenderState(LPDIRECT3DDEVICE7 iface, return DD_OK; } +HRESULT WINAPI +GL_IDirect3DDeviceImpl_3_2T_GetLightState(LPDIRECT3DDEVICE3 iface, + D3DLIGHTSTATETYPE dwLightStateType, + LPDWORD lpdwLightState) +{ + ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface); + + TRACE("(%p/%p)->(%08x,%p)\n", This, iface, dwLightStateType, lpdwLightState); + + if (!dwLightStateType && (dwLightStateType > D3DLIGHTSTATE_COLORVERTEX)) { + TRACE("Unexpected Light State Type\n"); + return DDERR_INVALIDPARAMS; + } + + if (dwLightStateType == D3DLIGHTSTATE_MATERIAL /* 1 */) { + *lpdwLightState = This->material; + } else if (dwLightStateType == D3DLIGHTSTATE_COLORMODEL /* 3 */) { + *lpdwLightState = D3DCOLOR_RGB; + } else { + D3DRENDERSTATETYPE rs; + switch (dwLightStateType) { + case D3DLIGHTSTATE_AMBIENT: /* 2 */ + rs = D3DRENDERSTATE_AMBIENT; + break; + case D3DLIGHTSTATE_FOGMODE: /* 4 */ + rs = D3DRENDERSTATE_FOGVERTEXMODE; + break; + case D3DLIGHTSTATE_FOGSTART: /* 5 */ + rs = D3DRENDERSTATE_FOGSTART; + break; + case D3DLIGHTSTATE_FOGEND: /* 6 */ + rs = D3DRENDERSTATE_FOGEND; + break; + case D3DLIGHTSTATE_FOGDENSITY: /* 7 */ + rs = D3DRENDERSTATE_FOGDENSITY; + break; + case D3DLIGHTSTATE_COLORVERTEX: /* 8 */ + rs = D3DRENDERSTATE_COLORVERTEX; + break; + default: + ERR("Unknown D3DLIGHTSTATETYPE %d.\n", dwLightStateType); + return DDERR_INVALIDPARAMS; + } + + IDirect3DDevice7_GetRenderState(ICOM_INTERFACE(This, IDirect3DDevice7), + rs,lpdwLightState); + } + + return DD_OK; +} + HRESULT WINAPI GL_IDirect3DDeviceImpl_3_2T_SetLightState(LPDIRECT3DDEVICE3 iface, D3DLIGHTSTATETYPE dwLightStateType, @@ -746,6 +798,7 @@ GL_IDirect3DDeviceImpl_3_2T_SetLightState(LPDIRECT3DDEVICE3 iface, } else { FIXME(" D3DLIGHTSTATE_MATERIAL called with NULL material !!!\n"); } + This->material = dwLightState; } else if (dwLightStateType == D3DLIGHTSTATE_COLORMODEL /* 3 */) { switch (dwLightState) { case D3DCOLOR_MONO: @@ -1119,7 +1172,7 @@ inline static void handle_xyz(D3DVALUE *coords) { glVertex3fv(coords); } inline static void handle_xyzrhw(D3DVALUE *coords) { - if (coords[3] < 1e-8) + if ((coords[3] < 1e-8) && (coords[3] > -1e-8)) glVertex3fv(coords); else { GLfloat w = 1.0 / coords[3]; @@ -2608,7 +2661,7 @@ ICOM_VTABLE(IDirect3DDevice3) VTABLE_IDirect3DDevice3 = XCAST(End) Main_IDirect3DDeviceImpl_3_2T_End, XCAST(GetRenderState) Thunk_IDirect3DDeviceImpl_3_GetRenderState, XCAST(SetRenderState) Thunk_IDirect3DDeviceImpl_3_SetRenderState, - XCAST(GetLightState) Main_IDirect3DDeviceImpl_3_2T_GetLightState, + XCAST(GetLightState) GL_IDirect3DDeviceImpl_3_2T_GetLightState, XCAST(SetLightState) GL_IDirect3DDeviceImpl_3_2T_SetLightState, XCAST(SetTransform) Thunk_IDirect3DDeviceImpl_3_SetTransform, XCAST(GetTransform) Thunk_IDirect3DDeviceImpl_3_GetTransform, diff --git a/dlls/ddraw/d3dexecutebuffer.c b/dlls/ddraw/d3dexecutebuffer.c index bed7c234be9..c3d87899256 100644 --- a/dlls/ddraw/d3dexecutebuffer.c +++ b/dlls/ddraw/d3dexecutebuffer.c @@ -331,8 +331,8 @@ static void execute(IDirect3DExecuteBufferImpl *This, dump_D3DMATRIX(lpDevice->proj_mat); TRACE(" View Matrix : (%p)\n", lpDevice->view_mat); dump_D3DMATRIX(lpDevice->view_mat); - TRACE(" World Matrix : (%p)\n", &mat); - dump_D3DMATRIX(&mat); + TRACE(" World Matrix : (%p)\n", lpDevice->world_mat); + dump_D3DMATRIX(lpDevice->world_mat); } multiply_matrix(&mat,lpDevice->view_mat,lpDevice->world_mat);