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 mat->lpvtbl = &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 mat->lpvtbl = (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);
110 WINE_StringFromCLSID((LPCLSID)riid,xrefiid);
111 FIXME("(%p)->(%s,%p): stub\n", This, xrefiid,ppvObj);
118 static ULONG WINAPI IDirect3DMaterial2Impl_AddRef(LPDIRECT3DMATERIAL2 iface)
120 ICOM_THIS(IDirect3DMaterial2Impl,iface);
121 TRACE("(%p)->()incrementing from %lu.\n", This, This->ref );
123 return ++(This->ref);
128 static ULONG WINAPI IDirect3DMaterial2Impl_Release(LPDIRECT3DMATERIAL2 iface)
130 ICOM_THIS(IDirect3DMaterial2Impl,iface);
131 FIXME("(%p)->() decrementing from %lu.\n", This, This->ref );
133 if (!--(This->ref)) {
134 HeapFree(GetProcessHeap(),0,This);
141 /*** IDirect3DMaterial2 methods ***/
142 static void dump_material(LPD3DMATERIAL mat)
144 fprintf(stderr, " dwSize : %ld\n", mat->dwSize);
147 static HRESULT WINAPI IDirect3DMaterial2Impl_GetMaterial(LPDIRECT3DMATERIAL2 iface,
150 ICOM_THIS(IDirect3DMaterial2Impl,iface);
151 TRACE("(%p)->(%p)\n", This, lpMat);
153 dump_material(lpMat);
155 /* Copies the material structure */
161 static HRESULT WINAPI IDirect3DMaterial2Impl_SetMaterial(LPDIRECT3DMATERIAL2 iface,
164 ICOM_THIS(IDirect3DMaterial2Impl,iface);
165 TRACE("(%p)->(%p)\n", This, lpMat);
167 dump_material(lpMat);
169 /* Stores the material */
175 static HRESULT WINAPI IDirect3DMaterial2Impl_GetHandle(LPDIRECT3DMATERIAL2 iface,
176 LPDIRECT3DDEVICE2 lpD3DDevice2,
177 LPD3DMATERIALHANDLE lpMatHandle)
180 ICOM_THIS(IDirect3DMaterial2Impl,iface);
181 FIXME("(%p)->(%p,%p): stub\n", This, lpD3DDevice2, lpMatHandle);
184 This->device.active_device2 = (IDirect3DDevice2Impl*)lpD3DDevice2;
186 This->device.active_device1 = (IDirect3DDeviceImpl*)lpD3DDevice2;
188 *lpMatHandle = (DWORD) This; /* lpD3DDevice2->store_material(This); */
193 static HRESULT WINAPI IDirect3DMaterialImpl_Reserve(LPDIRECT3DMATERIAL iface)
195 ICOM_THIS(IDirect3DMaterial2Impl,iface);
196 FIXME("(%p)->(): stub\n", This);
198 return DDERR_INVALIDPARAMS;
201 static HRESULT WINAPI IDirect3DMaterialImpl_Unreserve(LPDIRECT3DMATERIAL iface)
203 ICOM_THIS(IDirect3DMaterial2Impl,iface);
204 FIXME("(%p)->(): stub\n", This);
206 return DDERR_INVALIDPARAMS;
209 static HRESULT WINAPI IDirect3DMaterialImpl_Initialize(LPDIRECT3DMATERIAL iface,
210 LPDIRECT3D lpDirect3D)
213 ICOM_THIS(IDirect3DMaterial2Impl,iface);
214 TRACE("(%p)->(%p)\n", This, lpDirect3D);
216 return DDERR_ALREADYINITIALIZED;
220 /*******************************************************************************
221 * IDirect3DMaterial VTable
223 static ICOM_VTABLE(IDirect3DMaterial) material_vtable =
225 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
226 /*** IUnknown methods ***/
227 IDirect3DMaterial2Impl_QueryInterface,
228 IDirect3DMaterial2Impl_AddRef,
229 IDirect3DMaterial2Impl_Release,
230 /*** IDirect3DMaterial methods ***/
231 IDirect3DMaterialImpl_Initialize,
232 IDirect3DMaterial2Impl_SetMaterial,
233 IDirect3DMaterial2Impl_GetMaterial,
234 IDirect3DMaterial2Impl_GetHandle,
235 IDirect3DMaterialImpl_Reserve,
236 IDirect3DMaterialImpl_Unreserve
240 /*******************************************************************************
241 * IDirect3DMaterial2 VTable
243 static ICOM_VTABLE(IDirect3DMaterial2) material2_vtable =
245 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
246 /*** IUnknown methods ***/
247 IDirect3DMaterial2Impl_QueryInterface,
248 IDirect3DMaterial2Impl_AddRef,
249 IDirect3DMaterial2Impl_Release,
250 /*** IDirect3DMaterial methods ***/
251 IDirect3DMaterial2Impl_SetMaterial,
252 IDirect3DMaterial2Impl_GetMaterial,
253 IDirect3DMaterial2Impl_GetHandle
256 #else /* HAVE_MESAGL */
258 LPDIRECT3DMATERIAL d3dmaterial_create(IDirect3DImpl* d3d1) {
259 ERR("Should not be called...\n");
263 LPDIRECT3DMATERIAL2 d3dmaterial2_create(IDirect3D2Impl* d3d2) {
264 ERR("Should not be called...\n");
269 #endif /* HAVE_MESAGL */