1999-01-03 18:00:19 +01:00
|
|
|
/* Direct3D Material
|
|
|
|
(c) 1998 Lionel ULMER
|
|
|
|
|
|
|
|
This files contains the implementation of Direct3DMaterial2. */
|
|
|
|
|
|
|
|
#include "config.h"
|
1999-03-14 17:35:05 +01:00
|
|
|
#include "windef.h"
|
1999-01-03 18:00:19 +01:00
|
|
|
#include "winerror.h"
|
1999-02-02 17:14:23 +01:00
|
|
|
#include "wine/obj_base.h"
|
1999-01-03 18:00:19 +01:00
|
|
|
#include "ddraw.h"
|
|
|
|
#include "d3d.h"
|
1999-06-26 21:09:08 +02:00
|
|
|
#include "debugtools.h"
|
1999-01-03 18:00:19 +01:00
|
|
|
|
2000-04-09 16:30:50 +02:00
|
|
|
#include "mesa_private.h"
|
1999-01-03 18:00:19 +01:00
|
|
|
|
2000-11-28 00:54:25 +01:00
|
|
|
DEFAULT_DEBUG_CHANNEL(ddraw);
|
1999-04-19 16:56:29 +02:00
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
static ICOM_VTABLE(IDirect3DMaterial2) material2_vtable;
|
|
|
|
static ICOM_VTABLE(IDirect3DMaterial) material_vtable;
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* Matrial2 static functions
|
|
|
|
*/
|
1999-03-27 17:56:13 +01:00
|
|
|
static void activate(IDirect3DMaterial2Impl* This) {
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("Activating material %p\n", This);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
1999-05-13 20:53:05 +02:00
|
|
|
ENTER_GL();
|
1999-01-03 18:00:19 +01:00
|
|
|
/* First, set the rendering context */
|
1999-03-27 17:56:13 +01:00
|
|
|
if (This->use_d3d2)
|
|
|
|
This->device.active_device2->set_context(This->device.active_device2);
|
1999-01-03 18:00:19 +01:00
|
|
|
else
|
1999-03-27 17:56:13 +01:00
|
|
|
This->device.active_device1->set_context(This->device.active_device1);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
/* Set the current Material */
|
2000-12-03 04:16:05 +01:00
|
|
|
_dump_colorvalue("Diffuse", This->mat.u.diffuse);
|
1999-01-03 18:00:19 +01:00
|
|
|
glMaterialfv(GL_FRONT,
|
|
|
|
GL_DIFFUSE,
|
2000-12-03 04:16:05 +01:00
|
|
|
(float *) &(This->mat.u.diffuse));
|
|
|
|
_dump_colorvalue("Ambient", This->mat.u1.ambient);
|
1999-01-03 18:00:19 +01:00
|
|
|
glMaterialfv(GL_FRONT,
|
|
|
|
GL_AMBIENT,
|
2000-12-03 04:16:05 +01:00
|
|
|
(float *) &(This->mat.u1.ambient));
|
|
|
|
_dump_colorvalue("Specular", This->mat.u2.specular);
|
1999-01-03 18:00:19 +01:00
|
|
|
glMaterialfv(GL_FRONT,
|
|
|
|
GL_SPECULAR,
|
2000-12-03 04:16:05 +01:00
|
|
|
(float *) &(This->mat.u2.specular));
|
|
|
|
_dump_colorvalue("Emissive", This->mat.u3.emissive);
|
1999-01-03 18:00:19 +01:00
|
|
|
glMaterialfv(GL_FRONT,
|
|
|
|
GL_EMISSION,
|
2000-12-03 04:16:05 +01:00
|
|
|
(float *) &(This->mat.u3.emissive));
|
1999-01-03 18:00:19 +01:00
|
|
|
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("Size : %ld\n", This->mat.dwSize);
|
2000-12-03 04:16:05 +01:00
|
|
|
TRACE("Power : %f\n", This->mat.u4.power);
|
1999-01-23 13:33:16 +01:00
|
|
|
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("Texture handle : %08lx\n", (DWORD)This->mat.hTexture);
|
1999-05-13 20:53:05 +02:00
|
|
|
LEAVE_GL();
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
return ;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* Matrial2 Creation functions
|
|
|
|
*/
|
1999-03-27 17:56:13 +01:00
|
|
|
LPDIRECT3DMATERIAL2 d3dmaterial2_create(IDirect3D2Impl* d3d2)
|
1999-01-03 18:00:19 +01:00
|
|
|
{
|
1999-03-27 17:56:13 +01:00
|
|
|
IDirect3DMaterial2Impl* mat;
|
1999-01-03 18:00:19 +01:00
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
mat = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirect3DMaterial2Impl));
|
1999-01-03 18:00:19 +01:00
|
|
|
mat->ref = 1;
|
1999-10-31 02:59:23 +01:00
|
|
|
ICOM_VTBL(mat) = &material2_vtable;
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
mat->use_d3d2 = 1;
|
1999-03-27 17:56:13 +01:00
|
|
|
mat->d3d.d3d2 = d3d2;
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
mat->activate = activate;
|
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
return (LPDIRECT3DMATERIAL2)mat;
|
1999-01-03 18:00:19 +01:00
|
|
|
}
|
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
LPDIRECT3DMATERIAL d3dmaterial_create(IDirect3DImpl* d3d1)
|
1999-01-03 18:00:19 +01:00
|
|
|
{
|
1999-03-27 17:56:13 +01:00
|
|
|
IDirect3DMaterial2Impl* mat;
|
1999-01-03 18:00:19 +01:00
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
mat = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirect3DMaterial2Impl));
|
1999-01-03 18:00:19 +01:00
|
|
|
mat->ref = 1;
|
1999-10-31 02:59:23 +01:00
|
|
|
ICOM_VTBL(mat) = (ICOM_VTABLE(IDirect3DMaterial2)*)&material_vtable;
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
mat->use_d3d2 = 0;
|
1999-03-27 17:56:13 +01:00
|
|
|
mat->d3d.d3d1 = d3d1;
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
mat->activate = activate;
|
|
|
|
|
|
|
|
return (LPDIRECT3DMATERIAL) mat;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* IDirect3DMaterial2 methods
|
|
|
|
*/
|
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
static HRESULT WINAPI IDirect3DMaterial2Impl_QueryInterface(LPDIRECT3DMATERIAL2 iface,
|
1999-01-03 18:00:19 +01:00
|
|
|
REFIID riid,
|
|
|
|
LPVOID* ppvObj)
|
|
|
|
{
|
1999-03-27 17:56:13 +01:00
|
|
|
ICOM_THIS(IDirect3DMaterial2Impl,iface);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
2000-01-18 06:09:49 +01:00
|
|
|
FIXME("(%p)->(%s,%p): stub\n", This, debugstr_guid(riid),ppvObj);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
static ULONG WINAPI IDirect3DMaterial2Impl_AddRef(LPDIRECT3DMATERIAL2 iface)
|
1999-01-03 18:00:19 +01:00
|
|
|
{
|
1999-03-27 17:56:13 +01:00
|
|
|
ICOM_THIS(IDirect3DMaterial2Impl,iface);
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("(%p)->()incrementing from %lu.\n", This, This->ref );
|
1999-01-03 18:00:19 +01:00
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
return ++(This->ref);
|
1999-01-03 18:00:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
static ULONG WINAPI IDirect3DMaterial2Impl_Release(LPDIRECT3DMATERIAL2 iface)
|
1999-01-03 18:00:19 +01:00
|
|
|
{
|
1999-03-27 17:56:13 +01:00
|
|
|
ICOM_THIS(IDirect3DMaterial2Impl,iface);
|
1999-06-26 21:09:08 +02:00
|
|
|
FIXME("(%p)->() decrementing from %lu.\n", This, This->ref );
|
1999-01-03 18:00:19 +01:00
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
if (!--(This->ref)) {
|
|
|
|
HeapFree(GetProcessHeap(),0,This);
|
1999-01-03 18:00:19 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
return This->ref;
|
1999-01-03 18:00:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*** IDirect3DMaterial2 methods ***/
|
|
|
|
static void dump_material(LPD3DMATERIAL mat)
|
|
|
|
{
|
2000-02-12 14:20:20 +01:00
|
|
|
DPRINTF(" dwSize : %ld\n", mat->dwSize);
|
1999-01-03 18:00:19 +01:00
|
|
|
}
|
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
static HRESULT WINAPI IDirect3DMaterial2Impl_GetMaterial(LPDIRECT3DMATERIAL2 iface,
|
1999-01-03 18:00:19 +01:00
|
|
|
LPD3DMATERIAL lpMat)
|
|
|
|
{
|
1999-03-27 17:56:13 +01:00
|
|
|
ICOM_THIS(IDirect3DMaterial2Impl,iface);
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("(%p)->(%p)\n", This, lpMat);
|
1999-01-03 18:00:19 +01:00
|
|
|
if (TRACE_ON(ddraw))
|
|
|
|
dump_material(lpMat);
|
|
|
|
|
|
|
|
/* Copies the material structure */
|
1999-03-27 17:56:13 +01:00
|
|
|
*lpMat = This->mat;
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
static HRESULT WINAPI IDirect3DMaterial2Impl_SetMaterial(LPDIRECT3DMATERIAL2 iface,
|
1999-01-03 18:00:19 +01:00
|
|
|
LPD3DMATERIAL lpMat)
|
|
|
|
{
|
1999-03-27 17:56:13 +01:00
|
|
|
ICOM_THIS(IDirect3DMaterial2Impl,iface);
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("(%p)->(%p)\n", This, lpMat);
|
1999-01-03 18:00:19 +01:00
|
|
|
if (TRACE_ON(ddraw))
|
|
|
|
dump_material(lpMat);
|
|
|
|
|
|
|
|
/* Stores the material */
|
1999-03-27 17:56:13 +01:00
|
|
|
This->mat = *lpMat;
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
static HRESULT WINAPI IDirect3DMaterial2Impl_GetHandle(LPDIRECT3DMATERIAL2 iface,
|
1999-01-03 18:00:19 +01:00
|
|
|
LPDIRECT3DDEVICE2 lpD3DDevice2,
|
|
|
|
LPD3DMATERIALHANDLE lpMatHandle)
|
|
|
|
|
|
|
|
{
|
1999-03-27 17:56:13 +01:00
|
|
|
ICOM_THIS(IDirect3DMaterial2Impl,iface);
|
1999-06-26 21:09:08 +02:00
|
|
|
FIXME("(%p)->(%p,%p): stub\n", This, lpD3DDevice2, lpMatHandle);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
if (This->use_d3d2)
|
|
|
|
This->device.active_device2 = (IDirect3DDevice2Impl*)lpD3DDevice2;
|
1999-01-03 18:00:19 +01:00
|
|
|
else
|
1999-03-27 17:56:13 +01:00
|
|
|
This->device.active_device1 = (IDirect3DDeviceImpl*)lpD3DDevice2;
|
1999-01-03 18:00:19 +01:00
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
*lpMatHandle = (DWORD) This; /* lpD3DDevice2->store_material(This); */
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
static HRESULT WINAPI IDirect3DMaterialImpl_Reserve(LPDIRECT3DMATERIAL iface)
|
1999-01-03 18:00:19 +01:00
|
|
|
{
|
1999-03-27 17:56:13 +01:00
|
|
|
ICOM_THIS(IDirect3DMaterial2Impl,iface);
|
1999-06-26 21:09:08 +02:00
|
|
|
FIXME("(%p)->(): stub\n", This);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
static HRESULT WINAPI IDirect3DMaterialImpl_Unreserve(LPDIRECT3DMATERIAL iface)
|
1999-01-03 18:00:19 +01:00
|
|
|
{
|
1999-03-27 17:56:13 +01:00
|
|
|
ICOM_THIS(IDirect3DMaterial2Impl,iface);
|
1999-06-26 21:09:08 +02:00
|
|
|
FIXME("(%p)->(): stub\n", This);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
|
1999-03-27 17:56:13 +01:00
|
|
|
static HRESULT WINAPI IDirect3DMaterialImpl_Initialize(LPDIRECT3DMATERIAL iface,
|
1999-01-03 18:00:19 +01:00
|
|
|
LPDIRECT3D lpDirect3D)
|
|
|
|
|
|
|
|
{
|
1999-03-27 17:56:13 +01:00
|
|
|
ICOM_THIS(IDirect3DMaterial2Impl,iface);
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("(%p)->(%p)\n", This, lpDirect3D);
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
return DDERR_ALREADYINITIALIZED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* IDirect3DMaterial VTable
|
|
|
|
*/
|
2000-07-16 16:40:35 +02:00
|
|
|
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
|
2001-01-04 23:59:48 +01:00
|
|
|
# define XCAST(fun) (typeof(material_vtable.fun))
|
2000-07-16 16:40:35 +02:00
|
|
|
#else
|
|
|
|
# define XCAST(fun) (void*)
|
|
|
|
#endif
|
|
|
|
|
1999-05-22 13:41:38 +02:00
|
|
|
static ICOM_VTABLE(IDirect3DMaterial) material_vtable =
|
|
|
|
{
|
|
|
|
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
1999-01-03 18:00:19 +01:00
|
|
|
/*** IUnknown methods ***/
|
2000-07-16 16:40:35 +02:00
|
|
|
XCAST(QueryInterface)IDirect3DMaterial2Impl_QueryInterface,
|
|
|
|
XCAST(AddRef)IDirect3DMaterial2Impl_AddRef,
|
|
|
|
XCAST(Release)IDirect3DMaterial2Impl_Release,
|
1999-01-03 18:00:19 +01:00
|
|
|
/*** IDirect3DMaterial methods ***/
|
1999-03-27 17:56:13 +01:00
|
|
|
IDirect3DMaterialImpl_Initialize,
|
2000-07-16 16:40:35 +02:00
|
|
|
XCAST(SetMaterial)IDirect3DMaterial2Impl_SetMaterial,
|
|
|
|
XCAST(GetMaterial)IDirect3DMaterial2Impl_GetMaterial,
|
|
|
|
XCAST(GetHandle)IDirect3DMaterial2Impl_GetHandle,
|
1999-03-27 17:56:13 +01:00
|
|
|
IDirect3DMaterialImpl_Reserve,
|
|
|
|
IDirect3DMaterialImpl_Unreserve
|
1999-01-03 18:00:19 +01:00
|
|
|
};
|
|
|
|
|
2000-07-16 16:40:35 +02:00
|
|
|
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
|
|
|
|
#undef XCAST
|
|
|
|
#endif
|
1999-01-03 18:00:19 +01:00
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* IDirect3DMaterial2 VTable
|
|
|
|
*/
|
1999-05-22 13:41:38 +02:00
|
|
|
static ICOM_VTABLE(IDirect3DMaterial2) material2_vtable =
|
|
|
|
{
|
|
|
|
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
1999-01-03 18:00:19 +01:00
|
|
|
/*** IUnknown methods ***/
|
1999-03-27 17:56:13 +01:00
|
|
|
IDirect3DMaterial2Impl_QueryInterface,
|
|
|
|
IDirect3DMaterial2Impl_AddRef,
|
|
|
|
IDirect3DMaterial2Impl_Release,
|
1999-01-03 18:00:19 +01:00
|
|
|
/*** IDirect3DMaterial methods ***/
|
1999-03-27 17:56:13 +01:00
|
|
|
IDirect3DMaterial2Impl_SetMaterial,
|
|
|
|
IDirect3DMaterial2Impl_GetMaterial,
|
|
|
|
IDirect3DMaterial2Impl_GetHandle
|
1999-01-03 18:00:19 +01:00
|
|
|
};
|