4 This files contains the implementation of Direct3DMaterial2. */
9 #include "wine/obj_base.h"
13 #include "debugtools.h"
15 #include "d3d_private.h"
17 DEFAULT_DEBUG_CHANNEL(ddraw
)
21 static ICOM_VTABLE(IDirect3DMaterial2
) material2_vtable
;
22 static ICOM_VTABLE(IDirect3DMaterial
) material_vtable
;
24 /*******************************************************************************
25 * Matrial2 static functions
27 static void activate(IDirect3DMaterial2Impl
* This
) {
28 TRACE("Activating material %p\n", This
);
31 /* First, set the rendering context */
33 This
->device
.active_device2
->set_context(This
->device
.active_device2
);
35 This
->device
.active_device1
->set_context(This
->device
.active_device1
);
37 /* Set the current Material */
38 _dump_colorvalue("Diffuse", This
->mat
.a
.diffuse
);
39 glMaterialfv(GL_FRONT
,
41 (float *) &(This
->mat
.a
.diffuse
));
42 _dump_colorvalue("Ambient", This
->mat
.b
.ambient
);
43 glMaterialfv(GL_FRONT
,
45 (float *) &(This
->mat
.b
.ambient
));
46 _dump_colorvalue("Specular", This
->mat
.c
.specular
);
47 glMaterialfv(GL_FRONT
,
49 (float *) &(This
->mat
.c
.specular
));
50 _dump_colorvalue("Emissive", This
->mat
.d
.emissive
);
51 glMaterialfv(GL_FRONT
,
53 (float *) &(This
->mat
.d
.emissive
));
55 TRACE("Size : %ld\n", This
->mat
.dwSize
);
56 TRACE("Power : %f\n", This
->mat
.e
.power
);
58 TRACE("Texture handle : %08lx\n", (DWORD
)This
->mat
.hTexture
);
64 /*******************************************************************************
65 * Matrial2 Creation functions
67 LPDIRECT3DMATERIAL2
d3dmaterial2_create(IDirect3D2Impl
* d3d2
)
69 IDirect3DMaterial2Impl
* mat
;
71 mat
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(IDirect3DMaterial2Impl
));
73 ICOM_VTBL(mat
) = &material2_vtable
;
78 mat
->activate
= activate
;
80 return (LPDIRECT3DMATERIAL2
)mat
;
83 LPDIRECT3DMATERIAL
d3dmaterial_create(IDirect3DImpl
* d3d1
)
85 IDirect3DMaterial2Impl
* mat
;
87 mat
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(IDirect3DMaterial2Impl
));
89 ICOM_VTBL(mat
) = (ICOM_VTABLE(IDirect3DMaterial2
)*)&material_vtable
;
94 mat
->activate
= activate
;
96 return (LPDIRECT3DMATERIAL
) mat
;
99 /*******************************************************************************
100 * IDirect3DMaterial2 methods
103 static HRESULT WINAPI
IDirect3DMaterial2Impl_QueryInterface(LPDIRECT3DMATERIAL2 iface
,
107 ICOM_THIS(IDirect3DMaterial2Impl
,iface
);
109 FIXME("(%p)->(%s,%p): stub\n", This
, debugstr_guid(riid
),ppvObj
);
116 static ULONG WINAPI
IDirect3DMaterial2Impl_AddRef(LPDIRECT3DMATERIAL2 iface
)
118 ICOM_THIS(IDirect3DMaterial2Impl
,iface
);
119 TRACE("(%p)->()incrementing from %lu.\n", This
, This
->ref
);
121 return ++(This
->ref
);
126 static ULONG WINAPI
IDirect3DMaterial2Impl_Release(LPDIRECT3DMATERIAL2 iface
)
128 ICOM_THIS(IDirect3DMaterial2Impl
,iface
);
129 FIXME("(%p)->() decrementing from %lu.\n", This
, This
->ref
);
131 if (!--(This
->ref
)) {
132 HeapFree(GetProcessHeap(),0,This
);
139 /*** IDirect3DMaterial2 methods ***/
140 static void dump_material(LPD3DMATERIAL mat
)
142 fprintf(stderr
, " dwSize : %ld\n", mat
->dwSize
);
145 static HRESULT WINAPI
IDirect3DMaterial2Impl_GetMaterial(LPDIRECT3DMATERIAL2 iface
,
148 ICOM_THIS(IDirect3DMaterial2Impl
,iface
);
149 TRACE("(%p)->(%p)\n", This
, lpMat
);
151 dump_material(lpMat
);
153 /* Copies the material structure */
159 static HRESULT WINAPI
IDirect3DMaterial2Impl_SetMaterial(LPDIRECT3DMATERIAL2 iface
,
162 ICOM_THIS(IDirect3DMaterial2Impl
,iface
);
163 TRACE("(%p)->(%p)\n", This
, lpMat
);
165 dump_material(lpMat
);
167 /* Stores the material */
173 static HRESULT WINAPI
IDirect3DMaterial2Impl_GetHandle(LPDIRECT3DMATERIAL2 iface
,
174 LPDIRECT3DDEVICE2 lpD3DDevice2
,
175 LPD3DMATERIALHANDLE lpMatHandle
)
178 ICOM_THIS(IDirect3DMaterial2Impl
,iface
);
179 FIXME("(%p)->(%p,%p): stub\n", This
, lpD3DDevice2
, lpMatHandle
);
182 This
->device
.active_device2
= (IDirect3DDevice2Impl
*)lpD3DDevice2
;
184 This
->device
.active_device1
= (IDirect3DDeviceImpl
*)lpD3DDevice2
;
186 *lpMatHandle
= (DWORD
) This
; /* lpD3DDevice2->store_material(This); */
191 static HRESULT WINAPI
IDirect3DMaterialImpl_Reserve(LPDIRECT3DMATERIAL iface
)
193 ICOM_THIS(IDirect3DMaterial2Impl
,iface
);
194 FIXME("(%p)->(): stub\n", This
);
196 return DDERR_INVALIDPARAMS
;
199 static HRESULT WINAPI
IDirect3DMaterialImpl_Unreserve(LPDIRECT3DMATERIAL iface
)
201 ICOM_THIS(IDirect3DMaterial2Impl
,iface
);
202 FIXME("(%p)->(): stub\n", This
);
204 return DDERR_INVALIDPARAMS
;
207 static HRESULT WINAPI
IDirect3DMaterialImpl_Initialize(LPDIRECT3DMATERIAL iface
,
208 LPDIRECT3D lpDirect3D
)
211 ICOM_THIS(IDirect3DMaterial2Impl
,iface
);
212 TRACE("(%p)->(%p)\n", This
, lpDirect3D
);
214 return DDERR_ALREADYINITIALIZED
;
218 /*******************************************************************************
219 * IDirect3DMaterial VTable
221 static ICOM_VTABLE(IDirect3DMaterial
) material_vtable
=
223 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
224 /*** IUnknown methods ***/
225 IDirect3DMaterial2Impl_QueryInterface
,
226 IDirect3DMaterial2Impl_AddRef
,
227 IDirect3DMaterial2Impl_Release
,
228 /*** IDirect3DMaterial methods ***/
229 IDirect3DMaterialImpl_Initialize
,
230 IDirect3DMaterial2Impl_SetMaterial
,
231 IDirect3DMaterial2Impl_GetMaterial
,
232 IDirect3DMaterial2Impl_GetHandle
,
233 IDirect3DMaterialImpl_Reserve
,
234 IDirect3DMaterialImpl_Unreserve
238 /*******************************************************************************
239 * IDirect3DMaterial2 VTable
241 static ICOM_VTABLE(IDirect3DMaterial2
) material2_vtable
=
243 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
244 /*** IUnknown methods ***/
245 IDirect3DMaterial2Impl_QueryInterface
,
246 IDirect3DMaterial2Impl_AddRef
,
247 IDirect3DMaterial2Impl_Release
,
248 /*** IDirect3DMaterial methods ***/
249 IDirect3DMaterial2Impl_SetMaterial
,
250 IDirect3DMaterial2Impl_GetMaterial
,
251 IDirect3DMaterial2Impl_GetHandle
254 #else /* HAVE_MESAGL */
256 LPDIRECT3DMATERIAL
d3dmaterial_create(IDirect3DImpl
* d3d1
) {
257 ERR("Should not be called...\n");
261 LPDIRECT3DMATERIAL2
d3dmaterial2_create(IDirect3D2Impl
* d3d2
) {
262 ERR("Should not be called...\n");
267 #endif /* HAVE_MESAGL */