4 This files contains the implementation of Direct3DMaterial2. */
9 #include "wine/obj_base.h"
13 #include "debugtools.h"
15 #include "mesa_private.h"
17 DEFAULT_DEBUG_CHANNEL(ddraw)
19 static ICOM_VTABLE(IDirect3DMaterial2) material2_vtable;
20 static ICOM_VTABLE(IDirect3DMaterial) material_vtable;
22 /*******************************************************************************
23 * Matrial2 static functions
25 static void activate(IDirect3DMaterial2Impl* This) {
26 TRACE("Activating material %p\n", This);
29 /* First, set the rendering context */
31 This->device.active_device2->set_context(This->device.active_device2);
33 This->device.active_device1->set_context(This->device.active_device1);
35 /* Set the current Material */
36 _dump_colorvalue("Diffuse", This->mat.a.diffuse);
37 glMaterialfv(GL_FRONT,
39 (float *) &(This->mat.a.diffuse));
40 _dump_colorvalue("Ambient", This->mat.b.ambient);
41 glMaterialfv(GL_FRONT,
43 (float *) &(This->mat.b.ambient));
44 _dump_colorvalue("Specular", This->mat.c.specular);
45 glMaterialfv(GL_FRONT,
47 (float *) &(This->mat.c.specular));
48 _dump_colorvalue("Emissive", This->mat.d.emissive);
49 glMaterialfv(GL_FRONT,
51 (float *) &(This->mat.d.emissive));
53 TRACE("Size : %ld\n", This->mat.dwSize);
54 TRACE("Power : %f\n", This->mat.e.power);
56 TRACE("Texture handle : %08lx\n", (DWORD)This->mat.hTexture);
62 /*******************************************************************************
63 * Matrial2 Creation functions
65 LPDIRECT3DMATERIAL2 d3dmaterial2_create(IDirect3D2Impl* d3d2)
67 IDirect3DMaterial2Impl* mat;
69 mat = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirect3DMaterial2Impl));
71 ICOM_VTBL(mat) = &material2_vtable;
76 mat->activate = activate;
78 return (LPDIRECT3DMATERIAL2)mat;
81 LPDIRECT3DMATERIAL d3dmaterial_create(IDirect3DImpl* d3d1)
83 IDirect3DMaterial2Impl* mat;
85 mat = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirect3DMaterial2Impl));
87 ICOM_VTBL(mat) = (ICOM_VTABLE(IDirect3DMaterial2)*)&material_vtable;
92 mat->activate = activate;
94 return (LPDIRECT3DMATERIAL) mat;
97 /*******************************************************************************
98 * IDirect3DMaterial2 methods
101 static HRESULT WINAPI IDirect3DMaterial2Impl_QueryInterface(LPDIRECT3DMATERIAL2 iface,
105 ICOM_THIS(IDirect3DMaterial2Impl,iface);
107 FIXME("(%p)->(%s,%p): stub\n", This, debugstr_guid(riid),ppvObj);
114 static ULONG WINAPI IDirect3DMaterial2Impl_AddRef(LPDIRECT3DMATERIAL2 iface)
116 ICOM_THIS(IDirect3DMaterial2Impl,iface);
117 TRACE("(%p)->()incrementing from %lu.\n", This, This->ref );
119 return ++(This->ref);
124 static ULONG WINAPI IDirect3DMaterial2Impl_Release(LPDIRECT3DMATERIAL2 iface)
126 ICOM_THIS(IDirect3DMaterial2Impl,iface);
127 FIXME("(%p)->() decrementing from %lu.\n", This, This->ref );
129 if (!--(This->ref)) {
130 HeapFree(GetProcessHeap(),0,This);
137 /*** IDirect3DMaterial2 methods ***/
138 static void dump_material(LPD3DMATERIAL mat)
140 DPRINTF(" dwSize : %ld\n", mat->dwSize);
143 static HRESULT WINAPI IDirect3DMaterial2Impl_GetMaterial(LPDIRECT3DMATERIAL2 iface,
146 ICOM_THIS(IDirect3DMaterial2Impl,iface);
147 TRACE("(%p)->(%p)\n", This, lpMat);
149 dump_material(lpMat);
151 /* Copies the material structure */
157 static HRESULT WINAPI IDirect3DMaterial2Impl_SetMaterial(LPDIRECT3DMATERIAL2 iface,
160 ICOM_THIS(IDirect3DMaterial2Impl,iface);
161 TRACE("(%p)->(%p)\n", This, lpMat);
163 dump_material(lpMat);
165 /* Stores the material */
171 static HRESULT WINAPI IDirect3DMaterial2Impl_GetHandle(LPDIRECT3DMATERIAL2 iface,
172 LPDIRECT3DDEVICE2 lpD3DDevice2,
173 LPD3DMATERIALHANDLE lpMatHandle)
176 ICOM_THIS(IDirect3DMaterial2Impl,iface);
177 FIXME("(%p)->(%p,%p): stub\n", This, lpD3DDevice2, lpMatHandle);
180 This->device.active_device2 = (IDirect3DDevice2Impl*)lpD3DDevice2;
182 This->device.active_device1 = (IDirect3DDeviceImpl*)lpD3DDevice2;
184 *lpMatHandle = (DWORD) This; /* lpD3DDevice2->store_material(This); */
189 static HRESULT WINAPI IDirect3DMaterialImpl_Reserve(LPDIRECT3DMATERIAL iface)
191 ICOM_THIS(IDirect3DMaterial2Impl,iface);
192 FIXME("(%p)->(): stub\n", This);
194 return DDERR_INVALIDPARAMS;
197 static HRESULT WINAPI IDirect3DMaterialImpl_Unreserve(LPDIRECT3DMATERIAL iface)
199 ICOM_THIS(IDirect3DMaterial2Impl,iface);
200 FIXME("(%p)->(): stub\n", This);
202 return DDERR_INVALIDPARAMS;
205 static HRESULT WINAPI IDirect3DMaterialImpl_Initialize(LPDIRECT3DMATERIAL iface,
206 LPDIRECT3D lpDirect3D)
209 ICOM_THIS(IDirect3DMaterial2Impl,iface);
210 TRACE("(%p)->(%p)\n", This, lpDirect3D);
212 return DDERR_ALREADYINITIALIZED;
216 /*******************************************************************************
217 * IDirect3DMaterial VTable
219 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
220 # define XCAST(fun) (typeof(material_vtable.fn##fun))
222 # define XCAST(fun) (void*)
225 static ICOM_VTABLE(IDirect3DMaterial) material_vtable =
227 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
228 /*** IUnknown methods ***/
229 XCAST(QueryInterface)IDirect3DMaterial2Impl_QueryInterface,
230 XCAST(AddRef)IDirect3DMaterial2Impl_AddRef,
231 XCAST(Release)IDirect3DMaterial2Impl_Release,
232 /*** IDirect3DMaterial methods ***/
233 IDirect3DMaterialImpl_Initialize,
234 XCAST(SetMaterial)IDirect3DMaterial2Impl_SetMaterial,
235 XCAST(GetMaterial)IDirect3DMaterial2Impl_GetMaterial,
236 XCAST(GetHandle)IDirect3DMaterial2Impl_GetHandle,
237 IDirect3DMaterialImpl_Reserve,
238 IDirect3DMaterialImpl_Unreserve
241 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
245 /*******************************************************************************
246 * IDirect3DMaterial2 VTable
248 static ICOM_VTABLE(IDirect3DMaterial2) material2_vtable =
250 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
251 /*** IUnknown methods ***/
252 IDirect3DMaterial2Impl_QueryInterface,
253 IDirect3DMaterial2Impl_AddRef,
254 IDirect3DMaterial2Impl_Release,
255 /*** IDirect3DMaterial methods ***/
256 IDirect3DMaterial2Impl_SetMaterial,
257 IDirect3DMaterial2Impl_GetMaterial,
258 IDirect3DMaterial2Impl_GetHandle