Ejemplo n.º 1
0
        private void DrawPerformanceStats(ref ImperativeRenderer ir)
        {
            const float scale = 1f;
            var         text  = PerformanceStats.GetText(this);

            using (var buffer = BufferPool <BitmapDrawCall> .Allocate(text.Length)) {
                var layout     = Font.LayoutString(text, buffer, scale: scale);
                var layoutSize = layout.Size;
                var position   = new Vector2(30f, 30f);
                var dc         = layout.DrawCalls;

                ir.FillRectangle(
                    Bounds.FromPositionAndSize(position, layoutSize),
                    Color.Black
                    );
                ir.Layer += 1;
                ir.DrawMultiple(dc, position);
            }
        }
Ejemplo n.º 2
0
Archivo: Game.cs Proyecto: sq/FNATest
        public override void Draw(GameTime gameTime, Frame frame)
        {
            using (var rtb = BatchGroup.ForRenderTarget(frame, -1, Rt)) {
                var ir = new ImperativeRenderer(rtb, Materials);
                ir.Clear(color: Color.Transparent);
                ir.SetViewport(new Rectangle(128, 128, 256, 256), true);
                ir.FillRectangle(new Rectangle(0, 0, 512, 512), Color.Black, customMaterial: Vpos);
            }

            {
                var ir = new ImperativeRenderer(frame, Materials)
                {
                    AutoIncrementLayer = true
                };
                ir.SetViewport(null, true);
                ir.Clear(color: Color.SteelBlue);
                const float scale = 0.65f;
                var         pos   = new Vector2(Graphics.PreferredBackBufferWidth, Graphics.PreferredBackBufferHeight) / 2f;
                ir.Draw(
                    Texture, pos, origin: Vector2.One * 0.5f, scale: Vector2.One * scale,
                    blendState: BlendState.Opaque,
                    samplerState: SamplerState.LinearClamp
                    );

                ir.DrawString(
                    Font, "Hello, World!", Vector2.Zero,
                    blendState: BlendState.AlphaBlend,
                    material: Materials.ScreenSpaceShadowedBitmap
                    );

                var sg = ir.MakeSubgroup();
                sg.AutoIncrementLayer = true;
                sg.SetViewport(new Rectangle(128, 128, 512, 512), true);
                sg.FillRectangle(new Rectangle(0, 0, 1024, 1024), Color.Black, customMaterial: Vpos);
                sg.SetViewport(null, true);

                ir.Draw(
                    Rt, new Vector2(1920 - 512, 0)
                    );
            }
        }
Ejemplo n.º 3
0
        private void NestedContextPassTeardown(
            ref UIOperationContext context, ref DecorationSettings settings, IDecorator decorations,
            ref RasterizePassSet passSet, ref ImperativeRenderer contentRenderer, ref UIOperationContext contentContext,
            int previousStackDepth
            )
        {
            // If this is the first stencil pass instead of a nested one, clear the stencil buffer
            if (passSet.StackDepth < 1)
            {
                contentRenderer.Clear(stencil: 0, layer: -9999);
            }
            else
            {
                // Erase any siblings' clip regions
                contentRenderer.DepthStencilState = context.UIContext.GetStencilRestore(previousStackDepth);
                contentRenderer.FillRectangle(new Rectangle(-1, -1, 9999, 9999), Color.Transparent, blendState: RenderStates.DrawNone, layer: -1000);
            }

            contentRenderer.DepthStencilState = context.UIContext.GetStencilWrite(previousStackDepth);

            // FIXME: Separate context?
            contentContext.Pass = RasterizePasses.ContentClip;

            // FIXME
            var temp = settings;

            ApplyClipMargins(ref contentContext, ref temp.Box);

            var crLayer = contentRenderer.Layer;

            contentRenderer.Layer = -999;
            settings.State        = default(ControlStates);
            decorations?.Rasterize(ref contentContext, ref contentRenderer, temp);

            contentRenderer.Layer = crLayer;

            // passSet.NextReferenceStencil = childrenPassSet.NextReferenceStencil;
        }