Commit 472a8f7a authored by Ričardas Barkauskas's avatar Ričardas Barkauskas Committed by Alexandre Julliard

ddraw: COM cleanup for IDirect3DDevice7 interface.

parent 7dc08745
...@@ -4328,7 +4328,7 @@ static HRESULT WINAPI d3d7_CreateDevice(IDirect3D7 *iface, REFCLSID riid, ...@@ -4328,7 +4328,7 @@ static HRESULT WINAPI d3d7_CreateDevice(IDirect3D7 *iface, REFCLSID riid,
} }
TRACE("Created device %p.\n", object); TRACE("Created device %p.\n", object);
*device = (IDirect3DDevice7 *)object; *device = &object->IDirect3DDevice7_iface;
LeaveCriticalSection(&ddraw_cs); LeaveCriticalSection(&ddraw_cs);
return D3D_OK; return D3D_OK;
......
...@@ -277,7 +277,7 @@ void *ddraw_get_object(struct ddraw_handle_table *t, DWORD handle, enum ddraw_ha ...@@ -277,7 +277,7 @@ void *ddraw_get_object(struct ddraw_handle_table *t, DWORD handle, enum ddraw_ha
struct IDirect3DDeviceImpl struct IDirect3DDeviceImpl
{ {
/* IUnknown */ /* IUnknown */
const IDirect3DDevice7Vtbl *lpVtbl; IDirect3DDevice7 IDirect3DDevice7_iface;
IDirect3DDevice3 IDirect3DDevice3_iface; IDirect3DDevice3 IDirect3DDevice3_iface;
IDirect3DDevice2 IDirect3DDevice2_iface; IDirect3DDevice2 IDirect3DDevice2_iface;
IDirect3DDevice IDirect3DDevice_iface; IDirect3DDevice IDirect3DDevice_iface;
...@@ -342,7 +342,7 @@ static inline IDirect3DDeviceImpl *impl_from_IDirect3DDevice3(IDirect3DDevice3 * ...@@ -342,7 +342,7 @@ static inline IDirect3DDeviceImpl *impl_from_IDirect3DDevice3(IDirect3DDevice3 *
static inline IDirect3DDeviceImpl *impl_from_IDirect3DDevice7(IDirect3DDevice7 *iface) static inline IDirect3DDeviceImpl *impl_from_IDirect3DDevice7(IDirect3DDevice7 *iface)
{ {
return CONTAINING_RECORD(iface, IDirect3DDeviceImpl, lpVtbl); return CONTAINING_RECORD(iface, IDirect3DDeviceImpl, IDirect3DDevice7_iface);
} }
IDirect3DDeviceImpl *unsafe_impl_from_IDirect3DDevice(IDirect3DDevice *iface) DECLSPEC_HIDDEN; IDirect3DDeviceImpl *unsafe_impl_from_IDirect3DDevice(IDirect3DDevice *iface) DECLSPEC_HIDDEN;
......
...@@ -157,7 +157,7 @@ HRESULT d3d_execute_buffer_execute(IDirect3DExecuteBufferImpl *This, ...@@ -157,7 +157,7 @@ HRESULT d3d_execute_buffer_execute(IDirect3DExecuteBufferImpl *This,
* enable it before drawing. This overwrites any ALPHA* * enable it before drawing. This overwrites any ALPHA*
* render state. */ * render state. */
wined3d_device_set_render_state(lpDevice->wined3d_device, WINED3DRS_COLORKEYENABLE, 1); wined3d_device_set_render_state(lpDevice->wined3d_device, WINED3DRS_COLORKEYENABLE, 1);
IDirect3DDevice7_DrawIndexedPrimitive((IDirect3DDevice7 *)lpDevice, IDirect3DDevice7_DrawIndexedPrimitive(&lpDevice->IDirect3DDevice7_iface,
D3DPT_TRIANGLELIST, D3DFVF_TLVERTEX, tl_vx, 0, This->indices, count * 3, 0); D3DPT_TRIANGLELIST, D3DFVF_TLVERTEX, tl_vx, 0, This->indices, count * 3, 0);
} break; } break;
...@@ -216,7 +216,7 @@ HRESULT d3d_execute_buffer_execute(IDirect3DExecuteBufferImpl *This, ...@@ -216,7 +216,7 @@ HRESULT d3d_execute_buffer_execute(IDirect3DExecuteBufferImpl *This,
lpDevice->view = ci->u2.dwArg[0]; lpDevice->view = ci->u2.dwArg[0];
if (ci->u1.dtstTransformStateType == D3DTRANSFORMSTATE_PROJECTION) if (ci->u1.dtstTransformStateType == D3DTRANSFORMSTATE_PROJECTION)
lpDevice->proj = ci->u2.dwArg[0]; lpDevice->proj = ci->u2.dwArg[0];
IDirect3DDevice7_SetTransform((IDirect3DDevice7 *)lpDevice, IDirect3DDevice7_SetTransform(&lpDevice->IDirect3DDevice7_iface,
ci->u1.dtstTransformStateType, m); ci->u1.dtstTransformStateType, m);
} }
...@@ -283,7 +283,7 @@ HRESULT d3d_execute_buffer_execute(IDirect3DExecuteBufferImpl *This, ...@@ -283,7 +283,7 @@ HRESULT d3d_execute_buffer_execute(IDirect3DExecuteBufferImpl *This,
break; break;
} }
IDirect3DDevice7_SetRenderState((IDirect3DDevice7 *)lpDevice, rs, ci->u2.dwArg[0]); IDirect3DDevice7_SetRenderState(&lpDevice->IDirect3DDevice7_iface, rs, ci->u2.dwArg[0]);
} }
instr += size; instr += size;
......
...@@ -41,7 +41,7 @@ static void light_update(IDirect3DLightImpl *light) ...@@ -41,7 +41,7 @@ static void light_update(IDirect3DLightImpl *light)
if (!light->active_viewport || !light->active_viewport->active_device) return; if (!light->active_viewport || !light->active_viewport->active_device) return;
device = light->active_viewport->active_device; device = light->active_viewport->active_device;
IDirect3DDevice7_SetLight((IDirect3DDevice7 *)device, light->dwLightIndex, &light->light7); IDirect3DDevice7_SetLight(&device->IDirect3DDevice7_iface, light->dwLightIndex, &light->light7);
} }
/***************************************************************************** /*****************************************************************************
...@@ -62,7 +62,7 @@ void light_activate(IDirect3DLightImpl *light) ...@@ -62,7 +62,7 @@ void light_activate(IDirect3DLightImpl *light)
light_update(light); light_update(light);
if (!(light->light.dwFlags & D3DLIGHT_ACTIVE)) if (!(light->light.dwFlags & D3DLIGHT_ACTIVE))
{ {
IDirect3DDevice7_LightEnable((IDirect3DDevice7 *)device, light->dwLightIndex, TRUE); IDirect3DDevice7_LightEnable(&device->IDirect3DDevice7_iface, light->dwLightIndex, TRUE);
light->light.dwFlags |= D3DLIGHT_ACTIVE; light->light.dwFlags |= D3DLIGHT_ACTIVE;
} }
} }
...@@ -86,7 +86,7 @@ void light_deactivate(IDirect3DLightImpl *light) ...@@ -86,7 +86,7 @@ void light_deactivate(IDirect3DLightImpl *light)
/* If was not active, activate it */ /* If was not active, activate it */
if (light->light.dwFlags & D3DLIGHT_ACTIVE) if (light->light.dwFlags & D3DLIGHT_ACTIVE)
{ {
IDirect3DDevice7_LightEnable((IDirect3DDevice7 *)device, light->dwLightIndex, FALSE); IDirect3DDevice7_LightEnable(&device->IDirect3DDevice7_iface, light->dwLightIndex, FALSE);
light->light.dwFlags &= ~D3DLIGHT_ACTIVE; light->light.dwFlags &= ~D3DLIGHT_ACTIVE;
} }
} }
......
...@@ -960,7 +960,7 @@ DllMain(HINSTANCE hInstDLL, ...@@ -960,7 +960,7 @@ DllMain(HINSTANCE hInstDLL,
if(ddraw->d3ddevice) if(ddraw->d3ddevice)
{ {
WARN("DDraw %p has d3ddevice %p attached\n", ddraw, ddraw->d3ddevice); WARN("DDraw %p has d3ddevice %p attached\n", ddraw, ddraw->d3ddevice);
while(IDirect3DDevice7_Release((IDirect3DDevice7 *)ddraw->d3ddevice)); while(IDirect3DDevice7_Release(&ddraw->d3ddevice->IDirect3DDevice7_iface));
} }
/* Try to release the objects /* Try to release the objects
......
...@@ -464,7 +464,7 @@ void material_activate(IDirect3DMaterialImpl* This) ...@@ -464,7 +464,7 @@ void material_activate(IDirect3DMaterialImpl* This)
d3d7mat.u3.emissive = This->mat.u3.emissive; d3d7mat.u3.emissive = This->mat.u3.emissive;
d3d7mat.u4.power = This->mat.u4.power; d3d7mat.u4.power = This->mat.u4.power;
IDirect3DDevice7_SetMaterial((IDirect3DDevice7 *)This->active_device, &d3d7mat); IDirect3DDevice7_SetMaterial(&This->active_device->IDirect3DDevice7_iface, &d3d7mat);
} }
static const struct IDirect3DMaterial3Vtbl d3d_material3_vtbl = static const struct IDirect3DMaterial3Vtbl d3d_material3_vtbl =
......
...@@ -361,8 +361,8 @@ static HRESULT WINAPI IDirect3DVertexBufferImpl_1_ProcessVertices(IDirect3DVerte ...@@ -361,8 +361,8 @@ static HRESULT WINAPI IDirect3DVertexBufferImpl_1_ProcessVertices(IDirect3DVerte
iface, VertexOp, DestIndex, Count, SrcBuffer, SrcIndex, device, Flags); iface, VertexOp, DestIndex, Count, SrcBuffer, SrcIndex, device, Flags);
return IDirect3DVertexBuffer7_ProcessVertices(&This->IDirect3DVertexBuffer7_iface, VertexOp, return IDirect3DVertexBuffer7_ProcessVertices(&This->IDirect3DVertexBuffer7_iface, VertexOp,
DestIndex, Count, &Src->IDirect3DVertexBuffer7_iface, SrcIndex, (IDirect3DDevice7 *)device_impl, DestIndex, Count, &Src->IDirect3DVertexBuffer7_iface, SrcIndex,
Flags); device_impl ? &device_impl->IDirect3DDevice7_iface : NULL, Flags);
} }
/***************************************************************************** /*****************************************************************************
...@@ -459,7 +459,7 @@ static HRESULT WINAPI IDirect3DVertexBufferImpl_1_Optimize(IDirect3DVertexBuffer ...@@ -459,7 +459,7 @@ static HRESULT WINAPI IDirect3DVertexBufferImpl_1_Optimize(IDirect3DVertexBuffer
TRACE("iface %p, device %p, flags %#x.\n", iface, device, Flags); TRACE("iface %p, device %p, flags %#x.\n", iface, device, Flags);
return IDirect3DVertexBuffer7_Optimize(&This->IDirect3DVertexBuffer7_iface, return IDirect3DVertexBuffer7_Optimize(&This->IDirect3DVertexBuffer7_iface,
(IDirect3DDevice7 *)device_impl, Flags); device_impl ? &device_impl->IDirect3DDevice7_iface : NULL, Flags);
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -72,7 +72,7 @@ void viewport_activate(IDirect3DViewportImpl *This, BOOL ignore_lights) ...@@ -72,7 +72,7 @@ void viewport_activate(IDirect3DViewportImpl *This, BOOL ignore_lights)
} }
/* And also set the viewport */ /* And also set the viewport */
IDirect3DDevice7_SetViewport((IDirect3DDevice7 *)This->active_device, &vp); IDirect3DDevice7_SetViewport(&This->active_device->IDirect3DDevice7_iface, &vp);
} }
/***************************************************************************** /*****************************************************************************
...@@ -692,7 +692,7 @@ static HRESULT WINAPI IDirect3DViewportImpl_Clear(IDirect3DViewport3 *iface, ...@@ -692,7 +692,7 @@ static HRESULT WINAPI IDirect3DViewportImpl_Clear(IDirect3DViewport3 *iface,
afterwards. */ afterwards. */
viewport_activate(This, TRUE); viewport_activate(This, TRUE);
hr = IDirect3DDevice7_Clear((IDirect3DDevice7 *)This->active_device, dwCount, lpRects, hr = IDirect3DDevice7_Clear(&This->active_device->IDirect3DDevice7_iface, dwCount, lpRects,
dwFlags & (D3DCLEAR_ZBUFFER | D3DCLEAR_TARGET), color, 1.0, 0x00000000); dwFlags & (D3DCLEAR_ZBUFFER | D3DCLEAR_TARGET), color, 1.0, 0x00000000);
IDirect3DDevice3_GetCurrentViewport(d3d_device3, &current_viewport); IDirect3DDevice3_GetCurrentViewport(d3d_device3, &current_viewport);
...@@ -1075,7 +1075,7 @@ IDirect3DViewportImpl_Clear2(IDirect3DViewport3 *iface, ...@@ -1075,7 +1075,7 @@ IDirect3DViewportImpl_Clear2(IDirect3DViewport3 *iface,
* one will be restored afterwards. */ * one will be restored afterwards. */
viewport_activate(This, TRUE); viewport_activate(This, TRUE);
hr = IDirect3DDevice7_Clear((IDirect3DDevice7 *)This->active_device, hr = IDirect3DDevice7_Clear(&This->active_device->IDirect3DDevice7_iface,
dwCount, lpRects, dwFlags, dwColor, dvZ, dwStencil); dwCount, lpRects, dwFlags, dwColor, dvZ, dwStencil);
IDirect3DDevice3_GetCurrentViewport(d3d_device3, &current_viewport); IDirect3DDevice3_GetCurrentViewport(d3d_device3, &current_viewport);
if(current_viewport) { if(current_viewport) {
......
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