public bool DrawScene(DeviceContextHolder holder, IReflectionDraw draw, int facesPerFrame) { if (facesPerFrame == 0 || _dirty.All(x => !x)) { return(true); } using (holder.SaveRenderTargetAndViewport()) { holder.DeviceContext.Rasterizer.SetViewports(_viewport); var offset = _previouslyUpdated + 1; for (var k = 0; k < 6; k++) { var i = (k + offset) % 6; if (_dirty[i] && --facesPerFrame >= 0) { _dirty[i] = false; holder.DeviceContext.ClearRenderTargetView(_targetView[i], BackgroundColor); holder.DeviceContext.ClearDepthStencilView(_depthTargetView, DepthStencilClearFlags.Depth, 1.0f, 0); holder.DeviceContext.OutputMerger.SetTargets(_depthTargetView, _targetView[i]); draw.DrawSceneForReflection(holder, _cameras[i]); _previouslyUpdated = i; } } holder.DeviceContext.GenerateMips(_view); } return(facesPerFrame >= 0); }
public void DrawScene(DeviceContextHolder holder, IReflectionDraw draw) { holder.SaveRenderTargetAndViewport(); holder.DeviceContext.Rasterizer.SetViewports(_viewport); for (var i = 0; i < 6; i++) { holder.DeviceContext.ClearRenderTargetView(_targetView[i], BackgroundColor); holder.DeviceContext.ClearDepthStencilView(_depthTargetView, DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil, 1.0f, 0); holder.DeviceContext.OutputMerger.SetTargets(_depthTargetView, _targetView[i]); draw.DrawSceneForReflection(holder, _cameras[i]); } holder.DeviceContext.GenerateMips(_view); holder.RestoreRenderTargetAndViewport(); }
public void DrawScene(DeviceContextHolder holder, IReflectionDraw draw) { holder.SaveRenderTargetAndViewport(); holder.DeviceContext.Rasterizer.SetViewports(_viewport); for (var i = 0; i < 6; i++) { holder.DeviceContext.ClearRenderTargetView(_targetView[i], new Color4(0)); holder.DeviceContext.ClearDepthStencilView(_depthTargetView, DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil, 1.0f, 0); holder.DeviceContext.OutputMerger.SetTargets(_depthTargetView, _targetView[i]); draw.DrawSceneForReflection(holder, _cameras[i]); } holder.DeviceContext.GenerateMips(_view); holder.RestoreRenderTargetAndViewport(); }