コード例 #1
0
        public void Dispose()
        {
            if (!UISpriteBatch.Invalidated)
            {
                Batch.Pause();

                GD.SetRenderTarget(null);
                Texture.SetValue(Target);
                Batch.Resume();

                Batch.FreeBuffer(Target);
            }
        }
コード例 #2
0
ファイル: UISpriteBatch.cs プロジェクト: Daribon/FreeSO
        public UIRenderPlane(UISpriteBatch batch, Promise<Texture2D> texture)
        {
            this.GD = batch.GraphicsDevice;
            this.Target = batch.GetBuffer();
            this.Texture = texture;
            this.Batch = batch;

            if(!UISpriteBatch.Invalidated)
            {
                /** Switch the render target **/
                Batch.Pause();
                GD.SetRenderTarget(Target);
                GD.Clear(Color.Transparent);
                Batch.Resume();
            }
        }
コード例 #3
0
        public UIRenderPlane(UISpriteBatch batch, Promise <Texture2D> texture)
        {
            this.GD      = batch.GraphicsDevice;
            this.Target  = batch.GetBuffer();
            this.Texture = texture;
            this.Batch   = batch;

            if (!UISpriteBatch.Invalidated)
            {
                /** Switch the render target **/
                Batch.Pause();
                GD.SetRenderTarget(Target);
                GD.Clear(Color.Transparent);
                Batch.Resume();
            }
        }
コード例 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="batch"></param>
        /// <param name="mtx"></param>
        public override void Draw(UISpriteBatch batch)
        {
            if (Width == 0 || Height == 0 || !DoRedraw)
            {
                return;
            }
            DoRedraw = false;
            batch    = Batch;
            batch.UIBegin(BlendState.AlphaBlend, SpriteSortMode.Deferred);
            Promise <Texture2D> bufferTexture = null;

            using (batch.WithBuffer(ref bufferTexture))
            {
                lock (Children)
                {
                    foreach (var child in Children)
                    {
                        child.PreDraw(batch);
                    }
                    foreach (var child in Children)
                    {
                        child.Draw(batch);
                    }
                }
                batch.Pause();
                batch.Resume();
            }

            var tex = bufferTexture.Get();

            batch.End();

            tex.GetData(RawImage, 0, (GameFacade.DirectX) ? RawImage.Length : RawImage.Length / 4);

            for (int i = 0; i < RawImage.Length; i += 4)
            {
                var swap = RawImage[i];
                RawImage[i]     = RawImage[i + 2];
                RawImage[i + 2] = swap;
            }
            if (OnFrame != null)
            {
                OnFrame();
            }
            //batch.Draw(tex, Vector2.Zero, _BlendColor);
        }
コード例 #5
0
        public override void Draw(UISpriteBatch batch)
        {
            base.Draw(batch);
            var bg = EditorComponent.EditorResource.Get().ViewBG;
            var viewport = GameFacade.GraphicsDevice.Viewport;
            var scale = 1.0f;

            switch (TempVM.Context.World.State.Zoom)
            {
                case LotView.WorldZoom.Far:
                    scale = 0.25f; break;
                case LotView.WorldZoom.Medium:
                    scale = 0.5f; break;
            }

            DrawLocalTexture(batch, bg, null, new Vector2(viewport.Width / 2 - 400*scale, viewport.Height / 2 - 300*scale), new Vector2(scale, scale));
            batch.Pause();
            GameFacade.GraphicsDevice.DepthStencilState = DepthStencilState.Default;

            if (TempVM == null) return;

            if (TargetTile != null)
            {
                Vector2 rot = new Vector2();
                switch (TempVM.Context.World.State.Rotation)
                {
                    case LotView.WorldRotation.TopLeft: rot = new Vector2(2.5f, 2.5f); break;
                    case LotView.WorldRotation.TopRight: rot = new Vector2(2.5f, -2.5f); break;
                    case LotView.WorldRotation.BottomRight: rot = new Vector2(-2.5f, -2.5f); break;
                    case LotView.WorldRotation.BottomLeft: rot = new Vector2(-2.5f, 2.5f); break;
                }
                var tile = TargetTile.VisualPosition;
                TempVM.Context.World.State.CenterTile = new Vector2(tile.X, tile.Y) - rot;
            }

            var world = TempVM.Context.World;
            world.State.SetDimensions(new Vector2(viewport.Width, viewport.Height));
            world.Draw(GameFacade.GraphicsDevice);
            GameFacade.GraphicsDevice.DepthStencilState = DepthStencilState.DepthRead;
            batch.Resume();
        }
