コード例 #1
0
        public void Draw(RenderComposer composer)
        {
            // The vertices were taken from a font, and the polygon is huge.
            composer.PushModelMatrix(Matrix4x4.CreateScale(0.1f, 0.1f, 1f));

            composer.SetStencilTest(true);
            composer.StencilWindingStart();
            composer.ToggleRenderColor(false);

            // Draw all of them together. Winding will take care of the overlap.
            var accum = Rectangle.Empty;

            for (var i = 0; i < _testPolygon.Length; i++)
            {
                composer.RenderVertices(_testPolygon[i].Vertices, Color.White);
                accum = accum.Union(_testPolygon[i].Bounds2D);
            }

            composer.StencilWindingEnd();
            composer.ToggleRenderColor(true);

            // You need one quad which covers the bounds of all the polygons.
            // In this case I added the bounding boxes, but you could just draw a screen sized quad.
            composer.RenderSprite(accum, Color.Red);

            composer.SetStencilTest(false);

            composer.PopModelMatrix();
        }
コード例 #2
0
ファイル: UIStencilWindow.cs プロジェクト: Cryru/Emotion
        protected override bool RenderInternal(RenderComposer c)
        {
            c.SetStencilTest(true);
            c.ToggleRenderColor(false);
            c.StencilStartDraw();
            c.RenderSprite(this, Color.White);
            c.ToggleRenderColor(true);
            c.StencilFillIn();

            return(base.RenderInternal(c));
        }