Sweden-Number/dlls/d3drm/light.c

389 lines
9.9 KiB
C
Raw Normal View History

2012-05-01 22:15:39 +02:00
/*
* Implementation of IDirect3DRMLight Interface
*
* Copyright 2012 André Hentschel
*
* 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 "config.h"
#include "wine/port.h"
2012-05-01 22:15:39 +02:00
#include "d3drm_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3drm);
struct d3drm_light
{
2012-05-01 22:15:39 +02:00
IDirect3DRMLight IDirect3DRMLight_iface;
LONG ref;
D3DRMLIGHTTYPE type;
D3DCOLOR color;
D3DVALUE range;
D3DVALUE cattenuation;
D3DVALUE lattenuation;
D3DVALUE qattenuation;
D3DVALUE umbra;
D3DVALUE penumbra;
};
2012-05-01 22:15:39 +02:00
static inline struct d3drm_light *impl_from_IDirect3DRMLight(IDirect3DRMLight *iface)
2012-05-01 22:15:39 +02:00
{
return CONTAINING_RECORD(iface, struct d3drm_light, IDirect3DRMLight_iface);
2012-05-01 22:15:39 +02:00
}
static HRESULT WINAPI d3drm_light_QueryInterface(IDirect3DRMLight *iface, REFIID riid, void **out)
2012-05-01 22:15:39 +02:00
{
TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
2012-05-01 22:15:39 +02:00
if (IsEqualGUID(riid, &IID_IDirect3DRMLight)
|| IsEqualGUID(riid, &IID_IUnknown))
2012-05-01 22:15:39 +02:00
{
IDirect3DRMLight_AddRef(iface);
*out = iface;
return S_OK;
2012-05-01 22:15:39 +02:00
}
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
*out = NULL;
return E_NOINTERFACE;
2012-05-01 22:15:39 +02:00
}
static ULONG WINAPI d3drm_light_AddRef(IDirect3DRMLight *iface)
2012-05-01 22:15:39 +02:00
{
struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
ULONG refcount = InterlockedIncrement(&light->ref);
2012-05-01 22:15:39 +02:00
TRACE("%p increasing refcount to %u.\n", iface, refcount);
2012-05-01 22:15:39 +02:00
return refcount;
2012-05-01 22:15:39 +02:00
}
static ULONG WINAPI d3drm_light_Release(IDirect3DRMLight *iface)
2012-05-01 22:15:39 +02:00
{
struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
ULONG refcount = InterlockedDecrement(&light->ref);
2012-05-01 22:15:39 +02:00
TRACE("%p decreasing refcount to %u.\n", iface, refcount);
2012-05-01 22:15:39 +02:00
if (!refcount)
HeapFree(GetProcessHeap(), 0, light);
2012-05-01 22:15:39 +02:00
return refcount;
2012-05-01 22:15:39 +02:00
}
static HRESULT WINAPI d3drm_light_Clone(IDirect3DRMLight *iface,
2013-08-20 10:20:13 +02:00
IUnknown *outer, REFIID iid, void **out)
2012-05-01 22:15:39 +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-01 22:15:39 +02:00
return E_NOTIMPL;
}
static HRESULT WINAPI d3drm_light_AddDestroyCallback(IDirect3DRMLight *iface,
2013-09-09 10:26:21 +02:00
D3DRMOBJECTCALLBACK cb, void *ctx)
2012-05-01 22:15:39 +02:00
{
2013-09-09 10:26:21 +02:00
FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
2012-05-01 22:15:39 +02:00
return E_NOTIMPL;
}
static HRESULT WINAPI d3drm_light_DeleteDestroyCallback(IDirect3DRMLight *iface,
2013-09-09 10:26:21 +02:00
D3DRMOBJECTCALLBACK cb, void *ctx)
2012-05-01 22:15:39 +02:00
{
2013-09-09 10:26:21 +02:00
FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
2012-05-01 22:15:39 +02:00
return E_NOTIMPL;
}
static HRESULT WINAPI d3drm_light_SetAppData(IDirect3DRMLight *iface, DWORD data)
2012-05-01 22:15:39 +02:00
{
FIXME("iface %p, data %#x stub!\n", iface, data);
2012-05-01 22:15:39 +02:00
return E_NOTIMPL;
}
static DWORD WINAPI d3drm_light_GetAppData(IDirect3DRMLight *iface)
2012-05-01 22:15:39 +02:00
{
FIXME("iface %p stub!\n", iface);
2012-05-01 22:15:39 +02:00
return 0;
}
static HRESULT WINAPI d3drm_light_SetName(IDirect3DRMLight *iface, const char *name)
2012-05-01 22:15:39 +02:00
{
2013-09-06 09:57:43 +02:00
FIXME("iface %p, name %s stub!\n", iface, debugstr_a(name));
2012-05-01 22:15:39 +02:00
return E_NOTIMPL;
}
static HRESULT WINAPI d3drm_light_GetName(IDirect3DRMLight *iface, DWORD *size, char *name)
2012-05-01 22:15:39 +02:00
{
2013-09-09 10:26:20 +02:00
FIXME("iface %p, size %p, name %p stub!\n", iface, size, name);
2012-05-01 22:15:39 +02:00
return E_NOTIMPL;
}
static HRESULT WINAPI d3drm_light_GetClassName(IDirect3DRMLight *iface, DWORD *size, char *name)
2012-05-01 22:15:39 +02:00
{
2013-09-09 10:26:20 +02:00
TRACE("iface %p, size %p, name %p.\n", iface, size, name);
2012-05-01 22:15:39 +02:00
if (!size || *size < strlen("Light") || !name)
return E_INVALIDARG;
strcpy(name, "Light");
*size = sizeof("Light");
return D3DRM_OK;
2012-05-01 22:15:39 +02:00
}
static HRESULT WINAPI d3drm_light_SetType(IDirect3DRMLight *iface, D3DRMLIGHTTYPE type)
2012-05-01 22:15:39 +02:00
{
struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
2012-05-01 22:15:39 +02:00
TRACE("iface %p, type %#x.\n", iface, type);
2012-05-01 22:15:39 +02:00
light->type = type;
return D3DRM_OK;
2012-05-01 22:15:39 +02:00
}
static HRESULT WINAPI d3drm_light_SetColor(IDirect3DRMLight *iface, D3DCOLOR color)
2012-05-01 22:15:39 +02:00
{
struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
2012-05-01 22:15:39 +02:00
TRACE("iface %p, color 0x%08x.\n", iface, color);
2012-05-01 22:15:39 +02:00
light->color = color;
return D3DRM_OK;
2012-05-01 22:15:39 +02:00
}
static HRESULT WINAPI d3drm_light_SetColorRGB(IDirect3DRMLight *iface,
D3DVALUE red, D3DVALUE green, D3DVALUE blue)
2012-05-01 22:15:39 +02:00
{
struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
2012-05-01 22:15:39 +02:00
TRACE("iface %p, red %.8e, green %.8e, blue %.8e.\n", iface, red, green, blue);
2012-05-01 22:15:39 +02:00
d3drm_set_color(&light->color, red, green, blue, 1.0f);
return D3DRM_OK;
2012-05-01 22:15:39 +02:00
}
static HRESULT WINAPI d3drm_light_SetRange(IDirect3DRMLight *iface, D3DVALUE range)
2012-05-01 22:15:39 +02:00
{
struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
2012-05-01 22:15:39 +02:00
TRACE("iface %p, range %.8e.\n", iface, range);
2012-05-01 22:15:39 +02:00
light->range = range;
return D3DRM_OK;
2012-05-01 22:15:39 +02:00
}
static HRESULT WINAPI d3drm_light_SetUmbra(IDirect3DRMLight *iface, D3DVALUE umbra)
2012-05-01 22:15:39 +02:00
{
struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
2012-05-01 22:15:39 +02:00
TRACE("iface %p, umbra %.8e.\n", iface, umbra);
2012-05-01 22:15:39 +02:00
light->umbra = umbra;
return D3DRM_OK;
2012-05-01 22:15:39 +02:00
}
static HRESULT WINAPI d3drm_light_SetPenumbra(IDirect3DRMLight *iface, D3DVALUE penumbra)
2012-05-01 22:15:39 +02:00
{
struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
2012-05-01 22:15:39 +02:00
TRACE("iface %p, penumbra %.8e.\n", iface, penumbra);
2012-05-01 22:15:39 +02:00
light->penumbra = penumbra;
return D3DRM_OK;
2012-05-01 22:15:39 +02:00
}
static HRESULT WINAPI d3drm_light_SetConstantAttenuation(IDirect3DRMLight *iface, D3DVALUE attenuation)
2012-05-01 22:15:39 +02:00
{
struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
2012-05-01 22:15:39 +02:00
TRACE("iface %p, attenuation %.8e.\n", iface, attenuation);
2012-05-01 22:15:39 +02:00
light->cattenuation = attenuation;
return D3DRM_OK;
2012-05-01 22:15:39 +02:00
}
static HRESULT WINAPI d3drm_light_SetLinearAttenuation(IDirect3DRMLight *iface, D3DVALUE attenuation)
2012-05-01 22:15:39 +02:00
{
struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
2012-05-01 22:15:39 +02:00
TRACE("iface %p, attenuation %.8e.\n", iface, attenuation);
2012-05-01 22:15:39 +02:00
light->lattenuation = attenuation;
return D3DRM_OK;
2012-05-01 22:15:39 +02:00
}
static HRESULT WINAPI d3drm_light_SetQuadraticAttenuation(IDirect3DRMLight *iface, D3DVALUE attenuation)
2012-05-01 22:15:39 +02:00
{
struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
2012-05-01 22:15:39 +02:00
TRACE("iface %p, attenuation %.8e.\n", iface, attenuation);
2012-05-01 22:15:39 +02:00
light->qattenuation = attenuation;
return D3DRM_OK;
2012-05-01 22:15:39 +02:00
}
static D3DVALUE WINAPI d3drm_light_GetRange(IDirect3DRMLight *iface)
2012-05-01 22:15:39 +02:00
{
struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
2012-05-01 22:15:39 +02:00
TRACE("iface %p.\n", iface);
2012-05-01 22:15:39 +02:00
return light->range;
2012-05-01 22:15:39 +02:00
}
static D3DVALUE WINAPI d3drm_light_GetUmbra(IDirect3DRMLight *iface)
2012-05-01 22:15:39 +02:00
{
struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
2012-05-01 22:15:39 +02:00
TRACE("iface %p.\n", light);
2012-05-01 22:15:39 +02:00
return light->umbra;
2012-05-01 22:15:39 +02:00
}
static D3DVALUE WINAPI d3drm_light_GetPenumbra(IDirect3DRMLight *iface)
2012-05-01 22:15:39 +02:00
{
struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
2012-05-01 22:15:39 +02:00
TRACE("iface %p.\n", iface);
2012-05-01 22:15:39 +02:00
return light->penumbra;
2012-05-01 22:15:39 +02:00
}
static D3DVALUE WINAPI d3drm_light_GetConstantAttenuation(IDirect3DRMLight *iface)
2012-05-01 22:15:39 +02:00
{
struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
2012-05-01 22:15:39 +02:00
TRACE("iface %p.\n", iface);
2012-05-01 22:15:39 +02:00
return light->cattenuation;
2012-05-01 22:15:39 +02:00
}
static D3DVALUE WINAPI d3drm_light_GetLinearAttenuation(IDirect3DRMLight *iface)
2012-05-01 22:15:39 +02:00
{
struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
2012-05-01 22:15:39 +02:00
TRACE("iface %p.\n", iface);
2012-05-01 22:15:39 +02:00
return light->lattenuation;
2012-05-01 22:15:39 +02:00
}
static D3DVALUE WINAPI d3drm_light_GetQuadraticAttenuation(IDirect3DRMLight *iface)
2012-05-01 22:15:39 +02:00
{
struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
2012-05-01 22:15:39 +02:00
TRACE("iface %p.\n", iface);
2012-05-01 22:15:39 +02:00
return light->qattenuation;
2012-05-01 22:15:39 +02:00
}
static D3DCOLOR WINAPI d3drm_light_GetColor(IDirect3DRMLight *iface)
2012-05-01 22:15:39 +02:00
{
struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
2012-05-01 22:15:39 +02:00
TRACE("iface %p.\n", iface);
2012-05-01 22:15:39 +02:00
return light->color;
2012-05-01 22:15:39 +02:00
}
static D3DRMLIGHTTYPE WINAPI d3drm_light_GetType(IDirect3DRMLight *iface)
2012-05-01 22:15:39 +02:00
{
struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
2012-05-01 22:15:39 +02:00
TRACE("iface %p.\n", iface);
2012-05-01 22:15:39 +02:00
return light->type;
2012-05-01 22:15:39 +02:00
}
static HRESULT WINAPI d3drm_light_SetEnableFrame(IDirect3DRMLight *iface, IDirect3DRMFrame *frame)
2012-05-01 22:15:39 +02:00
{
2013-04-19 08:34:15 +02:00
FIXME("iface %p, frame %p stub!\n", iface, frame);
2012-05-01 22:15:39 +02:00
return E_NOTIMPL;
}
static HRESULT WINAPI d3drm_light_GetEnableFrame(IDirect3DRMLight *iface, IDirect3DRMFrame **frame)
2012-05-01 22:15:39 +02:00
{
2013-04-19 08:34:15 +02:00
FIXME("iface %p, frame %p stub!\n", iface, frame);
2012-05-01 22:15:39 +02:00
return E_NOTIMPL;
}
static const struct IDirect3DRMLightVtbl d3drm_light_vtbl =
{
d3drm_light_QueryInterface,
d3drm_light_AddRef,
d3drm_light_Release,
d3drm_light_Clone,
d3drm_light_AddDestroyCallback,
d3drm_light_DeleteDestroyCallback,
d3drm_light_SetAppData,
d3drm_light_GetAppData,
d3drm_light_SetName,
d3drm_light_GetName,
d3drm_light_GetClassName,
d3drm_light_SetType,
d3drm_light_SetColor,
d3drm_light_SetColorRGB,
d3drm_light_SetRange,
d3drm_light_SetUmbra,
d3drm_light_SetPenumbra,
d3drm_light_SetConstantAttenuation,
d3drm_light_SetLinearAttenuation,
d3drm_light_SetQuadraticAttenuation,
d3drm_light_GetRange,
d3drm_light_GetUmbra,
d3drm_light_GetPenumbra,
d3drm_light_GetConstantAttenuation,
d3drm_light_GetLinearAttenuation,
d3drm_light_GetQuadraticAttenuation,
d3drm_light_GetColor,
d3drm_light_GetType,
d3drm_light_SetEnableFrame,
d3drm_light_GetEnableFrame,
2012-05-01 22:15:39 +02:00
};
HRESULT Direct3DRMLight_create(IUnknown **out)
2012-05-01 22:15:39 +02:00
{
struct d3drm_light *object;
2012-05-01 22:15:39 +02:00
TRACE("out %p.\n", out);
2012-05-01 22:15:39 +02:00
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
2012-05-01 22:15:39 +02:00
return E_OUTOFMEMORY;
object->IDirect3DRMLight_iface.lpVtbl = &d3drm_light_vtbl;
2012-05-01 22:15:39 +02:00
object->ref = 1;
*out = (IUnknown *)&object->IDirect3DRMLight_iface;
2012-05-01 22:15:39 +02:00
return S_OK;
}