コード例 #6
0
ファイル: UISim.cs プロジェクト: Daribon/FreeSO
 public override void Draw(UISpriteBatch batch)
 {
     if (!UISpriteBatch.Invalidated)
     {
         if (!_3DScene.IsInvalidated)
         {
             batch.Pause();
             Avatar.Draw(GameFacade.GraphicsDevice);
             batch.Resume();
         }
     }
 }
コード例 #7
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="batch"></param>
        /// <param name="mtx"></param>
        public override void Draw(UISpriteBatch batch)
        {
            if (Width == 0 || Height == 0 || !DoRedraw) return;
            DoRedraw = false;
            batch = Batch;
            batch.UIBegin(BlendState.AlphaBlend, SpriteSortMode.Deferred);
            Promise<Texture2D> bufferTexture = null;
            using (batch.WithBuffer(ref bufferTexture))
            {
                lock (Children)
                {
                    foreach (var child in Children)
                    {
                        child.PreDraw(batch);
                    }
                    foreach (var child in Children)
                    {
                        child.Draw(batch);
                    }
                }
                batch.Pause();
                batch.Resume();
            }

            var tex = bufferTexture.Get();
            batch.End();

            tex.GetData(RawImage, 0, (GameFacade.DirectX) ? RawImage.Length : RawImage.Length/4);

            for (int i=0; i<RawImage.Length; i+=4)
            {
                var swap = RawImage[i];
                RawImage[i] = RawImage[i + 2];
                RawImage[i + 2] = swap;
            }
            if (OnFrame != null) OnFrame();
            //batch.Draw(tex, Vector2.Zero, _BlendColor);
        }
コード例 #8
0
ファイル: UIPieMenu.cs プロジェクト: Daribon/FreeSO
 public override void Draw(UISpriteBatch batch)
 {
     base.Draw(batch);
     if (m_CurrentItem == m_PieTree)
     {
         //var oldd = GameFacade.GraphicsDevice.DepthStencilBuffer;
         //GameFacade.GraphicsDevice.DepthStencilBuffer = new DepthStencilBuffer(GameFacade.GraphicsDevice, oldd.Width, oldd.Height, oldd.Format);
         //todo: how to do this in xna4...
         GameFacade.GraphicsDevice.Clear(ClearOptions.DepthBuffer, new Vector4(0), 16777215, 0); //use a temp depth buffer for drawing this... this is an awful idea but will do until we get a better 3D UI element drawing system.
         batch.Pause();
         m_Head.Draw(GameFacade.GraphicsDevice);
         batch.Resume();
         //GameFacade.GraphicsDevice.DepthStencilBuffer = oldd;
     } //if we're top level, draw head!
 }
コード例 #9
0
ファイル: UISim.cs プロジェクト: RHY3756547/FreeSO
 public override void PreDraw(UISpriteBatch batch)
 {
     if (!UISpriteBatch.Invalidated)
     {
         if (!_3DScene.IsInvalidated)
         {
             batch.Pause();
             Scene.Draw(GameFacade.GraphicsDevice);
             batch.Resume();
             DrawLocalTexture(batch, Scene.Target, new Vector2());
         }
     }
     base.PreDraw(batch);
 }