ChangeSet ID: 20987 CVSROOT: /opt/cvs-commit Module name: wine Changes by: julliard@winehq.org 2005/10/31 04:05:15
Modified files: dlls/ddraw : opengl_private.h light.c direct3d_opengl.c
Log message: Christian Costa titan.costa@wanadoo.fr Finish moving d3d[1..3] light code to use d3d7.
Patch: http://cvs.winehq.org/patch.py?id=20987
Old revision New revision Changes Path 1.2 1.3 +2 -9 wine/dlls/ddraw/opengl_private.h 1.2 1.3 +31 -25 wine/dlls/ddraw/light.c 1.2 1.3 +2 -21 wine/dlls/ddraw/direct3d_opengl.c
Index: wine/dlls/ddraw/opengl_private.h diff -u -p wine/dlls/ddraw/opengl_private.h:1.2 wine/dlls/ddraw/opengl_private.h:1.3 --- wine/dlls/ddraw/opengl_private.h 31 Oct 2005 10: 5:15 -0000 +++ /dev/null 31 Oct 2005 10: 5:15 -0000 @@ -48,16 +48,9 @@ typedef enum { /* This structure is used for the 'd3d_private' field of the IDirectDraw structure */ typedef struct IDirect3DGLImpl { - DWORD free_lights; - void (*light_released)(IDirectDrawImpl *, GLenum light_num); + int dummy; /* Empty for the moment */ } IDirect3DGLImpl;
-typedef struct IDirect3DLightGLImpl -{ - struct IDirect3DLightImpl parent; - GLenum light_num; -} IDirect3DLightGLImpl; - /* This structure is used for the 'private' field of the IDirectDrawSurfaceImpl structure */ typedef struct IDirect3DTextureGLImpl { @@ -185,7 +178,7 @@ extern GL_EXTENSIONS_LIST GL_extensions; /* All non-static functions 'exported' by various sub-objects */ extern HRESULT direct3d_create(IDirectDrawImpl *This); extern HRESULT d3dtexture_create(IDirectDrawImpl *d3d, IDirectDrawSurfaceImpl *surf, BOOLEAN at_creation, IDirectDrawSurfaceImpl *main_surf); -extern HRESULT d3dlight_create(IDirect3DLightImpl **obj, IDirectDrawImpl *d3d, GLenum light_num); +extern HRESULT d3dlight_create(IDirect3DLightImpl **obj, IDirectDrawImpl *d3d); extern HRESULT d3dexecutebuffer_create(IDirect3DExecuteBufferImpl **obj, IDirectDrawImpl *d3d, IDirect3DDeviceImpl *d3ddev, LPD3DEXECUTEBUFFERDESC lpDesc); extern HRESULT d3dmaterial_create(IDirect3DMaterialImpl **obj, IDirectDrawImpl *d3d); extern HRESULT d3dviewport_create(IDirect3DViewportImpl **obj, IDirectDrawImpl *d3d); Index: wine/dlls/ddraw/light.c diff -u -p wine/dlls/ddraw/light.c:1.2 wine/dlls/ddraw/light.c:1.3 --- wine/dlls/ddraw/light.c 31 Oct 2005 10: 5:16 -0000 +++ /dev/null 31 Oct 2005 10: 5:16 -0000 @@ -156,54 +156,63 @@ Main_IDirect3DLightImpl_1_GetLight(LPDIR * Light static functions */
-static void update(IDirect3DLightImpl* This) { +static void update(IDirect3DLightImpl* This) +{ IDirect3DDeviceImpl* device; - if (!This->active_viewport||!This->active_viewport->active_device) + + TRACE("(%p)\n", This); + + if (!This->active_viewport || !This->active_viewport->active_device) return; device = This->active_viewport->active_device; - IDirect3DDevice7_SetLight(ICOM_INTERFACE(device,IDirect3DDevice7),This->dwLightIndex,&(This->light7)); + + IDirect3DDevice7_SetLight(ICOM_INTERFACE(device,IDirect3DDevice7), This->dwLightIndex, &(This->light7)); }
-static void activate(IDirect3DLightImpl* This) { - IDirect3DLightGLImpl *glThis = (IDirect3DLightGLImpl *) This; +static void activate(IDirect3DLightImpl* This) +{ + IDirect3DDeviceImpl* device;
TRACE("(%p)\n", This); + + if (!This->active_viewport || !This->active_viewport->active_device) + return; + device = This->active_viewport->active_device;
- ENTER_GL(); update(This); /* If was not active, activate it */ - if ((glThis->parent.light.dwFlags & D3DLIGHT_ACTIVE) == 0) { - glEnable(glThis->light_num); - glThis->parent.light.dwFlags |= D3DLIGHT_ACTIVE; + if ((This->light.dwFlags & D3DLIGHT_ACTIVE) == 0) { + IDirect3DDevice7_LightEnable(ICOM_INTERFACE(device,IDirect3DDevice7), This->dwLightIndex, TRUE); + This->light.dwFlags |= D3DLIGHT_ACTIVE; } - LEAVE_GL(); }
-static void desactivate(IDirect3DLightImpl* This) { - IDirect3DLightGLImpl *glThis = (IDirect3DLightGLImpl *) This; - +static void desactivate(IDirect3DLightImpl* This) +{ + IDirect3DDeviceImpl* device; + TRACE("(%p)\n", This); + + if (!This->active_viewport || !This->active_viewport->active_device) + return; + device = This->active_viewport->active_device;
- ENTER_GL(); /* If was not active, activate it */ - if ((glThis->parent.light.dwFlags & D3DLIGHT_ACTIVE) != 0) { - glDisable(glThis->light_num); - glThis->parent.light.dwFlags &= ~D3DLIGHT_ACTIVE; + if ((This->light.dwFlags & D3DLIGHT_ACTIVE) != 0) { + IDirect3DDevice7_LightEnable(ICOM_INTERFACE(device,IDirect3DDevice7), This->dwLightIndex, FALSE); + This->light.dwFlags &= ~D3DLIGHT_ACTIVE; } - LEAVE_GL(); }
ULONG WINAPI GL_IDirect3DLightImpl_1_Release(LPDIRECT3DLIGHT iface) { ICOM_THIS_FROM(IDirect3DLightImpl, IDirect3DLight, iface); - IDirect3DLightGLImpl *glThis = (IDirect3DLightGLImpl *) This; ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p/%p)->() decrementing from %lu.\n", This, iface, ref + 1);
if (!ref) { - ((IDirect3DGLImpl *) This->d3d->d3d_private)->light_released(This->d3d, glThis->light_num); HeapFree(GetProcessHeap(), 0, This); return 0; } @@ -233,14 +242,12 @@ static const IDirect3DLightVtbl VTABLE_I
-HRESULT d3dlight_create(IDirect3DLightImpl **obj, IDirectDrawImpl *d3d, GLenum light_num) +HRESULT d3dlight_create(IDirect3DLightImpl **obj, IDirectDrawImpl *d3d) { IDirect3DLightImpl *object; - IDirect3DLightGLImpl *gl_object;
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DLightGLImpl)); + object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DLightImpl)); if (object == NULL) return DDERR_OUTOFMEMORY; - gl_object = (IDirect3DLightGLImpl *) object;
object->ref = 1; object->d3d = d3d; @@ -249,7 +256,6 @@ HRESULT d3dlight_create(IDirect3DLightIm object->desactivate = desactivate; object->update = update; object->active_viewport = NULL; - gl_object->light_num = light_num;
ICOM_INIT_INTERFACE(object, IDirect3DLight, VTABLE_IDirect3DLight);
Index: wine/dlls/ddraw/direct3d_opengl.c diff -u -p wine/dlls/ddraw/direct3d_opengl.c:1.2 wine/dlls/ddraw/direct3d_opengl.c:1.3 --- wine/dlls/ddraw/direct3d_opengl.c 31 Oct 2005 10: 5:16 -0000 +++ /dev/null 31 Oct 2005 10: 5:16 -0000 @@ -97,22 +97,12 @@ GL_IDirect3DImpl_3_2T_1T_CreateLight(LPD IUnknown* pUnkOuter) { ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D3, iface); - IDirect3DGLImpl *glThis = (IDirect3DGLImpl *) This->d3d_private; - int fl; IDirect3DLightImpl *d3dlimpl; HRESULT ret_value;
TRACE("(%p/%p)->(%p,%p)\n", This, iface, lplpDirect3DLight, pUnkOuter); - for (fl = 0; fl < MAX_LIGHTS; fl++) { - if ((glThis->free_lights & (0x01 << fl)) != 0) { - glThis->free_lights &= ~(0x01 << fl); - break; - } - } - if (fl == MAX_LIGHTS) { - return DDERR_INVALIDPARAMS; /* No way to say 'max lights reached' ... */ - } - ret_value = d3dlight_create(&d3dlimpl, This, GL_LIGHT0 + fl); + + ret_value = d3dlight_create(&d3dlimpl, This); *lplpDirect3DLight = ICOM_INTERFACE(d3dlimpl, IDirect3DLight);
return ret_value; @@ -306,12 +296,6 @@ GL_IDirect3DImpl_7_3T_CreateVertexBuffer return res; }
-static void light_released(IDirectDrawImpl *This, GLenum light_num) -{ - IDirect3DGLImpl *glThis = (IDirect3DGLImpl *) This->d3d_private; - glThis->free_lights |= (light_num - GL_LIGHT0); -} - #if !defined(__STRICT_ANSI__) && defined(__GNUC__) # define XCAST(fun) (typeof(VTABLE_IDirect3D7.fun)) #else @@ -453,9 +437,6 @@ HRESULT direct3d_create(IDirectDrawImpl ICOM_INIT_INTERFACE(This, IDirect3D3, VTABLE_IDirect3D3); ICOM_INIT_INTERFACE(This, IDirect3D7, VTABLE_IDirect3D7);
- globject->free_lights = (0x01 << MAX_LIGHTS) - 1; /* There are, in total, 8 lights in OpenGL */ - globject->light_released = light_released; - This->d3d_private = globject;
TRACE(" creating OpenGL private storage at %p.\n", globject);