Esempio n. 1
0
struct d3d_light *unsafe_impl_from_IDirect3DLight(IDirect3DLight *iface)
{
    if (!iface)
        return NULL;
    assert(iface->lpVtbl == &d3d_light_vtbl);

    return impl_from_IDirect3DLight(iface);
}
Esempio n. 2
0
static ULONG WINAPI d3d_light_AddRef(IDirect3DLight *iface)
{
    struct d3d_light *light = impl_from_IDirect3DLight(iface);
    ULONG ref = InterlockedIncrement(&light->ref);

    TRACE("%p increasing refcount to %u.\n", light, ref);

    return ref;
}
Esempio n. 3
0
static ULONG WINAPI IDirect3DLightImpl_AddRef(IDirect3DLight *iface)
{
    IDirect3DLightImpl *This = impl_from_IDirect3DLight(iface);
    ULONG ref = InterlockedIncrement(&This->ref);

    TRACE("%p increasing refcount to %u.\n", This, ref);

    return ref;
}
Esempio n. 4
0
/*****************************************************************************
 * IDirect3DLight::GetLight
 *
 * Returns the parameters currently assigned to the IDirect3DLight object
 *
 * Params:
 *  Light: Pointer to an D3DLIGHT structure to store the parameters
 *
 * Returns:
 *  D3D_OK on success
 *  DDERR_INVALIDPARAMS if Light is NULL
 *****************************************************************************/
