2012-05-22 22:05:24 +02:00
|
|
|
/*
|
|
|
|
* Implementation of IDirect3DRMMaterial2 interface
|
|
|
|
*
|
|
|
|
* Copyright 2012 Christian Costa
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "wingdi.h"
|
|
|
|
|
|
|
|
#include "d3drm_private.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(d3drm);
|
|
|
|
|
2013-10-29 10:28:06 +01:00
|
|
|
struct color_rgb
|
2012-05-22 22:05:24 +02:00
|
|
|
{
|
|
|
|
D3DVALUE r;
|
|
|
|
D3DVALUE g;
|
|
|
|
D3DVALUE b;
|
2013-10-29 10:28:06 +01:00
|
|
|
};
|
2012-05-22 22:05:24 +02:00
|
|
|
|
2013-10-28 11:46:43 +01:00
|
|
|
struct d3drm_material
|
|
|
|
{
|
2012-05-22 22:05:24 +02:00
|
|
|
IDirect3DRMMaterial2 IDirect3DRMMaterial2_iface;
|
|
|
|
LONG ref;
|
2013-10-29 10:28:06 +01:00
|
|
|
struct color_rgb emissive;
|
|
|
|
struct color_rgb specular;
|
2012-05-22 22:05:24 +02:00
|
|
|
D3DVALUE power;
|
2013-10-29 10:28:06 +01:00
|
|
|
struct color_rgb ambient;
|
2013-10-28 11:46:43 +01:00
|
|
|
};
|
2012-05-22 22:05:24 +02:00
|
|
|
|
2013-10-28 11:46:43 +01:00
|
|
|
static inline struct d3drm_material *impl_from_IDirect3DRMMaterial2(IDirect3DRMMaterial2 *iface)
|
2012-05-22 22:05:24 +02:00
|
|
|
{
|
2013-10-28 11:46:43 +01:00
|
|
|
return CONTAINING_RECORD(iface, struct d3drm_material, IDirect3DRMMaterial2_iface);
|
2012-05-22 22:05:24 +02:00
|
|
|
}
|
|
|
|
|
2013-10-28 11:46:43 +01:00
|
|
|
static HRESULT WINAPI d3drm_material_QueryInterface(IDirect3DRMMaterial2 *iface, REFIID riid, void **out)
|
2012-05-22 22:05:24 +02:00
|
|
|
{
|
2013-10-28 11:46:43 +01:00
|
|
|
TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
|
2012-05-22 22:05:24 +02:00
|
|
|
|
2013-10-28 11:46:43 +01:00
|
|
|
if (IsEqualGUID(riid, &IID_IDirect3DRMMaterial2)
|
|
|
|
|| IsEqualGUID(riid, &IID_IDirect3DRMMaterial)
|
|
|
|
|| IsEqualGUID(riid, &IID_IUnknown))
|
2012-05-22 22:05:24 +02:00
|
|
|
{
|
2013-10-28 11:46:43 +01:00
|
|
|
IDirect3DRMMaterial2_AddRef(iface);
|
|
|
|
*out = iface;
|
|
|
|
return S_OK;
|
2012-05-22 22:05:24 +02:00
|
|
|
}
|
|
|
|
|
2013-10-28 11:46:43 +01:00
|
|
|
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
|
2012-05-22 22:05:24 +02:00
|
|
|
|
2013-10-28 11:46:43 +01:00
|
|
|
*out = NULL;
|
|
|
|
return E_NOINTERFACE;
|
2012-05-22 22:05:24 +02:00
|
|
|
}
|
|
|
|
|
2013-10-28 11:46:43 +01:00
|
|
|
static ULONG WINAPI d3drm_material_AddRef(IDirect3DRMMaterial2 *iface)
|
2012-05-22 22:05:24 +02:00
|
|
|
{
|
2013-10-28 11:46:43 +01:00
|
|
|
struct d3drm_material *material = impl_from_IDirect3DRMMaterial2(iface);
|
|
|
|
ULONG refcount = InterlockedIncrement(&material->ref);
|
2012-05-22 22:05:24 +02:00
|
|
|
|
2013-10-28 11:46:43 +01:00
|
|
|
TRACE("%p increasing refcount to %u.\n", iface, refcount);
|
2012-05-22 22:05:24 +02:00
|
|
|
|
2013-10-28 11:46:43 +01:00
|
|
|
return refcount;
|
2012-05-22 22:05:24 +02:00
|
|
|
}
|
|
|
|
|
2013-10-28 11:46:43 +01:00
|
|
|
static ULONG WINAPI d3drm_material_Release(IDirect3DRMMaterial2 *iface)
|
2012-05-22 22:05:24 +02:00
|
|
|
{
|
2013-10-28 11:46:43 +01:00
|
|
|
struct d3drm_material *material = impl_from_IDirect3DRMMaterial2(iface);
|
|
|
|
ULONG refcount = InterlockedDecrement(&material->ref);
|
2012-05-22 22:05:24 +02:00
|
|
|
|
2013-10-28 11:46:43 +01:00
|
|
|
TRACE("%p decreasing refcount to %u.\n", iface, refcount);
|
2012-05-22 22:05:24 +02:00
|
|
|
|
2013-10-28 11:46:43 +01:00
|
|
|
if (!refcount)
|
|
|
|
HeapFree(GetProcessHeap(), 0, material);
|
2012-05-22 22:05:24 +02:00
|
|
|
|
2013-10-28 11:46:43 +01:00
|
|
|
return refcount;
|
2012-05-22 22:05:24 +02:00
|
|
|
}
|
|
|
|
|
2013-10-28 11:46:43 +01:00
|
|
|
static HRESULT WINAPI d3drm_material_Clone(IDirect3DRMMaterial2 *iface,
|
2013-08-20 10:20:13 +02:00
|
|
|
IUnknown *outer, REFIID iid, void **out)
|
2012-05-22 22:05:24 +02:00
|
|
|
{
|
2013-08-20 10:20:13 +02:00
|
|
|
FIXME("iface %p, outer %p, iid %s, out %p stub!\n", iface, outer, debugstr_guid(iid), out);
|
2012-05-22 22:05:24 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2013-10-28 11:46:43 +01:00
|
|
|
static HRESULT WINAPI d3drm_material_AddDestroyCallback(IDirect3DRMMaterial2 *iface,
|
2013-09-09 10:26:21 +02:00
|
|
|
D3DRMOBJECTCALLBACK cb, void *ctx)
|
2012-05-22 22:05:24 +02:00
|
|
|
{
|
2013-09-09 10:26:21 +02:00
|
|
|
FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
|
2012-05-22 22:05:24 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2013-10-28 11:46:43 +01:00
|
|
|
static HRESULT WINAPI d3drm_material_DeleteDestroyCallback(IDirect3DRMMaterial2 *iface,
|
2013-09-09 10:26:21 +02:00
|
|
|
D3DRMOBJECTCALLBACK cb, void *ctx)
|
2012-05-22 22:05:24 +02:00
|
|
|
{
|
2013-09-09 10:26:21 +02:00
|
|
|
FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
|
2012-05-22 22:05:24 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2013-10-28 11:46:43 +01:00
|
|
|
static HRESULT WINAPI d3drm_material_SetAppData(IDirect3DRMMaterial2 *iface, DWORD data)
|
2012-05-22 22:05:24 +02:00
|
|
|
{
|
2013-10-28 11:46:43 +01:00
|
|
|
FIXME("iface %p, data %#x stub!\n", iface, data);
|
2012-05-22 22:05:24 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2013-10-28 11:46:43 +01:00
|
|
|
static DWORD WINAPI d3drm_material_GetAppData(IDirect3DRMMaterial2 *iface)
|
2012-05-22 22:05:24 +02:00
|
|
|
{
|
2013-10-28 11:46:43 +01:00
|
|
|
FIXME("iface %p stub!\n", iface);
|
2012-05-22 22:05:24 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-10-28 11:46:43 +01:00
|
|
|
static HRESULT WINAPI d3drm_material_SetName(IDirect3DRMMaterial2 *iface, const char *name)
|
2012-05-22 22:05:24 +02:00
|
|
|
{
|
2013-09-06 09:57:43 +02:00
|
|
|
FIXME("iface %p, name %s stub!\n", iface, debugstr_a(name));
|
2012-05-22 22:05:24 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2013-10-28 11:46:43 +01:00
|
|
|
static HRESULT WINAPI d3drm_material_GetName(IDirect3DRMMaterial2 *iface, DWORD *size, char *name)
|
2012-05-22 22:05:24 +02:00
|
|
|
{
|
2013-09-09 10:26:20 +02:00
|
|
|
FIXME("iface %p, size %p, name %p stub!\n", iface, size, name);
|
2012-05-22 22:05:24 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2013-10-28 11:46:43 +01:00
|
|
|
static HRESULT WINAPI d3drm_material_GetClassName(IDirect3DRMMaterial2 *iface, DWORD *size, char *name)
|
2012-05-22 22:05:24 +02:00
|
|
|
{
|
2013-09-09 10:26:20 +02:00
|
|
|
TRACE("iface %p, size %p, name %p.\n", iface, size, name);
|
2012-05-22 22:05:24 +02:00
|
|
|
|
2012-06-17 15:37:05 +02:00
|
|
|
if (!size || *size < strlen("Material") || !name)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
strcpy(name, "Material");
|
|
|
|
*size = sizeof("Material");
|
|
|
|
|
|
|
|
return D3DRM_OK;
|
2012-05-22 22:05:24 +02:00
|
|
|
}
|
|
|
|
|
2013-10-28 11:46:43 +01:00
|
|
|
static HRESULT WINAPI d3drm_material_SetPower(IDirect3DRMMaterial2 *iface, D3DVALUE power)
|
2012-05-22 22:05:24 +02:00
|
|
|
{
|
2013-10-28 11:46:43 +01:00
|
|
|
struct d3drm_material *material = impl_from_IDirect3DRMMaterial2(iface);
|
2012-05-22 22:05:24 +02:00
|
|
|
|
2013-10-28 11:46:43 +01:00
|
|
|
TRACE("iface %p, power %.8e.\n", iface, power);
|
2012-05-22 22:05:24 +02:00
|
|
|
|
2013-10-28 11:46:43 +01:00
|
|
|
material->power = power;
|
2012-05-22 22:05:24 +02:00
|
|
|
|
|
|
|
return D3DRM_OK;
|
|
|
|
}
|
|
|
|
|
2013-10-28 11:46:43 +01:00
|
|
|
static HRESULT WINAPI d3drm_material_SetSpecular(IDirect3DRMMaterial2 *iface,
|
|
|
|
D3DVALUE r, D3DVALUE g, D3DVALUE b)
|
2012-05-22 22:05:24 +02:00
|
|
|
{
|
2013-10-28 11:46:43 +01:00
|
|
|
struct d3drm_material *material = impl_from_IDirect3DRMMaterial2(iface);
|
2012-05-22 22:05:24 +02:00
|
|
|
|
2013-10-28 11:46:43 +01:00
|
|
|
TRACE("iface %p, r %.8e, g %.8e, b %.8e.\n", iface, r, g, b);
|
2012-05-22 22:05:24 +02:00
|
|
|
|
2013-10-28 11:46:43 +01:00
|
|
|
material->specular.r = r;
|
|
|
|
material->specular.g = g;
|
|
|
|
material->specular.b = b;
|
2012-05-22 22:05:24 +02:00
|
|
|
|
|
|
|
return D3DRM_OK;
|
|
|
|
}
|
|
|
|
|
2013-10-28 11:46:43 +01:00
|
|
|
static HRESULT WINAPI d3drm_material_SetEmissive(IDirect3DRMMaterial2 *iface,
|
|
|
|
D3DVALUE r, D3DVALUE g, D3DVALUE b)
|
2012-05-22 22:05:24 +02:00
|
|
|
{
|
2013-10-28 11:46:43 +01:00
|
|
|
struct d3drm_material *material = impl_from_IDirect3DRMMaterial2(iface);
|
2012-05-22 22:05:24 +02:00
|
|
|
|
2013-10-28 11:46:43 +01:00
|
|
|
TRACE("iface %p, r %.8e, g %.8e, b %.8e.\n", iface, r, g, b);
|
2012-05-22 22:05:24 +02:00
|
|
|
|
2013-10-28 11:46:43 +01:00
|
|
|
material->emissive.r = r;
|
|
|
|
material->emissive.g = g;
|
|
|
|
material->emissive.b = b;
|
2012-05-22 22:05:24 +02:00
|
|
|
|
|
|
|
return D3DRM_OK;
|
|
|
|
}
|
|
|
|
|
2013-10-28 11:46:43 +01:00
|
|
|
static D3DVALUE WINAPI d3drm_material_GetPower(IDirect3DRMMaterial2 *iface)
|
2012-05-22 22:05:24 +02:00
|
|
|
{
|
2013-10-28 11:46:43 +01:00
|
|
|
struct d3drm_material *material = impl_from_IDirect3DRMMaterial2(iface);
|
2012-05-22 22:05:24 +02:00
|
|
|
|
2013-10-28 11:46:43 +01:00
|
|
|
TRACE("iface %p.\n", iface);
|
2012-05-22 22:05:24 +02:00
|
|
|
|
2013-10-28 11:46:43 +01:00
|
|
|
return material->power;
|
2012-05-22 22:05:24 +02:00
|
|
|
}
|
|
|
|
|
2013-10-28 11:46:43 +01:00
|
|
|
static HRESULT WINAPI d3drm_material_GetSpecular(IDirect3DRMMaterial2 *iface,
|
|
|
|
D3DVALUE *r, D3DVALUE *g, D3DVALUE *b)
|
2012-05-22 22:05:24 +02:00
|
|
|
{
|
2013-10-28 11:46:43 +01:00
|
|
|
struct d3drm_material *material = impl_from_IDirect3DRMMaterial2(iface);
|
2012-05-22 22:05:24 +02:00
|
|
|
|
2013-10-28 11:46:43 +01:00
|
|
|
TRACE("iface %p, r %p, g %p, b %p.\n", iface, r, g, b);
|
2012-05-22 22:05:24 +02:00
|
|
|
|
2013-10-28 11:46:43 +01:00
|
|
|
*r = material->specular.r;
|
|
|
|
*g = material->specular.g;
|
|
|
|
*b = material->specular.b;
|
2012-05-22 22:05:24 +02:00
|
|
|
|
|
|
|
return D3DRM_OK;
|
|
|
|
}
|
|
|
|
|
2013-10-28 11:46:43 +01:00
|
|
|
static HRESULT WINAPI d3drm_material_GetEmissive(IDirect3DRMMaterial2 *iface,
|
|
|
|
D3DVALUE *r, D3DVALUE *g, D3DVALUE *b)
|
2012-05-22 22:05:24 +02:00
|
|
|
{
|
2013-10-28 11:46:43 +01:00
|
|
|
struct d3drm_material *material = impl_from_IDirect3DRMMaterial2(iface);
|
2012-05-22 22:05:24 +02:00
|
|
|
|
2013-10-28 11:46:43 +01:00
|
|
|
TRACE("iface %p, r %p, g %p, b %p.\n", iface, r, g, b);
|
2012-05-22 22:05:24 +02:00
|
|
|
|
2013-10-28 11:46:43 +01:00
|
|
|
*r = material->emissive.r;
|
|
|
|
*g = material->emissive.g;
|
|
|
|
*b = material->emissive.b;
|
2012-05-22 22:05:24 +02:00
|
|
|
|
|
|
|
return D3DRM_OK;
|
|
|
|
}
|
|
|
|
|
2013-10-28 11:46:43 +01:00
|
|
|
static HRESULT WINAPI d3drm_material_GetAmbient(IDirect3DRMMaterial2 *iface,
|
|
|
|
D3DVALUE *r, D3DVALUE *g, D3DVALUE *b)
|
2012-05-22 22:05:24 +02:00
|
|
|
{
|
2013-10-28 11:46:43 +01:00
|
|
|
struct d3drm_material *material = impl_from_IDirect3DRMMaterial2(iface);
|
2012-05-22 22:05:24 +02:00
|
|
|
|
2013-10-28 11:46:43 +01:00
|
|
|
TRACE("iface %p, r %p, g %p, b %p.\n", iface, r, g, b);
|
2012-05-22 22:05:24 +02:00
|
|
|
|
2013-10-28 11:46:43 +01:00
|
|
|
*r = material->ambient.r;
|
|
|
|
*g = material->ambient.g;
|
|
|
|
*b = material->ambient.b;
|
2012-05-22 22:05:24 +02:00
|
|
|
|
|
|
|
return D3DRM_OK;
|
|
|
|
}
|
|
|
|
|
2013-10-28 11:46:43 +01:00
|
|
|
static HRESULT WINAPI d3drm_material_SetAmbient(IDirect3DRMMaterial2 *iface,
|
|
|
|
D3DVALUE r, D3DVALUE g, D3DVALUE b)
|
2012-05-22 22:05:24 +02:00
|
|
|
{
|
2013-10-28 11:46:43 +01:00
|
|
|
struct d3drm_material *material = impl_from_IDirect3DRMMaterial2(iface);
|
2012-05-22 22:05:24 +02:00
|
|
|
|
2013-10-28 11:46:43 +01:00
|
|
|
TRACE("iface %p, r %.8e, g %.8e, b %.8e.\n", iface, r, g, b);
|
2012-05-22 22:05:24 +02:00
|
|
|
|
2013-10-28 11:46:43 +01:00
|
|
|
material->ambient.r = r;
|
|
|
|
material->ambient.g = g;
|
|
|
|
material->ambient.b = b;
|
2012-05-22 22:05:24 +02:00
|
|
|
|
|
|
|
return D3DRM_OK;
|
|
|
|
}
|
|
|
|
|
2013-10-28 11:46:43 +01:00
|
|
|
static const struct IDirect3DRMMaterial2Vtbl d3drm_material_vtbl =
|
2012-05-22 22:05:24 +02:00
|
|
|
{
|
2013-10-28 11:46:43 +01:00
|
|
|
d3drm_material_QueryInterface,
|
|
|
|
d3drm_material_AddRef,
|
|
|
|
d3drm_material_Release,
|
|
|
|
d3drm_material_Clone,
|
|
|
|
d3drm_material_AddDestroyCallback,
|
|
|
|
d3drm_material_DeleteDestroyCallback,
|
|
|
|
d3drm_material_SetAppData,
|
|
|
|
d3drm_material_GetAppData,
|
|
|
|
d3drm_material_SetName,
|
|
|
|
d3drm_material_GetName,
|
|
|
|
d3drm_material_GetClassName,
|
|
|
|
d3drm_material_SetPower,
|
|
|
|
d3drm_material_SetSpecular,
|
|
|
|
d3drm_material_SetEmissive,
|
|
|
|
d3drm_material_GetPower,
|
|
|
|
d3drm_material_GetSpecular,
|
|
|
|
d3drm_material_GetEmissive,
|
|
|
|
d3drm_material_GetAmbient,
|
|
|
|
d3drm_material_SetAmbient,
|
2012-05-22 22:05:24 +02:00
|
|
|
};
|
|
|
|
|
2013-10-28 11:46:43 +01:00
|
|
|
HRESULT Direct3DRMMaterial_create(IDirect3DRMMaterial2 **out)
|
2012-05-22 22:05:24 +02:00
|
|
|
{
|
2013-10-28 11:46:43 +01:00
|
|
|
struct d3drm_material *object;
|
2012-05-22 22:05:24 +02:00
|
|
|
|
2013-10-28 11:46:43 +01:00
|
|
|
TRACE("out %p.\n", out);
|
2012-05-22 22:05:24 +02:00
|
|
|
|
2013-10-28 11:46:43 +01:00
|
|
|
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
|
2012-05-22 22:05:24 +02:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2013-10-28 11:46:43 +01:00
|
|
|
object->IDirect3DRMMaterial2_iface.lpVtbl = &d3drm_material_vtbl;
|
2012-05-22 22:05:24 +02:00
|
|
|
object->ref = 1;
|
|
|
|
|
2012-06-17 15:38:50 +02:00
|
|
|
object->specular.r = 1.0f;
|
|
|
|
object->specular.g = 1.0f;
|
|
|
|
object->specular.b = 1.0f;
|
|
|
|
|
2013-10-28 11:46:43 +01:00
|
|
|
*out = &object->IDirect3DRMMaterial2_iface;
|
2012-05-22 22:05:24 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|