Fixed error messages.
[wine/dcerpc.git] / graphics / d3dmaterial.c
bloba40deb9290817e02e9a2222265cd6a664aac67cb
1 /* Direct3D Material
2 (c) 1998 Lionel ULMER
4 This files contains the implementation of Direct3DMaterial2. */
6 #include "config.h"
7 #include "windows.h"
8 #include "wintypes.h"
9 #include "winerror.h"
10 #include "interfaces.h"
11 #include "heap.h"
12 #include "ddraw.h"
13 #include "d3d.h"
14 #include "debug.h"
16 #include "d3d_private.h"
18 #ifdef HAVE_MESAGL
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 */
30 if (this->use_d3d2)
31 this->device.active_device2->set_context(this->device.active_device2);
32 else
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,
38 GL_DIFFUSE,
39 (float *) &(this->mat.a.diffuse));
40 _dump_colorvalue("Ambient", this->mat.b.ambient);
41 glMaterialfv(GL_FRONT,
42 GL_AMBIENT,
43 (float *) &(this->mat.b.ambient));
44 _dump_colorvalue("Specular", this->mat.c.specular);
45 glMaterialfv(GL_FRONT,
46 GL_SPECULAR,
47 (float *) &(this->mat.c.specular));
48 _dump_colorvalue("Emissive", this->mat.d.emissive);
49 glMaterialfv(GL_FRONT,
50 GL_EMISSION,
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);
58 return ;
61 /*******************************************************************************
62 * Matrial2 Creation functions
64 LPDIRECT3DMATERIAL2 d3dmaterial2_create(LPDIRECT3D2 d3d)
66 LPDIRECT3DMATERIAL2 mat;
68 mat = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirect3DMaterial2));
69 mat->ref = 1;
70 mat->lpvtbl = &material2_vtable;
72 mat->use_d3d2 = 1;
73 mat->d3d.d3d2 = d3d;
75 mat->activate = activate;
77 return mat;
80 LPDIRECT3DMATERIAL d3dmaterial_create(LPDIRECT3D d3d)
82 LPDIRECT3DMATERIAL2 mat;
84 mat = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirect3DMaterial2));
85 mat->ref = 1;
86 mat->lpvtbl = (LPDIRECT3DMATERIAL2_VTABLE) &material_vtable;
88 mat->use_d3d2 = 0;
89 mat->d3d.d3d1 = d3d;
91 mat->activate = activate;
93 return (LPDIRECT3DMATERIAL) mat;
96 /*******************************************************************************
97 * IDirect3DMaterial2 methods
100 static HRESULT WINAPI IDirect3DMaterial2_QueryInterface(LPDIRECT3DMATERIAL2 this,
101 REFIID riid,
102 LPVOID* ppvObj)
104 char xrefiid[50];
106 WINE_StringFromCLSID((LPCLSID)riid,xrefiid);
107 FIXME(ddraw, "(%p)->(%s,%p): stub\n", this, xrefiid,ppvObj);
109 return S_OK;
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);
129 return 0;
132 return this->ref;
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,
142 LPD3DMATERIAL lpMat)
144 TRACE(ddraw, "(%p)->(%p)\n", this, lpMat);
145 if (TRACE_ON(ddraw))
146 dump_material(lpMat);
148 /* Copies the material structure */
149 *lpMat = this->mat;
151 return DD_OK;
154 static HRESULT WINAPI IDirect3DMaterial2_SetMaterial(LPDIRECT3DMATERIAL2 this,
155 LPD3DMATERIAL lpMat)
157 TRACE(ddraw, "(%p)->(%p)\n", this, lpMat);
158 if (TRACE_ON(ddraw))
159 dump_material(lpMat);
161 /* Stores the material */
162 this->mat = *lpMat;
164 return DD_OK;
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);
174 if (this->use_d3d2)
175 this->device.active_device2 = lpD3DDevice2;
176 else
177 this->device.active_device1 = (LPDIRECT3DDEVICE) lpD3DDevice2;
179 *lpMatHandle = (DWORD) this; /* lpD3DDevice2->store_material(this); */
181 return DD_OK;
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");
244 return NULL;
247 LPDIRECT3DMATERIAL2 d3dmaterial2_create(LPDIRECT3D2 d3d) {
248 ERR(ddraw, "Should not be called...\n");
249 return NULL;
253 #endif /* HAVE_MESAGL */