예제 #1
0
        public override void Draw(GameTime gameTime, Frame frame)
        {
            var ir = new ImperativeRenderer(frame, Materials);

            ir.AutoIncrementLayer = true;

            ir.Clear(color: ClearColor);

            var rect1 = new Rectangle(0, 0, 32, 32);
            var rect2 = new Rectangle(1, 1, 30, 30);

            var drawSet = (Action <Rectangle, float>)((r, y) => {
                DrawRow(ref ir, 0f, y + 0f, SamplerState.PointClamp, r);
                DrawRow(ref ir, 0.5f, y + 1 + 64f, SamplerState.PointClamp, r);
                DrawRow(ref ir, 0f, (y + 3 + 128) + 0.5f, SamplerState.PointClamp, r);

                DrawRow(ref ir, 0f, y + 5 + 192f, SamplerState.LinearClamp, r);
                DrawRow(ref ir, 0.5f, y + 7 + 256f, SamplerState.LinearClamp, r);
                DrawRow(ref ir, 0f, (y + 9 + 320) + 0.5f, SamplerState.LinearClamp, r);
            });

            drawSet(rect1, 0f);

            drawSet(rect2, (70f * 6));

            var cornerSamplers = SamplerState.LinearClamp;

            ir.Draw(TestTexture, new Vector2(Graphics.PreferredBackBufferWidth - 1, Graphics.PreferredBackBufferHeight - 1), origin: new Vector2(1, 1), samplerState: cornerSamplers);
            ir.Draw(TestTexture, new Vector2(0, Graphics.PreferredBackBufferHeight - 1), origin: new Vector2(0, 1), samplerState: cornerSamplers);
            ir.Draw(TestTexture, new Vector2(Graphics.PreferredBackBufferWidth - 1, 0), origin: new Vector2(1, 0), samplerState: cornerSamplers);
        }
예제 #2
0
        public override void Draw(GameTime gameTime, Frame frame)
        {
            var ir = new ImperativeRenderer(frame, Materials, samplerState: SamplerState.LinearClamp);

            ir.AutoIncrementLayer = true;

            ir.Clear(color: ClearColor);

            Text.Position        = TopLeft;
            Text2.LineBreakAtX   = Text.LineBreakAtX = BottomRight.X - TopLeft.X;
            Text.WrapIndentation = Text2.WrapIndentation = Indent.Value ? 64 : 0;

            ir.OutlineRectangle(new Bounds(TopLeft, BottomRight), Color.Red);

            var layout = Text.Get();

            if (ShowOutlines.Value)
            {
                foreach (var dc in layout.DrawCalls)
                {
                    ir.OutlineRectangle(dc.EstimateDrawBounds(), Color.Blue);
                }
            }

            var m = Materials.Get(Materials.ScreenSpaceShadowedBitmap, blendState: BlendState.AlphaBlend);

            m.Parameters.ShadowColor.SetValue(new Vector4(0, 0, 0, 0.66f));
            m.Parameters.ShadowOffset.SetValue(new Vector2(3.5f, 3.5f));

            ir.OutlineRectangle(Bounds.FromPositionAndSize(Text.Position, layout.Size), Color.Yellow * 0.75f);
            ir.DrawMultiple(layout, material: m);

            if (Which.Value)
            {
                Text2.Position = TopLeft + new Vector2(0, layout.Size.Y + 20);
                layout         = Text2.Get();

                if (ShowOutlines.Value)
                {
                    foreach (var dc in layout.DrawCalls)
                    {
                        ir.OutlineRectangle(dc.EstimateDrawBounds(), Color.Blue);
                    }
                }

                ir.OutlineRectangle(Bounds.FromPositionAndSize(Text2.Position, layout.Size), Color.Yellow * 0.75f);
                ir.DrawMultiple(layout, material: m);
            }
        }
예제 #3
0
        public override void Draw(GameTime gameTime, Frame frame)
        {
            var ir = new ImperativeRenderer(frame, Materials);

            ir.AutoIncrementLayer = true;

            ir.Clear(color: ClearColor);

            DrawRow(ref ir, 16f, 16f, SamplerState.PointClamp);
            DrawRow(ref ir, 16.5f, 16 + 64f, SamplerState.PointClamp);
            DrawRow(ref ir, 16f, (16 + 128) + 0.5f, SamplerState.PointClamp);

            DrawRow(ref ir, 16f, 16 + 192f, SamplerState.LinearClamp);
            DrawRow(ref ir, 16.5f, 16 + 256f, SamplerState.LinearClamp);
            DrawRow(ref ir, 16f, (16 + 320) + 0.5f, SamplerState.LinearClamp);
        }
예제 #4
0
파일: Game.cs 프로젝트: 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)
                    );
            }
        }
예제 #5
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;
        }