4 This files contains the implementation of Direct3DMaterial2. */
10 #include "interfaces.h"
16 #include "d3d_private.h"
20 static IDirect3DMaterial2_VTable material2_vtable;
21 static IDirect3DMaterial_VTable material_vtable;
23 /*******************************************************************************
24 * Matrial2 static functions
26 static void activate(LPDIRECT3DMATERIAL2 this) {
27 TRACE(ddraw, "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(ddraw, "Size : %ld\n", this->mat.dwSize);
54 TRACE(ddraw, "Power : %f\n", this->mat.e.power);
56 TRACE(ddraw, "Texture handle : %ld\n", (DWORD)this->mat.hTexture);
61 /*******************************************************************************
62 * Matrial2 Creation functions
64 LPDIRECT3DMATERIAL2 d3dmaterial2_create(LPDIRECT3D2 d3d)
66 LPDIRECT3DMATERIAL2 mat;
68 mat = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirect3DMaterial2));
70 mat->lpvtbl = &material2_vtable;
75 mat->activate = activate;
80 LPDIRECT3DMATERIAL d3dmaterial_create(LPDIRECT3D d3d)
82 LPDIRECT3DMATERIAL2 mat;
84 mat = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirect3DMaterial2));
86 mat->lpvtbl = (LPDIRECT3DMATERIAL2_VTABLE) &material_vtable;
91 mat->activate = activate;
93 return (LPDIRECT3DMATERIAL) mat;
96 /*******************************************************************************
97 * IDirect3DMaterial2 methods
100 static HRESULT WINAPI IDirect3DMaterial2_QueryInterface(LPDIRECT3DMATERIAL2 this,
106 WINE_StringFromCLSID((LPCLSID)riid,xrefiid);
107 FIXME(ddraw, "(%p)->(%s,%p): stub\n", this, xrefiid,ppvObj);
114 static ULONG WINAPI IDirect3DMaterial2_AddRef(LPDIRECT3DMATERIAL2 this)
116 TRACE(ddraw, "(%p)->()incrementing from %lu.\n", this, this->ref );
118 return ++(this->ref);
123 static ULONG WINAPI IDirect3DMaterial2_Release(LPDIRECT3DMATERIAL2 this)
125 FIXME( ddraw, "(%p)->() decrementing from %lu.\n", this, this->ref );
127 if (!--(this->ref)) {
128 HeapFree(GetProcessHeap(),0,this);
135 /*** IDirect3DMaterial2 methods ***/
136 static void dump_material(LPD3DMATERIAL mat)
138 fprintf(stderr, " dwSize : %ld\n", mat->dwSize);
141 static HRESULT WINAPI IDirect3DMaterial2_GetMaterial(LPDIRECT3DMATERIAL2 this,
144 TRACE(ddraw, "(%p)->(%p)\n", this, lpMat);
146 dump_material(lpMat);
148 /* Copies the material structure */
154 static HRESULT WINAPI IDirect3DMaterial2_SetMaterial(LPDIRECT3DMATERIAL2 this,
157 TRACE(ddraw, "(%p)->(%p)\n", this, lpMat);
159 dump_material(lpMat);
161 /* Stores the material */
167 static HRESULT WINAPI IDirect3DMaterial2_GetHandle(LPDIRECT3DMATERIAL2 this,
168 LPDIRECT3DDEVICE2 lpD3DDevice2,
169 LPD3DMATERIALHANDLE lpMatHandle)
172 FIXME(ddraw, "(%p)->(%p,%p): stub\n", this, lpD3DDevice2, lpMatHandle);
175 this->device.active_device2 = lpD3DDevice2;
177 this->device.active_device1 = (LPDIRECT3DDEVICE) lpD3DDevice2;
179 *lpMatHandle = (DWORD) this; /* lpD3DDevice2->store_material(this); */
184 static HRESULT WINAPI IDirect3DMaterial_Reserve(LPDIRECT3DMATERIAL this)
186 FIXME(ddraw, "(%p)->(): stub\n", this);
188 return DDERR_INVALIDPARAMS;
191 static HRESULT WINAPI IDirect3DMaterial_Unreserve(LPDIRECT3DMATERIAL this)
193 FIXME(ddraw, "(%p)->(): stub\n", this);
195 return DDERR_INVALIDPARAMS;
198 static HRESULT WINAPI IDirect3DMaterial_Initialize(LPDIRECT3DMATERIAL this,
199 LPDIRECT3D lpDirect3D)
202 TRACE(ddraw, "(%p)->(%p)\n", this, lpDirect3D);
204 return DDERR_ALREADYINITIALIZED;
208 /*******************************************************************************
209 * IDirect3DMaterial VTable
211 static IDirect3DMaterial_VTable material_vtable = {
212 /*** IUnknown methods ***/
213 IDirect3DMaterial2_QueryInterface,
214 IDirect3DMaterial2_AddRef,
215 IDirect3DMaterial2_Release,
216 /*** IDirect3DMaterial methods ***/
217 IDirect3DMaterial_Initialize,
218 IDirect3DMaterial2_SetMaterial,
219 IDirect3DMaterial2_GetMaterial,
220 IDirect3DMaterial2_GetHandle,
221 IDirect3DMaterial_Reserve,
222 IDirect3DMaterial_Unreserve
226 /*******************************************************************************
227 * IDirect3DMaterial2 VTable
229 static IDirect3DMaterial2_VTable material2_vtable = {
230 /*** IUnknown methods ***/
231 IDirect3DMaterial2_QueryInterface,
232 IDirect3DMaterial2_AddRef,
233 IDirect3DMaterial2_Release,
234 /*** IDirect3DMaterial methods ***/
235 IDirect3DMaterial2_SetMaterial,
236 IDirect3DMaterial2_GetMaterial,
237 IDirect3DMaterial2_GetHandle
240 #else /* HAVE_MESAGL */
242 LPDIRECT3DMATERIAL d3dmaterial_create(LPDIRECT3D d3d) {
243 ERR(ddraw, "Should not be called...\n");
247 LPDIRECT3DMATERIAL2 d3dmaterial2_create(LPDIRECT3D2 d3d) {
248 ERR(ddraw, "Should not be called...\n");
253 #endif /* HAVE_MESAGL */