4 This files contains the implementation of Direct3DMaterial2. */
9 #include "wine/obj_base.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(ddraw
, "Activating material %p\n", This
);
30 /* First, set the rendering context */
32 This
->device
.active_device2
->set_context(This
->device
.active_device2
);
34 This
->device
.active_device1
->set_context(This
->device
.active_device1
);
36 /* Set the current Material */
37 _dump_colorvalue("Diffuse", This
->mat
.a
.diffuse
);
38 glMaterialfv(GL_FRONT
,
40 (float *) &(This
->mat
.a
.diffuse
));
41 _dump_colorvalue("Ambient", This
->mat
.b
.ambient
);
42 glMaterialfv(GL_FRONT
,
44 (float *) &(This
->mat
.b
.ambient
));
45 _dump_colorvalue("Specular", This
->mat
.c
.specular
);
46 glMaterialfv(GL_FRONT
,
48 (float *) &(This
->mat
.c
.specular
));
49 _dump_colorvalue("Emissive", This
->mat
.d
.emissive
);
50 glMaterialfv(GL_FRONT
,
52 (float *) &(This
->mat
.d
.emissive
));
54 TRACE(ddraw
, "Size : %ld\n", This
->mat
.dwSize
);
55 TRACE(ddraw
, "Power : %f\n", This
->mat
.e
.power
);
57 TRACE(ddraw
, "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 mat
->lpvtbl
= &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 mat
->lpvtbl
= (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
);
108 WINE_StringFromCLSID((LPCLSID
)riid
,xrefiid
);
109 FIXME(ddraw
, "(%p)->(%s,%p): stub\n", This
, xrefiid
,ppvObj
);
116 static ULONG WINAPI
IDirect3DMaterial2Impl_AddRef(LPDIRECT3DMATERIAL2 iface
)
118 ICOM_THIS(IDirect3DMaterial2Impl
,iface
);
119 TRACE(ddraw
, "(%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( ddraw
, "(%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(ddraw
, "(%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(ddraw
, "(%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(ddraw
, "(%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(ddraw
, "(%p)->(): stub\n", This
);
196 return DDERR_INVALIDPARAMS
;
199 static HRESULT WINAPI
IDirect3DMaterialImpl_Unreserve(LPDIRECT3DMATERIAL iface
)
201 ICOM_THIS(IDirect3DMaterial2Impl
,iface
);
202 FIXME(ddraw
, "(%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(ddraw
, "(%p)->(%p)\n", This
, lpDirect3D
);
214 return DDERR_ALREADYINITIALIZED
;
218 /*******************************************************************************
219 * IDirect3DMaterial VTable
221 static ICOM_VTABLE(IDirect3DMaterial
) material_vtable
= {
222 /*** IUnknown methods ***/
223 IDirect3DMaterial2Impl_QueryInterface
,
224 IDirect3DMaterial2Impl_AddRef
,
225 IDirect3DMaterial2Impl_Release
,
226 /*** IDirect3DMaterial methods ***/
227 IDirect3DMaterialImpl_Initialize
,
228 IDirect3DMaterial2Impl_SetMaterial
,
229 IDirect3DMaterial2Impl_GetMaterial
,
230 IDirect3DMaterial2Impl_GetHandle
,
231 IDirect3DMaterialImpl_Reserve
,
232 IDirect3DMaterialImpl_Unreserve
236 /*******************************************************************************
237 * IDirect3DMaterial2 VTable
239 static ICOM_VTABLE(IDirect3DMaterial2
) material2_vtable
= {
240 /*** IUnknown methods ***/
241 IDirect3DMaterial2Impl_QueryInterface
,
242 IDirect3DMaterial2Impl_AddRef
,
243 IDirect3DMaterial2Impl_Release
,
244 /*** IDirect3DMaterial methods ***/
245 IDirect3DMaterial2Impl_SetMaterial
,
246 IDirect3DMaterial2Impl_GetMaterial
,
247 IDirect3DMaterial2Impl_GetHandle
250 #else /* HAVE_MESAGL */
252 LPDIRECT3DMATERIAL
d3dmaterial_create(IDirect3DImpl
* d3d1
) {
253 ERR(ddraw
, "Should not be called...\n");
257 LPDIRECT3DMATERIAL2
d3dmaterial2_create(IDirect3D2Impl
* d3d2
) {
258 ERR(ddraw
, "Should not be called...\n");
263 #endif /* HAVE_MESAGL */