Fixed unconditional use of JOYDEV.
[wine/wine64.git] / graphics / d3dmaterial.c
blobee88f8d57ea12b2f20a4347404c9bd9de1db7589
1 /* Direct3D Material
2 (c) 1998 Lionel ULMER
4 This files contains the implementation of Direct3DMaterial2. */
6 #include "config.h"
7 #include "windef.h"
8 #include "winerror.h"
9 #include "wine/obj_base.h"
10 #include "heap.h"
11 #include "ddraw.h"
12 #include "d3d.h"
13 #include "debugtools.h"
15 #include "d3d_private.h"
17 DEFAULT_DEBUG_CHANNEL(ddraw)
19 #ifdef HAVE_MESAGL
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);
30 ENTER_GL();
31 /* First, set the rendering context */
32 if (This->use_d3d2)
33 This->device.active_device2->set_context(This->device.active_device2);
34 else
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,
40 GL_DIFFUSE,
41 (float *) &(This->mat.a.diffuse));
42 _dump_colorvalue("Ambient", This->mat.b.ambient);
43 glMaterialfv(GL_FRONT,
44 GL_AMBIENT,
45 (float *) &(This->mat.b.ambient));
46 _dump_colorvalue("Specular", This->mat.c.specular);
47 glMaterialfv(GL_FRONT,
48 GL_SPECULAR,
49 (float *) &(This->mat.c.specular));
50 _dump_colorvalue("Emissive", This->mat.d.emissive);
51 glMaterialfv(GL_FRONT,
52 GL_EMISSION,
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);
59 LEAVE_GL();
61 return ;
64 /*******************************************************************************
65 * Matrial2 Creation functions
67 LPDIRECT3DMATERIAL2 d3dmaterial2_create(IDirect3D2Impl* d3d2)
69 IDirect3DMaterial2Impl* mat;
71 mat = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirect3DMaterial2Impl));
72 mat->ref = 1;
73 ICOM_VTBL(mat) = &material2_vtable;
75 mat->use_d3d2 = 1;
76 mat->d3d.d3d2 = d3d2;
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));
88 mat->ref = 1;
89 ICOM_VTBL(mat) = (ICOM_VTABLE(IDirect3DMaterial2)*)&material_vtable;
91 mat->use_d3d2 = 0;
92 mat->d3d.d3d1 = d3d1;
94 mat->activate = activate;
96 return (LPDIRECT3DMATERIAL) mat;
99 /*******************************************************************************
100 * IDirect3DMaterial2 methods
103 static HRESULT WINAPI IDirect3DMaterial2Impl_QueryInterface(LPDIRECT3DMATERIAL2 iface,
104 REFIID riid,
105 LPVOID* ppvObj)
107 ICOM_THIS(IDirect3DMaterial2Impl,iface);
109 FIXME("(%p)->(%s,%p): stub\n", This, debugstr_guid(riid),ppvObj);
111 return S_OK;
116 static ULONG WINAPI IDirect3DMaterial2Impl_AddRef(LPDIRECT3DMATERIAL2 iface)
118 ICOM_THIS(IDirect3DMaterial2Impl,iface);
119 TRACE("(%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("(%p)->() decrementing from %lu.\n", This, This->ref );
131 if (!--(This->ref)) {
132 HeapFree(GetProcessHeap(),0,This);
133 return 0;
136 return This->ref;
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,
146 LPD3DMATERIAL lpMat)
148 ICOM_THIS(IDirect3DMaterial2Impl,iface);
149 TRACE("(%p)->(%p)\n", This, lpMat);
150 if (TRACE_ON(ddraw))
151 dump_material(lpMat);
153 /* Copies the material structure */
154 *lpMat = This->mat;
156 return DD_OK;
159 static HRESULT WINAPI IDirect3DMaterial2Impl_SetMaterial(LPDIRECT3DMATERIAL2 iface,
160 LPD3DMATERIAL lpMat)
162 ICOM_THIS(IDirect3DMaterial2Impl,iface);
163 TRACE("(%p)->(%p)\n", This, lpMat);
164 if (TRACE_ON(ddraw))
165 dump_material(lpMat);
167 /* Stores the material */
168 This->mat = *lpMat;
170 return DD_OK;
173 static HRESULT WINAPI IDirect3DMaterial2Impl_GetHandle(LPDIRECT3DMATERIAL2 iface,
174 LPDIRECT3DDEVICE2 lpD3DDevice2,
175 LPD3DMATERIALHANDLE lpMatHandle)
178 ICOM_THIS(IDirect3DMaterial2Impl,iface);
179 FIXME("(%p)->(%p,%p): stub\n", This, lpD3DDevice2, lpMatHandle);
181 if (This->use_d3d2)
182 This->device.active_device2 = (IDirect3DDevice2Impl*)lpD3DDevice2;
183 else
184 This->device.active_device1 = (IDirect3DDeviceImpl*)lpD3DDevice2;
186 *lpMatHandle = (DWORD) This; /* lpD3DDevice2->store_material(This); */
188 return DD_OK;
191 static HRESULT WINAPI IDirect3DMaterialImpl_Reserve(LPDIRECT3DMATERIAL iface)
193 ICOM_THIS(IDirect3DMaterial2Impl,iface);
194 FIXME("(%p)->(): stub\n", This);
196 return DDERR_INVALIDPARAMS;
199 static HRESULT WINAPI IDirect3DMaterialImpl_Unreserve(LPDIRECT3DMATERIAL iface)
201 ICOM_THIS(IDirect3DMaterial2Impl,iface);
202 FIXME("(%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("(%p)->(%p)\n", This, lpDirect3D);
214 return DDERR_ALREADYINITIALIZED;
218 /*******************************************************************************
219 * IDirect3DMaterial VTable
221 static ICOM_VTABLE(IDirect3DMaterial) material_vtable =
223 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
224 /*** IUnknown methods ***/
225 IDirect3DMaterial2Impl_QueryInterface,
226 IDirect3DMaterial2Impl_AddRef,
227 IDirect3DMaterial2Impl_Release,
228 /*** IDirect3DMaterial methods ***/
229 IDirect3DMaterialImpl_Initialize,
230 IDirect3DMaterial2Impl_SetMaterial,
231 IDirect3DMaterial2Impl_GetMaterial,
232 IDirect3DMaterial2Impl_GetHandle,
233 IDirect3DMaterialImpl_Reserve,
234 IDirect3DMaterialImpl_Unreserve
238 /*******************************************************************************
239 * IDirect3DMaterial2 VTable
241 static ICOM_VTABLE(IDirect3DMaterial2) material2_vtable =
243 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
244 /*** IUnknown methods ***/
245 IDirect3DMaterial2Impl_QueryInterface,
246 IDirect3DMaterial2Impl_AddRef,
247 IDirect3DMaterial2Impl_Release,
248 /*** IDirect3DMaterial methods ***/
249 IDirect3DMaterial2Impl_SetMaterial,
250 IDirect3DMaterial2Impl_GetMaterial,
251 IDirect3DMaterial2Impl_GetHandle
254 #else /* HAVE_MESAGL */
256 LPDIRECT3DMATERIAL d3dmaterial_create(IDirect3DImpl* d3d1) {
257 ERR("Should not be called...\n");
258 return NULL;
261 LPDIRECT3DMATERIAL2 d3dmaterial2_create(IDirect3D2Impl* d3d2) {
262 ERR("Should not be called...\n");
263 return NULL;
267 #endif /* HAVE_MESAGL */