4 This files contains the implementation of Direct3DMaterial2. */
9 #include "wine/obj_base.h"
15 #include "d3d_private.h"
19 static IDirect3DMaterial2_VTable material2_vtable;
20 static IDirect3DMaterial_VTable material_vtable;
22 /*******************************************************************************
23 * Matrial2 static functions
25 static void activate(LPDIRECT3DMATERIAL2 this) {
26 TRACE(ddraw, "Activating material %p\n", this);
28 /* First, set the rendering context */
30 this->device.active_device2->set_context(this->device.active_device2);
32 this->device.active_device1->set_context(this->device.active_device1);
34 /* Set the current Material */
35 _dump_colorvalue("Diffuse", this->mat.a.diffuse);
36 glMaterialfv(GL_FRONT,
38 (float *) &(this->mat.a.diffuse));
39 _dump_colorvalue("Ambient", this->mat.b.ambient);
40 glMaterialfv(GL_FRONT,
42 (float *) &(this->mat.b.ambient));
43 _dump_colorvalue("Specular", this->mat.c.specular);
44 glMaterialfv(GL_FRONT,
46 (float *) &(this->mat.c.specular));
47 _dump_colorvalue("Emissive", this->mat.d.emissive);
48 glMaterialfv(GL_FRONT,
50 (float *) &(this->mat.d.emissive));
52 TRACE(ddraw, "Size : %ld\n", this->mat.dwSize);
53 TRACE(ddraw, "Power : %f\n", this->mat.e.power);
55 TRACE(ddraw, "Texture handle : %08lx\n", (DWORD)this->mat.hTexture);
60 /*******************************************************************************
61 * Matrial2 Creation functions
63 LPDIRECT3DMATERIAL2 d3dmaterial2_create(LPDIRECT3D2 d3d)
65 LPDIRECT3DMATERIAL2 mat;
67 mat = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirect3DMaterial2));
69 mat->lpvtbl = &material2_vtable;
74 mat->activate = activate;
79 LPDIRECT3DMATERIAL d3dmaterial_create(LPDIRECT3D d3d)
81 LPDIRECT3DMATERIAL2 mat;
83 mat = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirect3DMaterial2));
85 mat->lpvtbl = (LPDIRECT3DMATERIAL2_VTABLE) &material_vtable;
90 mat->activate = activate;
92 return (LPDIRECT3DMATERIAL) mat;
95 /*******************************************************************************
96 * IDirect3DMaterial2 methods
99 static HRESULT WINAPI IDirect3DMaterial2_QueryInterface(LPDIRECT3DMATERIAL2 this,
105 WINE_StringFromCLSID((LPCLSID)riid,xrefiid);
106 FIXME(ddraw, "(%p)->(%s,%p): stub\n", this, xrefiid,ppvObj);
113 static ULONG WINAPI IDirect3DMaterial2_AddRef(LPDIRECT3DMATERIAL2 this)
115 TRACE(ddraw, "(%p)->()incrementing from %lu.\n", this, this->ref );
117 return ++(this->ref);
122 static ULONG WINAPI IDirect3DMaterial2_Release(LPDIRECT3DMATERIAL2 this)
124 FIXME( ddraw, "(%p)->() decrementing from %lu.\n", this, this->ref );
126 if (!--(this->ref)) {
127 HeapFree(GetProcessHeap(),0,this);
134 /*** IDirect3DMaterial2 methods ***/
135 static void dump_material(LPD3DMATERIAL mat)
137 fprintf(stderr, " dwSize : %ld\n", mat->dwSize);
140 static HRESULT WINAPI IDirect3DMaterial2_GetMaterial(LPDIRECT3DMATERIAL2 this,
143 TRACE(ddraw, "(%p)->(%p)\n", this, lpMat);
145 dump_material(lpMat);
147 /* Copies the material structure */
153 static HRESULT WINAPI IDirect3DMaterial2_SetMaterial(LPDIRECT3DMATERIAL2 this,
156 TRACE(ddraw, "(%p)->(%p)\n", this, lpMat);
158 dump_material(lpMat);
160 /* Stores the material */
166 static HRESULT WINAPI IDirect3DMaterial2_GetHandle(LPDIRECT3DMATERIAL2 this,
167 LPDIRECT3DDEVICE2 lpD3DDevice2,
168 LPD3DMATERIALHANDLE lpMatHandle)
171 FIXME(ddraw, "(%p)->(%p,%p): stub\n", this, lpD3DDevice2, lpMatHandle);
174 this->device.active_device2 = lpD3DDevice2;
176 this->device.active_device1 = (LPDIRECT3DDEVICE) lpD3DDevice2;
178 *lpMatHandle = (DWORD) this; /* lpD3DDevice2->store_material(this); */
183 static HRESULT WINAPI IDirect3DMaterial_Reserve(LPDIRECT3DMATERIAL this)
185 FIXME(ddraw, "(%p)->(): stub\n", this);
187 return DDERR_INVALIDPARAMS;
190 static HRESULT WINAPI IDirect3DMaterial_Unreserve(LPDIRECT3DMATERIAL this)
192 FIXME(ddraw, "(%p)->(): stub\n", this);
194 return DDERR_INVALIDPARAMS;
197 static HRESULT WINAPI IDirect3DMaterial_Initialize(LPDIRECT3DMATERIAL this,
198 LPDIRECT3D lpDirect3D)
201 TRACE(ddraw, "(%p)->(%p)\n", this, lpDirect3D);
203 return DDERR_ALREADYINITIALIZED;
207 /*******************************************************************************
208 * IDirect3DMaterial VTable
210 static IDirect3DMaterial_VTable material_vtable = {
211 /*** IUnknown methods ***/
212 IDirect3DMaterial2_QueryInterface,
213 IDirect3DMaterial2_AddRef,
214 IDirect3DMaterial2_Release,
215 /*** IDirect3DMaterial methods ***/
216 IDirect3DMaterial_Initialize,
217 IDirect3DMaterial2_SetMaterial,
218 IDirect3DMaterial2_GetMaterial,
219 IDirect3DMaterial2_GetHandle,
220 IDirect3DMaterial_Reserve,
221 IDirect3DMaterial_Unreserve
225 /*******************************************************************************
226 * IDirect3DMaterial2 VTable
228 static IDirect3DMaterial2_VTable material2_vtable = {
229 /*** IUnknown methods ***/
230 IDirect3DMaterial2_QueryInterface,
231 IDirect3DMaterial2_AddRef,
232 IDirect3DMaterial2_Release,
233 /*** IDirect3DMaterial methods ***/
234 IDirect3DMaterial2_SetMaterial,
235 IDirect3DMaterial2_GetMaterial,
236 IDirect3DMaterial2_GetHandle
239 #else /* HAVE_MESAGL */
241 LPDIRECT3DMATERIAL d3dmaterial_create(LPDIRECT3D d3d) {
242 ERR(ddraw, "Should not be called...\n");
246 LPDIRECT3DMATERIAL2 d3dmaterial2_create(LPDIRECT3D2 d3d) {
247 ERR(ddraw, "Should not be called...\n");
252 #endif /* HAVE_MESAGL */