protected override void OnPaint(PaintEventArgs e) { if (LicenseManager.UsageMode != LicenseUsageMode.Runtime || Device == null || SwapChain == null) { e.Graphics.DrawString("Rendering: Not Available in form designer!", Font, Brushes.DarkGray, ClientRectangle, new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }); return; } SwapChain.Clear(ClearColor); OnDraw(); SwapChain.Present(); }
protected virtual void Render(IRenderer renderer) { //Get the window's swap chain SwapChain swapChain = _window.SwapChain; //Primary drawing to the window, sets the backbuffer render targets and clears them swapChain.Clear(_clearColor); if (_wireFrame) { renderer.EnforcedRasterizerState = RasterizerState.CullNoneWireframe; } OnRenderPre(renderer); //Draw the scenegraph _rootNode.Draw(renderer); //Debbuging for bounding volumes if (_debugBounds) { GeometryDebugger.DrawBounds(_rootNode, renderer); } //Debugging for normals and tangents/binormals if they exist for the mesh if (_debugNormals) { GeometryDebugger.DrawTangentBasis(_rootNode, renderer); } if (_wireFrameSolid) { renderer.RenderQueue.SortAndRender(); //renderer.EnforcedRasterizerState = RasterizerState.CullNoneWireframe; RasterizerState rs = new RasterizerState(); rs.Cull = CullMode.None; rs.DepthBias = -100; rs.SlopeScaledDepthBias = 5f; rs.Fill = FillMode.WireFrame; renderer.EnforcedRasterizerState = rs; renderer.EnforcedMaterial = _wireFrameSolidMat; renderer.RenderQueue.RenderBuckets(); renderer.RenderQueue.ClearBuckets(); renderer.ClearEnforcedStates(); renderer.EnforcedMaterial = null; } else { //Finally sort the render queue and draw remaining elements renderer.RenderQueue.SortRenderClear(); } //Any extra rendering OnRenderPost(renderer); if (_wireFrame || _wireFrameSolid) { renderer.ClearEnforcedState(RenderStateType.RasterizerState); } //Lastly, draw GUI - we do this via a spritebatch and do it last //so it's rendered over everything (including anything from OnRender() DrawInstructions(renderer); //Present to the window swapChain.Present(); //Count the frame for FPS display CountFrame(); }
// Start is called before the first frame update void Start() { Debug.Log("TestSwapChain begin"); var chain = new SwapChain <string>(); chain.Clear(); chain.AddFront("b1"); chain.AddBack("b2"); Debug.Assert(chain.GetFront() == "b1"); Debug.Assert(chain.GetBack() == "b2"); Error.Catch <System.IndexOutOfRangeException>(() => chain.GetBack(1)); chain.Swap(); Debug.Assert(chain.GetFront() == "b2"); Debug.Assert(chain.GetBack() == "b1"); Error.Catch <System.IndexOutOfRangeException>(() => chain.GetBack(1)); chain.Clear(); chain.AddFront("b1"); chain.AddBack("b2"); chain.AddBack("b3"); Debug.Assert(chain.GetFront() == "b1"); Debug.Assert(chain.GetBack() == "b2"); Debug.Assert(chain.GetBack(1) == "b3"); Error.Catch <System.IndexOutOfRangeException>(() => chain.GetBack(2)); chain.Swap(); Debug.Assert(chain.GetFront() == "b2"); Debug.Assert(chain.GetBack() == "b3"); Debug.Assert(chain.GetBack(1) == "b1"); Error.Catch <System.IndexOutOfRangeException>(() => chain.GetBack(2)); chain.Swap(); Debug.Assert(chain.GetFront() == "b3"); Debug.Assert(chain.GetBack() == "b1"); Debug.Assert(chain.GetBack(1) == "b2"); Error.Catch <System.IndexOutOfRangeException>(() => chain.GetBack(2)); chain.Swap(); Debug.Assert(chain.GetFront() == "b1"); Debug.Assert(chain.GetBack() == "b2"); Debug.Assert(chain.GetBack(1) == "b3"); Error.Catch <System.IndexOutOfRangeException>(() => chain.GetBack(2)); chain.Clear(); chain.AddBack("b1"); chain.AddBack("b2"); Error.Catch <System.IndexOutOfRangeException>(() => chain.GetFront()); Debug.Assert(chain.GetBack() == "b1"); Error.Catch <System.IndexOutOfRangeException>(() => chain.GetBack(1)); chain.Swap(); Debug.Assert(chain.GetFront() == "b1"); Debug.Assert(chain.GetBack() == "b2"); Error.Catch <System.IndexOutOfRangeException>(() => chain.GetBack(1)); chain.Swap(); Debug.Assert(chain.GetFront() == "b2"); Debug.Assert(chain.GetBack() == "b1"); Error.Catch <System.IndexOutOfRangeException>(() => chain.GetBack(1)); chain.Swap(); Debug.Assert(chain.GetFront() == "b1"); Debug.Assert(chain.GetBack() == "b2"); Error.Catch <System.IndexOutOfRangeException>(() => chain.GetBack(1)); Debug.Log("TestSwapChain end"); }