/***************************************************************************** * IDirect3DViewport3::Clear * * Clears the render target and / or the z buffer * * Params: * dwCount: The amount of rectangles to clear. If 0, the whole buffer is * cleared * lpRects: Pointer to the array of rectangles. If NULL, Count must be 0 * dwFlags: D3DCLEAR_ZBUFFER and / or D3DCLEAR_TARGET * * Returns: * D3D_OK on success * D3DERR_VIEWPORTHASNODEVICE if there's no active device * The return value of IDirect3DDevice7::Clear * *****************************************************************************/ static HRESULT WINAPI IDirect3DViewportImpl_Clear(IDirect3DViewport3 *iface, DWORD dwCount, D3DRECT *lpRects, DWORD dwFlags) { ICOM_THIS_FROM(IDirect3DViewportImpl, IDirect3DViewport3, iface); DWORD color = 0x00000000; HRESULT hr; LPDIRECT3DVIEWPORT3 current_viewport; TRACE("(%p/%p)->(%08x,%p,%08x)\n", This, iface, dwCount, lpRects, dwFlags); if (This->active_device == NULL) { ERR(" Trying to clear a viewport not attached to a device !\n"); return D3DERR_VIEWPORTHASNODEVICE; } EnterCriticalSection(&ddraw_cs); if (dwFlags & D3DCLEAR_TARGET) { if (This->background == NULL) { ERR(" Trying to clear the color buffer without background material !\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); } } /* Need to temporarily activate viewport to clear it. Previously active one will be restored afterwards. */ This->activate(This, TRUE); hr = IDirect3DDevice7_Clear(ICOM_INTERFACE(This->active_device, IDirect3DDevice7), dwCount, lpRects, dwFlags & (D3DCLEAR_ZBUFFER | D3DCLEAR_TARGET), color, 1.0, 0x00000000); IDirect3DDevice3_GetCurrentViewport(ICOM_INTERFACE(This->active_device, IDirect3DDevice3), ¤t_viewport); if(current_viewport) { IDirect3DViewportImpl *vp = ICOM_OBJECT(IDirect3DViewportImpl, IDirect3DViewport3, current_viewport); vp->activate(vp, TRUE); IDirect3DViewport3_Release(current_viewport); } LeaveCriticalSection(&ddraw_cs); return hr; }
/***************************************************************************** * IDirect3DViewport3::Clear * * Clears the render target and / or the z buffer * * Params: * dwCount: The amount of rectangles to clear. If 0, the whole buffer is * cleared * lpRects: Pointer to the array of rectangles. If NULL, Count must be 0 * dwFlags: D3DCLEAR_ZBUFFER and / or D3DCLEAR_TARGET * * Returns: * D3D_OK on success * D3DERR_VIEWPORTHASNODEVICE if there's no active device * The return value of IDirect3DDevice7::Clear * *****************************************************************************/ static HRESULT WINAPI IDirect3DViewportImpl_Clear(IDirect3DViewport3 *iface, DWORD dwCount, D3DRECT *lpRects, DWORD dwFlags) { IDirect3DViewportImpl *This = (IDirect3DViewportImpl *)iface; DWORD color = 0x00000000; HRESULT hr; LPDIRECT3DVIEWPORT3 current_viewport; IDirect3DDevice3 *d3d_device3; TRACE("iface %p, rect_count %u, rects %p, flags %#x.\n", iface, dwCount, lpRects, dwFlags); if (This->active_device == NULL) { ERR(" Trying to clear a viewport not attached to a device !\n"); return D3DERR_VIEWPORTHASNODEVICE; } d3d_device3 = (IDirect3DDevice3 *)&This->active_device->IDirect3DDevice3_vtbl; EnterCriticalSection(&ddraw_cs); if (dwFlags & D3DCLEAR_TARGET) { if (This->background == NULL) { ERR(" Trying to clear the color buffer without background material !\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); } } /* Need to temporarily activate viewport to clear it. Previously active one will be restored afterwards. */ viewport_activate(This, TRUE); hr = IDirect3DDevice7_Clear((IDirect3DDevice7 *)This->active_device, dwCount, lpRects, dwFlags & (D3DCLEAR_ZBUFFER | D3DCLEAR_TARGET), color, 1.0, 0x00000000); IDirect3DDevice3_GetCurrentViewport(d3d_device3, ¤t_viewport); if(current_viewport) { IDirect3DViewportImpl *vp = (IDirect3DViewportImpl *)current_viewport; viewport_activate(vp, TRUE); IDirect3DViewport3_Release(current_viewport); } LeaveCriticalSection(&ddraw_cs); return hr; }
void clear_zbuffer_screen_using_viewport ( void ) { // ASSERT ( !d3d_in_3d_scene ); if ( d3d.device ) { #ifdef _WIN32 unsigned int ret; ret = IDirect3DDevice7_Clear ( d3d.device, 0, NULL, D3DCLEAR_ZBUFFER, 0, 1.0, 0 ); if ( ret != DD_OK ) { debug_log ( "Unable to clear zbuffer: %s", get_d3d_error_message ( ret ) ); } #endif } }
/***************************************************************************** * IDirect3DViewport3::Clear2 * * Another clearing method * * Params: * Count: Number of rectangles to clear * Rects: Rectangle array to clear * Flags: Some flags :) * Color: Color to fill the render target with * Z: Value to fill the depth buffer with * Stencil: Value to fill the stencil bits with * * Returns: * *****************************************************************************/ static HRESULT WINAPI IDirect3DViewportImpl_Clear2(IDirect3DViewport3 *iface, DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags, DWORD dwColor, D3DVALUE dvZ, DWORD dwStencil) { ICOM_THIS_FROM(IDirect3DViewportImpl, IDirect3DViewport3, iface); HRESULT hr; LPDIRECT3DVIEWPORT3 current_viewport; TRACE("(%p)->(%08x,%p,%08x,%08x,%f,%08x)\n", This, dwCount, lpRects, dwFlags, dwColor, dvZ, dwStencil); EnterCriticalSection(&ddraw_cs); if (This->active_device == NULL) { ERR(" Trying to clear a viewport not attached to a device !\n"); LeaveCriticalSection(&ddraw_cs); return D3DERR_VIEWPORTHASNODEVICE; } /* Need to temporarily activate viewport to clear it. Previously active one will be restored afterwards. */ This->activate(This, TRUE); hr = IDirect3DDevice7_Clear(ICOM_INTERFACE(This->active_device, IDirect3DDevice7), dwCount, lpRects, dwFlags, dwColor, dvZ, dwStencil); IDirect3DDevice3_GetCurrentViewport(ICOM_INTERFACE(This->active_device, IDirect3DDevice3), ¤t_viewport); if(current_viewport) { IDirect3DViewportImpl *vp = ICOM_OBJECT(IDirect3DViewportImpl, IDirect3DViewport3, current_viewport); vp->activate(vp, TRUE); IDirect3DViewport3_Release(current_viewport); } LeaveCriticalSection(&ddraw_cs); return hr; }
/***************************************************************************** * IDirect3DViewport3::Clear2 * * Another clearing method * * Params: * Count: Number of rectangles to clear * Rects: Rectangle array to clear * Flags: Some flags :) * Color: Color to fill the render target with * Z: Value to fill the depth buffer with * Stencil: Value to fill the stencil bits with * * Returns: * *****************************************************************************/ static HRESULT WINAPI IDirect3DViewportImpl_Clear2(IDirect3DViewport3 *iface, DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags, DWORD dwColor, D3DVALUE dvZ, DWORD dwStencil) { IDirect3DViewportImpl *This = (IDirect3DViewportImpl *)iface; HRESULT hr; LPDIRECT3DVIEWPORT3 current_viewport; IDirect3DDevice3 *d3d_device3; TRACE("iface %p, rect_count %u, rects %p, flags %#x, color 0x%08x, depth %.8e, stencil %u.\n", iface, dwCount, lpRects, dwFlags, dwColor, dvZ, dwStencil); EnterCriticalSection(&ddraw_cs); if (This->active_device == NULL) { ERR(" Trying to clear a viewport not attached to a device !\n"); LeaveCriticalSection(&ddraw_cs); return D3DERR_VIEWPORTHASNODEVICE; } d3d_device3 = (IDirect3DDevice3 *)&This->active_device->IDirect3DDevice3_vtbl; /* Need to temporarily activate viewport to clear it. Previously active * one will be restored afterwards. */ viewport_activate(This, TRUE); hr = IDirect3DDevice7_Clear((IDirect3DDevice7 *)This->active_device, dwCount, lpRects, dwFlags, dwColor, dvZ, dwStencil); IDirect3DDevice3_GetCurrentViewport(d3d_device3, ¤t_viewport); if(current_viewport) { IDirect3DViewportImpl *vp = (IDirect3DViewportImpl *)current_viewport; viewport_activate(vp, TRUE); IDirect3DViewport3_Release(current_viewport); } LeaveCriticalSection(&ddraw_cs); return hr; }