Exemplo n.º 1
0
        public override void Update()
        {
            if (renderChain == null)
            {
                InitRenderChain();
            }

            if (renderChain == null || renderChain.device == null)
            {
                return;
            }

            renderChain.ProcessChanges();

            PanelClearSettings clearSettings = panel.clearSettings;

            if (clearSettings.clearColor || clearSettings.clearDepthStencil)
            {
                // Case 1277149: Clear color must be pre-multiplied like when we render.
                Color clearColor = clearSettings.color;
                clearColor = clearColor.RGBMultiplied(clearColor.a);

                GL.Clear(clearSettings.clearDepthStencil, // Clearing may impact MVP
                         clearSettings.clearColor, clearColor, UIRUtility.k_ClearZ);
            }

            // Apply these debug values every frame because the render chain may have been recreated.
            renderChain.drawStats           = drawStats;
            renderChain.device.breakBatches = breakBatches;

            renderChain.Render();
        }
        public override void Update()
        {
            if (renderChain == null)
            {
                InitRenderChain();
            }

            if (renderChain == null || renderChain.device == null)
            {
                return;
            }

            using (s_MarkerDrawChain.Auto())
            {
                renderChain.ProcessChanges();

                PanelClearSettings clearSettings = panel.clearSettings;
                if (clearSettings.clearColor || clearSettings.clearDepthStencil)
                {
                    // Case 1277149: Clear color must be pre-multiplied like when we render.
                    Color clearColor = clearSettings.color;
                    clearColor = clearColor.RGBMultiplied(clearColor.a);

                    GL.Clear(clearSettings.clearDepthStencil, // Clearing may impact MVP
                             clearSettings.clearColor, clearColor, UIRUtility.k_ClearZ);
                }

                renderChain.Render();
            }
        }
Exemplo n.º 3
0
 protected virtual void DrawChain(Rect viewport, Matrix4x4 projection)
 {
     using (s_MarkerDrawChain.Auto())
     {
         renderChain.Render(viewport, projection, panel.clearFlags);
     }
 }
 protected virtual void DrawChain(Rect topRect, Matrix4x4 projection)
 {
     Profiler.BeginSample("DrawChain");
     try
     {
         renderChain.Render(topRect, projection);
     }
     finally
     {
         Profiler.EndSample();
     }
 }
        public override void Update()
        {
            if (renderChain?.device == null)
            {
                return;
            }

            using (s_MarkerDrawChain.Auto())
            {
                renderChain.ProcessChanges();

                PanelClearFlags clearFlags = panel.clearFlags;
                if (clearFlags != PanelClearFlags.None)
                {
                    GL.Clear((clearFlags & PanelClearFlags.Depth) != 0, // Clearing may impact MVP
                             (clearFlags & PanelClearFlags.Color) != 0, Color.clear, UIRUtility.k_ClearZ);
                }

                renderChain.Render();
            }
        }
Exemplo n.º 6
0
 public static void RenderToTexture(this Widget widget, ITexture texture, RenderChain renderChain, bool clearRenderTarget = true)
 {
     if (widget.Width > 0 && widget.Height > 0)
     {
         texture.SetAsRenderTarget();
         Renderer.PushState(
             RenderState.ScissorState |
             RenderState.View |
             RenderState.World |
             RenderState.View |
             RenderState.Projection |
             RenderState.DepthState |
             RenderState.CullMode |
             RenderState.Transform2);
         Renderer.ScissorState = ScissorState.ScissorDisabled;
         Renderer.Viewport     = new Viewport(0, 0, texture.ImageSize.Width, texture.ImageSize.Height);
         if (clearRenderTarget)
         {
             Renderer.Clear(new Color4(0, 0, 0, 0));
         }
         Renderer.World = Matrix44.Identity;
         Renderer.View  = Matrix44.Identity;
         Renderer.SetOrthogonalProjection(0, 0, widget.Width, widget.Height);
         Renderer.DepthState = DepthState.DepthDisabled;
         Renderer.CullMode   = CullMode.None;
         Renderer.Transform2 = widget.LocalToWorldTransform.CalcInversed();
         try {
             for (var node = widget.FirstChild; node != null; node = node.NextSibling)
             {
                 node.RenderChainBuilder?.AddToRenderChain(renderChain);
             }
             renderChain.Render();
         } finally {
             renderChain.Clear();
         }
         Renderer.PopState();
         texture.RestoreRenderTarget();
     }
 }
Exemplo n.º 7
0
 public static void RenderAndClear(this RenderChain renderChain)
 {
     renderChain.Render();
     renderChain.Clear();
 }