return DDERR_UNSUPPORTED;
}
-/*****************************************************************************
- * IDirect3DViewport3::SetBackground
- *
- * Sets the background material
- *
- * Params:
- * hMat: Handle from a IDirect3DMaterial interface
- *
- * Returns:
- * D3D_OK on success
- *
- *****************************************************************************/
-static HRESULT WINAPI d3d_viewport_SetBackground(IDirect3DViewport3 *iface, D3DMATERIALHANDLE hMat)
+static HRESULT WINAPI d3d_viewport_SetBackground(IDirect3DViewport3 *iface, D3DMATERIALHANDLE material)
{
struct d3d_viewport *viewport = impl_from_IDirect3DViewport3(iface);
struct d3d_material *m;
- TRACE("iface %p, material %#x.\n", iface, hMat);
+ TRACE("iface %p, material %#x.\n", iface, material);
wined3d_mutex_lock();
- if (!hMat)
+ if (!(m = ddraw_get_object(&viewport->ddraw->d3ddevice->handle_table, material - 1, DDRAW_HANDLE_MATERIAL)))
{
- viewport->background = NULL;
- TRACE("Setting background to NULL\n");
- wined3d_mutex_unlock();
- return D3D_OK;
- }
-
- m = ddraw_get_object(&viewport->ddraw->d3ddevice->handle_table, hMat - 1, DDRAW_HANDLE_MATERIAL);
- if (!m)
- {
- WARN("Invalid material handle.\n");
+ WARN("Invalid material handle %#x.\n", material);
wined3d_mutex_unlock();
return DDERR_INVALIDPARAMS;
}
if (flags & D3DCLEAR_TARGET)
{
- if (This->background == NULL) {
- ERR(" Trying to clear the color buffer without background material!\n");
- }
+ if (!This->background)
+ WARN("No background material set.\n");
else
- {
- color = ((int)((This->background->mat.u.diffuse.u1.r) * 255) << 16)
- | ((int) ((This->background->mat.u.diffuse.u2.g) * 255) << 8)
- | ((int) ((This->background->mat.u.diffuse.u3.b) * 255) << 0)
- | ((int) ((This->background->mat.u.diffuse.u4.a) * 255) << 24);
- }
+ color = D3DRGBA(This->background->mat.u.diffuse.u1.r,
+ This->background->mat.u.diffuse.u2.g,
+ This->background->mat.u.diffuse.u3.b,
+ This->background->mat.u.diffuse.u4.a);
}
/* Need to temporarily activate viewport to clear it. Previously active one will be restored