private void RenderTextured(DX11RenderContext context) { quadshader.SelectTechnique("RenderTextured"); quadgeometry.Bind(quadlayouts[1]); for (int i = 0; i < this.spmax; i++) { bool popstate = false; if (this.FInState.PluginIO.IsConnected) { context.RenderStateStack.Push(this.FInState[i]); popstate = true; } if (this.FInSamplerState.PluginIO.IsConnected) { SamplerState state = SamplerState.FromDescription(context.Device, this.FInSamplerState[i]); samplervariable.SetSamplerState(0, state); } else { samplervariable.UndoSetSamplerState(0); } quadshader.SetBySemantic("COLOR", this.FInColor[i]); quadshader.SetBySemantic("WORLD", this.FInWorld[i]); quadshader.SetBySemantic("TEXTUREMATRIX", this.FInTexTransform[i]); if (this.FInTexture[i].Contains(context)) { texturevariable.SetResource(this.FInTexture[i][context].SRV); } else { texturevariable.SetResource(null); } quadshader.ApplyPass(0); quadgeometry.Draw(); if (popstate) { context.RenderStateStack.Pop(); } } }
public void Render(DX11RenderContext context) { if (this.lasthandle != this.Handle) { if (this.swapchain != null) { if (this.swapchain.Contains(context)) { this.swapchain.Dispose(context); } } this.lasthandle = this.Handle; } if (!this.swapchain.Contains(context)) { this.swapchain[context] = new DX11SwapChain(context, this.Handle, SlimDX.DXGI.Format.R8G8B8A8_UNorm, new SampleDescription(1, 0), 60, 1); } if (this.resized) { this.swapchain[context].Resize(); } if (this.FEnabled[0]) { context.CurrentDeviceContext.ClearRenderTargetView(this.swapchain[context].RTV, new SlimDX.Color4(0, 0, 0, 0)); } if (this.FIn.IsConnected && this.spreadMax > 0 && this.FEnabled[0]) { int id = this.FIndex[0]; if (this.FIn[id].Contains(context) && this.FIn[id][context] != null) { context.RenderTargetStack.Push(this.swapchain[context]); var rs = new DX11RenderState(); if (FAlpha[0]) { rs.Blend = DX11BlendStates.Instance.GetState("Blend"); context.CurrentDeviceContext.ClearRenderTargetView(this.swapchain[context].RTV, FInBgColor[0].Color); } context.RenderStateStack.Push(rs); context.CleanShaderStages(); context.Primitives.FullTriVS.GetVariableBySemantic("TEXTURE").AsResource().SetResource(this.FIn[id][context].SRV); EffectSamplerVariable samplervariable = context.Primitives.FullTriVS.GetVariableByName("linSamp").AsSampler(); SamplerState state = null; if (this.FInSamplerState.IsConnected) { state = SamplerState.FromDescription(context.Device, this.FInSamplerState[0]); samplervariable.SetSamplerState(0, state); } else { samplervariable.UndoSetSamplerState(0); } context.Primitives.FullScreenTriangle.Bind(null); context.Primitives.ApplyFullTri(); context.Primitives.FullScreenTriangle.Draw(); context.RenderStateStack.Pop(); context.RenderTargetStack.Pop(); context.CleanUpPS(); samplervariable.UndoSetSamplerState(0); //undo as can be used in other places if (state != null) { state.Dispose(); } } } }