VxDCall functions do not need to be 'register'.
[wine/multimedia.git] / graphics / d3dmaterial.c
blob86fd96b26aa68bf8a155bc4f88ef4d97595f9730
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 "debug.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(ddraw, "Activating material %p\n", This);
30 /* First, set the rendering context */
31 if (This->use_d3d2)
32 This->device.active_device2->set_context(This->device.active_device2);
33 else
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,
39 GL_DIFFUSE,
40 (float *) &(This->mat.a.diffuse));
41 _dump_colorvalue("Ambient", This->mat.b.ambient);
42 glMaterialfv(GL_FRONT,
43 GL_AMBIENT,
44 (float *) &(This->mat.b.ambient));
45 _dump_colorvalue("Specular", This->mat.c.specular);
46 glMaterialfv(GL_FRONT,
47 GL_SPECULAR,
48 (float *) &(This->mat.c.specular));
49 _dump_colorvalue("Emissive", This->mat.d.emissive);
50 glMaterialfv(GL_FRONT,
51 GL_EMISSION,
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);
59 return ;
62 /*******************************************************************************
63 * Matrial2 Creation functions
65 LPDIRECT3DMATERIAL2 d3dmaterial2_create(IDirect3D2Impl* d3d2)
67 IDirect3DMaterial2Impl* mat;
69 mat = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirect3DMaterial2Impl));
70 mat->ref = 1;
71 mat->lpvtbl = &material2_vtable;
73 mat->use_d3d2 = 1;
74 mat->d3d.d3d2 = d3d2;
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));
86 mat->ref = 1;
87 mat->lpvtbl = (ICOM_VTABLE(IDirect3DMaterial2)*)&material_vtable;
89 mat->use_d3d2 = 0;
90 mat->d3d.d3d1 = d3d1;
92 mat->activate = activate;
94 return (LPDIRECT3DMATERIAL) mat;
97 /*******************************************************************************
98 * IDirect3DMaterial2 methods
101 static HRESULT WINAPI IDirect3DMaterial2Impl_QueryInterface(LPDIRECT3DMATERIAL2 iface,
102 REFIID riid,
103 LPVOID* ppvObj)
105 ICOM_THIS(IDirect3DMaterial2Impl,iface);
106 char xrefiid[50];
108 WINE_StringFromCLSID((LPCLSID)riid,xrefiid);
109 FIXME(ddraw, "(%p)->(%s,%p): stub\n", This, xrefiid,ppvObj);
111 return S_OK;
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);
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(ddraw, "(%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(ddraw, "(%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(ddraw, "(%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(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");
254 return NULL;
257 LPDIRECT3DMATERIAL2 d3dmaterial2_create(IDirect3D2Impl* d3d2) {
258 ERR(ddraw, "Should not be called...\n");
259 return NULL;
263 #endif /* HAVE_MESAGL */