4 This files contains the implementation of Direct3DMaterial2. */
10 #include "wine/obj_base.h"
17 #include "d3d_private.h"
21 static IDirect3DMaterial2_VTable material2_vtable;
22 static IDirect3DMaterial_VTable material_vtable;
24 /*******************************************************************************
25 * Matrial2 static functions
27 static void activate(LPDIRECT3DMATERIAL2 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(LPDIRECT3D2 d3d)
67 LPDIRECT3DMATERIAL2 mat;
69 mat = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirect3DMaterial2));
71 mat->lpvtbl = &material2_vtable;
76 mat->activate = activate;
81 LPDIRECT3DMATERIAL d3dmaterial_create(LPDIRECT3D d3d)
83 LPDIRECT3DMATERIAL2 mat;
85 mat = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirect3DMaterial2));
87 mat->lpvtbl = (LPDIRECT3DMATERIAL2_VTABLE) &material_vtable;
92 mat->activate = activate;
94 return (LPDIRECT3DMATERIAL) mat;
97 /*******************************************************************************
98 * IDirect3DMaterial2 methods
101 static HRESULT WINAPI IDirect3DMaterial2_QueryInterface(LPDIRECT3DMATERIAL2 this,
107 WINE_StringFromCLSID((LPCLSID)riid,xrefiid);
108 FIXME(ddraw, "(%p)->(%s,%p): stub\n", this, xrefiid,ppvObj);
115 static ULONG WINAPI IDirect3DMaterial2_AddRef(LPDIRECT3DMATERIAL2 this)
117 TRACE(ddraw, "(%p)->()incrementing from %lu.\n", this, this->ref );
119 return ++(this->ref);
124 static ULONG WINAPI IDirect3DMaterial2_Release(LPDIRECT3DMATERIAL2 this)
126 FIXME( ddraw, "(%p)->() decrementing from %lu.\n", this, this->ref );
128 if (!--(this->ref)) {
129 HeapFree(GetProcessHeap(),0,this);
136 /*** IDirect3DMaterial2 methods ***/
137 static void dump_material(LPD3DMATERIAL mat)
139 fprintf(stderr, " dwSize : %ld\n", mat->dwSize);
142 static HRESULT WINAPI IDirect3DMaterial2_GetMaterial(LPDIRECT3DMATERIAL2 this,
145 TRACE(ddraw, "(%p)->(%p)\n", this, lpMat);
147 dump_material(lpMat);
149 /* Copies the material structure */
155 static HRESULT WINAPI IDirect3DMaterial2_SetMaterial(LPDIRECT3DMATERIAL2 this,
158 TRACE(ddraw, "(%p)->(%p)\n", this, lpMat);
160 dump_material(lpMat);
162 /* Stores the material */
168 static HRESULT WINAPI IDirect3DMaterial2_GetHandle(LPDIRECT3DMATERIAL2 this,
169 LPDIRECT3DDEVICE2 lpD3DDevice2,
170 LPD3DMATERIALHANDLE lpMatHandle)
173 FIXME(ddraw, "(%p)->(%p,%p): stub\n", this, lpD3DDevice2, lpMatHandle);
176 this->device.active_device2 = lpD3DDevice2;
178 this->device.active_device1 = (LPDIRECT3DDEVICE) lpD3DDevice2;
180 *lpMatHandle = (DWORD) this; /* lpD3DDevice2->store_material(this); */
185 static HRESULT WINAPI IDirect3DMaterial_Reserve(LPDIRECT3DMATERIAL this)
187 FIXME(ddraw, "(%p)->(): stub\n", this);
189 return DDERR_INVALIDPARAMS;
192 static HRESULT WINAPI IDirect3DMaterial_Unreserve(LPDIRECT3DMATERIAL this)
194 FIXME(ddraw, "(%p)->(): stub\n", this);
196 return DDERR_INVALIDPARAMS;
199 static HRESULT WINAPI IDirect3DMaterial_Initialize(LPDIRECT3DMATERIAL this,
200 LPDIRECT3D lpDirect3D)
203 TRACE(ddraw, "(%p)->(%p)\n", this, lpDirect3D);
205 return DDERR_ALREADYINITIALIZED;
209 /*******************************************************************************
210 * IDirect3DMaterial VTable
212 static IDirect3DMaterial_VTable material_vtable = {
213 /*** IUnknown methods ***/
214 IDirect3DMaterial2_QueryInterface,
215 IDirect3DMaterial2_AddRef,
216 IDirect3DMaterial2_Release,
217 /*** IDirect3DMaterial methods ***/
218 IDirect3DMaterial_Initialize,
219 IDirect3DMaterial2_SetMaterial,
220 IDirect3DMaterial2_GetMaterial,
221 IDirect3DMaterial2_GetHandle,
222 IDirect3DMaterial_Reserve,
223 IDirect3DMaterial_Unreserve
227 /*******************************************************************************
228 * IDirect3DMaterial2 VTable
230 static IDirect3DMaterial2_VTable material2_vtable = {
231 /*** IUnknown methods ***/
232 IDirect3DMaterial2_QueryInterface,
233 IDirect3DMaterial2_AddRef,
234 IDirect3DMaterial2_Release,
235 /*** IDirect3DMaterial methods ***/
236 IDirect3DMaterial2_SetMaterial,
237 IDirect3DMaterial2_GetMaterial,
238 IDirect3DMaterial2_GetHandle
241 #else /* HAVE_MESAGL */
243 LPDIRECT3DMATERIAL d3dmaterial_create(LPDIRECT3D d3d) {
244 ERR(ddraw, "Should not be called...\n");
248 LPDIRECT3DMATERIAL2 d3dmaterial2_create(LPDIRECT3D2 d3d) {
249 ERR(ddraw, "Should not be called...\n");
254 #endif /* HAVE_MESAGL */