Пример #1
0
        public Renderer(int passes, ViewportPolicy viewportPolicy, RenderOptions renderOptions)
        {
            this.Passes = passes;
            this.Policy = viewportPolicy;
            this.Options = renderOptions;
            this.sortMode = Renderer.ToSortMode(renderOptions);
            this.blendState = Renderer.ToBlendState(renderOptions);

            // Doing a GlobalRenderLock because Renderer objects might be constructed in different threads.
            lock (PhantomGame.Game.GlobalRenderLock)
            {
                if ((renderOptions & RenderOptions.Canvas) == RenderOptions.Canvas)
                    this.canvas = new Canvas(PhantomGame.Game.GraphicsDevice);
                this.batch = new SpriteBatch(PhantomGame.Game.GraphicsDevice);
            }

            if (this.sortMode == SpriteSortMode.Immediate)
                this.activeRenderPass = this.RenderPassFullLock;
            else
                this.activeRenderPass = this.RenderPassEndLock;
        }
Пример #2
0
        public void ChangeOptions(ViewportPolicy viewportPolicy, RenderOptions renderOptions)
        {
            this.Policy = viewportPolicy;

            this.Options = renderOptions;
            bool wantCanvas = (renderOptions & RenderOptions.Canvas) == RenderOptions.Canvas;
            if (this.canvas == null && wantCanvas)
                this.canvas = new Canvas(PhantomGame.Game.GraphicsDevice);
            else if (this.canvas != null && !wantCanvas)
                this.canvas = null;

            if (!renderOptions.HasFlag(RenderOptions.ApplyEffect))
                this.fx = null;

            this.sortMode = Renderer.ToSortMode(renderOptions);
            this.blendState = Renderer.ToBlendState(renderOptions);

            if (this.sortMode == SpriteSortMode.Immediate)
                this.activeRenderPass = this.RenderPassFullLock;
            else
                this.activeRenderPass = this.RenderPassEndLock;
        }
Пример #3
0
 private void DrawVector(Canvas canvas, Vector2 start, Vector2 end, string name)
 {
     Vector2 unit = end - start;
     if (unit.Length() > 0.1f)
     {
         unit.Normalize();
         Vector2 right = unit.RightPerproduct();
         canvas.Begin();
         canvas.MoveTo(start);
         canvas.LineTo(end);
         canvas.MoveTo(end - unit * 5 + right * 5);
         canvas.LineTo(end);
         canvas.LineTo(end - unit * 5 - right * 5);
         canvas.LineWidth = this.defaultLineWidth*3;
         canvas.StrokeColor = DebugLayer.Shadow;
         canvas.Stroke();
         canvas.LineWidth = this.defaultLineWidth;
         canvas.StrokeColor = GetColor(name);
         canvas.Stroke();
     }
 }