From bf26c2c869ef49a69dd192fed58b8f393b69a5d4 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Wed, 18 Aug 2010 19:26:22 +0200 Subject: [PATCH] ddraw: Add a separate function for material initialization. --- dlls/ddraw/ddraw.c | 6 +----- dlls/ddraw/ddraw_private.h | 6 +----- dlls/ddraw/material.c | 15 ++++++++++++--- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c index 28af7d06eec..75416716aec 100644 --- a/dlls/ddraw/ddraw.c +++ b/dlls/ddraw/ddraw.c @@ -4432,11 +4432,7 @@ static HRESULT WINAPI d3d3_CreateMaterial(IDirect3D3 *iface, IDirect3DMaterial3 return DDERR_OUTOFMEMORY; } - object->lpVtbl = &IDirect3DMaterial3_Vtbl; - object->IDirect3DMaterial2_vtbl = &IDirect3DMaterial2_Vtbl; - object->IDirect3DMaterial_vtbl = &IDirect3DMaterial_Vtbl; - object->ref = 1; - object->ddraw = ddraw_from_d3d3(iface); + d3d_material_init(object, ddraw_from_d3d3(iface)); TRACE("Created material %p.\n", object); *material = (IDirect3DMaterial3 *)object; diff --git a/dlls/ddraw/ddraw_private.h b/dlls/ddraw/ddraw_private.h index f7ea61dac0a..6ea61fe394e 100644 --- a/dlls/ddraw/ddraw_private.h +++ b/dlls/ddraw/ddraw_private.h @@ -548,13 +548,9 @@ struct IDirect3DMaterialImpl DWORD Handle; }; -/* VTables in various versions */ -extern const IDirect3DMaterialVtbl IDirect3DMaterial_Vtbl DECLSPEC_HIDDEN; -extern const IDirect3DMaterial2Vtbl IDirect3DMaterial2_Vtbl DECLSPEC_HIDDEN; -extern const IDirect3DMaterial3Vtbl IDirect3DMaterial3_Vtbl DECLSPEC_HIDDEN; - /* Helper functions */ void material_activate(IDirect3DMaterialImpl* This) DECLSPEC_HIDDEN; +void d3d_material_init(IDirect3DMaterialImpl *material, IDirectDrawImpl *ddraw) DECLSPEC_HIDDEN; /***************************************************************************** * IDirect3DViewport - Wraps to D3D7 diff --git a/dlls/ddraw/material.c b/dlls/ddraw/material.c index 68da7ff6712..10f4ab54274 100644 --- a/dlls/ddraw/material.c +++ b/dlls/ddraw/material.c @@ -448,7 +448,7 @@ void material_activate(IDirect3DMaterialImpl* This) IDirect3DDevice7_SetMaterial((IDirect3DDevice7 *)This->active_device, &d3d7mat); } -const IDirect3DMaterial3Vtbl IDirect3DMaterial3_Vtbl = +static const struct IDirect3DMaterial3Vtbl d3d_material3_vtbl = { /*** IUnknown Methods ***/ IDirect3DMaterialImpl_QueryInterface, @@ -460,7 +460,7 @@ const IDirect3DMaterial3Vtbl IDirect3DMaterial3_Vtbl = IDirect3DMaterialImpl_GetHandle, }; -const IDirect3DMaterial2Vtbl IDirect3DMaterial2_Vtbl = +static const struct IDirect3DMaterial2Vtbl d3d_material2_vtbl = { /*** IUnknown Methods ***/ Thunk_IDirect3DMaterialImpl_2_QueryInterface, @@ -472,7 +472,7 @@ const IDirect3DMaterial2Vtbl IDirect3DMaterial2_Vtbl = Thunk_IDirect3DMaterialImpl_2_GetHandle, }; -const IDirect3DMaterialVtbl IDirect3DMaterial_Vtbl = +static const struct IDirect3DMaterialVtbl d3d_material1_vtbl = { /*** IUnknown Methods ***/ Thunk_IDirect3DMaterialImpl_1_QueryInterface, @@ -486,3 +486,12 @@ const IDirect3DMaterialVtbl IDirect3DMaterial_Vtbl = IDirect3DMaterialImpl_Reserve, IDirect3DMaterialImpl_Unreserve }; + +void d3d_material_init(IDirect3DMaterialImpl *material, IDirectDrawImpl *ddraw) +{ + material->lpVtbl = &d3d_material3_vtbl; + material->IDirect3DMaterial2_vtbl = &d3d_material2_vtbl; + material->IDirect3DMaterial_vtbl = &d3d_material1_vtbl; + material->ref = 1; + material->ddraw = ddraw; +}