static HRESULT WINAPI d3d_light_GetLight(IDirect3DLight *iface, D3DLIGHT *lpLight)
{
    struct d3d_light *light = impl_from_IDirect3DLight(iface);

    TRACE("iface %p, light %p.\n", iface, lpLight);

    wined3d_mutex_lock();
    memcpy(lpLight, &light->light, lpLight->dwSize);
    wined3d_mutex_unlock();

    return DD_OK;
}
Esempio n. 5
0
static ULONG WINAPI IDirect3DLightImpl_Release(IDirect3DLight *iface)
{
    IDirect3DLightImpl *This = impl_from_IDirect3DLight(iface);
    ULONG ref = InterlockedDecrement(&This->ref);

    TRACE("%p decreasing refcount to %u.\n", This, ref);

    if (!ref) {
        HeapFree(GetProcessHeap(), 0, This);
        return 0;
    }
    return ref;
}
Esempio n. 6
0
static ULONG WINAPI d3d_light_Release(IDirect3DLight *iface)
{
    struct d3d_light *light = impl_from_IDirect3DLight(iface);
    ULONG ref = InterlockedDecrement(&light->ref);

    TRACE("%p decreasing refcount to %u.\n", light, ref);

    if (!ref)
    {
        HeapFree(GetProcessHeap(), 0, light);
        return 0;
    }
    return ref;
}
Esempio n. 7
0
static HRESULT WINAPI d3d_light_SetLight(IDirect3DLight *iface, D3DLIGHT *data)
{
    struct d3d_light *light = impl_from_IDirect3DLight(iface);
    DWORD flags = data->dwSize >= sizeof(D3DLIGHT2) ? ((D3DLIGHT2 *)data)->dwFlags : D3DLIGHT_ACTIVE;
    D3DLIGHT7 *light7 = &light->light7;

    TRACE("iface %p, data %p.\n", iface, data);

    if ((!data->dltType) || (data->dltType > D3DLIGHT_PARALLELPOINT))
         return DDERR_INVALIDPARAMS;

    if (data->dltType == D3DLIGHT_PARALLELPOINT)
        FIXME("D3DLIGHT_PARALLELPOINT not implemented.\n");

    /* Translate D3DLIGHT2 structure to D3DLIGHT7. */
    light7->dltType = data->dltType;
    light7->dcvDiffuse = data->dcvColor;
    if (!(flags & D3DLIGHT_NO_SPECULAR))
        light7->dcvSpecular = data->dcvColor;
    else
        light7->dcvSpecular = *(const D3DCOLORVALUE *)zero_value;
    light7->dcvAmbient = data->dcvColor;
    light7->dvPosition = data->dvPosition;
    light7->dvDirection = data->dvDirection;
    light7->dvRange = data->dvRange;
    light7->dvFalloff = data->dvFalloff;
    light7->dvAttenuation0 = data->dvAttenuation0;
    light7->dvAttenuation1 = data->dvAttenuation1;
    light7->dvAttenuation2 = data->dvAttenuation2;
    light7->dvTheta = data->dvTheta;
    light7->dvPhi = data->dvPhi;

    wined3d_mutex_lock();
    memcpy(&light->light, data, sizeof(D3DLIGHT));
    if (!(light->light.dwFlags & D3DLIGHT_ACTIVE) && flags & D3DLIGHT_ACTIVE)
        light_activate(light);
    else if (light->light.dwFlags & D3DLIGHT_ACTIVE && !(flags & D3DLIGHT_ACTIVE))
        light_deactivate(light);
    else if (flags & D3DLIGHT_ACTIVE)
        light_update(light);
    light->light.dwFlags = flags;
    wined3d_mutex_unlock();

    return D3D_OK;
}
Esempio n. 8
0
static HRESULT WINAPI IDirect3DLightImpl_SetLight(IDirect3DLight *iface, D3DLIGHT *lpLight)
{
    IDirect3DLightImpl *This = impl_from_IDirect3DLight(iface);
    LPD3DLIGHT7 light7 = &This->light7;

    TRACE("iface %p, light %p.\n", iface, lpLight);

    if (TRACE_ON(ddraw))
    {
        TRACE("  Light definition :\n");
        dump_light((LPD3DLIGHT2) lpLight);
    }

    if ( (lpLight->dltType == 0) || (lpLight->dltType > D3DLIGHT_PARALLELPOINT) )
         return DDERR_INVALIDPARAMS;

    if ( lpLight->dltType == D3DLIGHT_PARALLELPOINT )
        FIXME("D3DLIGHT_PARALLELPOINT no supported\n");

    /* Translate D3DLIGH2 structure to D3DLIGHT7 */
    light7->dltType        = lpLight->dltType;
    light7->dcvDiffuse     = lpLight->dcvColor;
    if ((((LPD3DLIGHT2)lpLight)->dwFlags & D3DLIGHT_NO_SPECULAR) != 0)
      light7->dcvSpecular    = lpLight->dcvColor;
    else
      light7->dcvSpecular    = *(const D3DCOLORVALUE*)zero_value;
    light7->dcvAmbient     = lpLight->dcvColor;
    light7->dvPosition     = lpLight->dvPosition;
    light7->dvDirection    = lpLight->dvDirection;
    light7->dvRange        = lpLight->dvRange;
    light7->dvFalloff      = lpLight->dvFalloff;
    light7->dvAttenuation0 = lpLight->dvAttenuation0;
    light7->dvAttenuation1 = lpLight->dvAttenuation1;
    light7->dvAttenuation2 = lpLight->dvAttenuation2;
    light7->dvTheta        = lpLight->dvTheta;
    light7->dvPhi          = lpLight->dvPhi;

    wined3d_mutex_lock();
    memcpy(&This->light, lpLight, lpLight->dwSize);
    if (This->light.dwFlags & D3DLIGHT_ACTIVE)
        light_update(This);
    wined3d_mutex_unlock();

    return D3D_OK;
}
Esempio n. 9
0
/*****************************************************************************
 * IDirect3DLight::GetLight
 *
 * Returns the parameters currently assigned to the IDirect3DLight object
 *
 * Params:
 *  Light: Pointer to an D3DLIGHT structure to store the parameters
 *
 * Returns:
 *  D3D_OK on success
 *  DDERR_INVALIDPARAMS if Light is NULL
 *****************************************************************************/
static HRESULT WINAPI IDirect3DLightImpl_GetLight(IDirect3DLight *iface, D3DLIGHT *lpLight)
{
    IDirect3DLightImpl *This = impl_from_IDirect3DLight(iface);

    TRACE("iface %p, light %p.\n", iface, lpLight);

    if (TRACE_ON(ddraw))
    {
        TRACE("  Returning light definition :\n");
        dump_light(&This->light);
    }

    wined3d_mutex_lock();
    memcpy(lpLight, &This->light, lpLight->dwSize);
    wined3d_mutex_unlock();

    return DD_OK;
}