Example #1
0
    /// <inheritdoc/>
    void IPresentationTarget.EndRender(RenderContext context)
    {
      if (!_rendering)
        return;

#pragma warning disable 168
      // ReSharper disable EmptyGeneralCatchClause
      try
      {
        var graphicsDevice = GraphicsService.GraphicsDevice;


        graphicsDevice.SetRenderTarget(null);
        context.RenderTarget = null;
        _renderTarget.Present();
#else
        int width = ClientSize.Width;
        int height = ClientSize.Height;
        var sourceRectangle = new Rectangle(0, 0, width, height);
        graphicsDevice.Present(sourceRectangle, null, Handle);

      }
      catch (Exception)
      {
        // Do nothing. This happens when the layout of the window changes during rendering.
        // For example, when the user docks windows an OutOfVideoMemoryException might occur.
      }
      finally
      {
        _rendering = false;
      }
      // ReSharper restore EmptyGeneralCatchClause
#pragma warning restore 168
    }
Example #2
0
 void EndDraw()
 {
     try
     {
         _renderTarget.Present();
     }
     catch
     {
     }
 }
Example #3
0
 private void EndDraw()
 {
     try
     {
         _chain.Present();
     }
     catch
     {
         // ignored
     }
 }
Example #4
0
        private void EndDraw(PaintEventArgs e)
        {
            try
            {
#if DX
                _chain.Present();
#elif GL
                if (_DrawThisFrame)
                {
                    _DrawThisFrame = false;
                    e.Graphics.DrawImage(_chain.Present(), 0, 0, _chain.Width, _chain.Height);
                }
                _graphicsDeviceService.SDLPlatform.RunLoop();
#endif
            }
            catch
            {
                // ignored
            }
        }
Example #5
0
        private void Draw()
        {
            if (_graphicsDevice != null && _chain != null && this.ParentForm?.WindowState != FormWindowState.Minimized)
            {
                _graphicsDevice.SetRenderTarget(_chain);
                _graphicsDevice.Clear(Color.Black);

                _spriteBatch.Begin();

                this.OnDraw?.Invoke(this);

                _spriteBatch.End();

                _chain.Present();
                _graphicsDevice.SetRenderTarget(null);
            }
        }
Example #6
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.SetRenderTarget(target);
            GraphicsDevice.Clear(Color.DarkSlateBlue);
            //GraphicsDevice.Present();

            _spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null, Matrix.CreateScale(3, 3, 1));
            _spriteBatch.Draw(_foxHead, new Rectangle(15, 15, 32, 32), null, Color.White, 0, Vector2.Zero, new SpriteEffects(), 1);
            _spriteBatch.End();

            GraphicsDevice.SetRenderTarget(null);

            //_effect.CurrentTechnique = _effect.Techniques["Pretransformed"];
            _effect.CurrentTechnique = _effect.Techniques["ColoredNoShading"];

            _effect.Parameters["xView"].SetValue(_viewMatrix);
            _effect.Parameters["xProjection"].SetValue(_projectionMatrix);
            Matrix worldMatrix = Matrix.CreateTranslation(-20.0f / 3.0f, -10.0f / 3.0f, 0) * Matrix.CreateRotationZ(_angle);

            _effect.Parameters["xWorld"].SetValue(worldMatrix);

            foreach (EffectPass pass in _effect.CurrentTechnique.Passes)
            {
                pass.Apply();
            }

            //_device.DrawUserPrimitives(PrimitiveType.TriangleList, _vertices, 0, 1, VertexPositionColor.VertexDeclaration);
            _device.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, _vertices, 0, _vertices.Length, _indices, 0, _indices.Length / 3, VertexPositionColor.VertexDeclaration);

            _spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null, Matrix.CreateScale(3, 3, 1));
            _spriteBatch.Draw(_foxHead, new Rectangle(15, 15, 32, 32), null, Color.White, 0, Vector2.Zero, new SpriteEffects(), 1);
            _spriteBatch.End();

            _spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null, Matrix.CreateScale(3, 3, 1));
            _testEffect.Parameters["filterColor"].SetValue(Color.Red.ToVector4());
            _testEffect.CurrentTechnique.Passes[0].Apply();
            _spriteBatch.Draw(_foxHead, new Rectangle(75, 15, 32, 32), null, Color.White, 0, Vector2.Zero, new SpriteEffects(), 1);
            _spriteBatch.End();

            target.Present();

            base.Draw(gameTime);
        }
    /// <inheritdoc/>
    void IPresentationTarget.EndRender(RenderContext context)
    {
      if (!_rendering)
        return;

      try
      {
        var graphicsDevice = GraphicsService.GraphicsDevice;

        graphicsDevice.SetRenderTarget(null);
        context.RenderTarget = null;
        _renderTarget.Present();
      }
      catch (Exception)
      {
        // Do nothing.
      }
      finally
      {
        _rendering = false;
      }
    }
Example #8
0
        void DrawUpperFrame()
        {
            if (mUpperWindow == null || mEditorItem == null)
            {
                return;
            }

            if (!mPlayUpper)
            {
                mUpperFrame = scrlUpperFrame.Value - 1;
            }

            var graphicsDevice = Core.Graphics.GetGraphicsDevice();

            Core.Graphics.EndSpriteBatch();
            graphicsDevice.SetRenderTarget(mUpperDarkness);
            graphicsDevice.Clear(Microsoft.Xna.Framework.Color.Black);
            if (mUpperFrame < mEditorItem.Upper.Lights.Length)
            {
                Core.Graphics.DrawLight(
                    picUpperAnimation.Width / 2 + mEditorItem.Upper.Lights[mUpperFrame].OffsetX,
                    picUpperAnimation.Height / 2 + mEditorItem.Upper.Lights[mUpperFrame].OffsetY,
                    mEditorItem.Upper.Lights[mUpperFrame], mUpperDarkness
                    );
            }

            Core.Graphics.DrawTexture(
                Core.Graphics.GetWhiteTex(), new RectangleF(0, 0, 1, 1),
                new RectangleF(0, 0, mUpperDarkness.Width, mUpperDarkness.Height),
                System.Drawing.Color.FromArgb((byte)((float)(100 - scrlDarkness.Value) / 100f * 255), 255, 255, 255),
                mUpperDarkness, BlendState.Additive
                );

            Core.Graphics.EndSpriteBatch();
            graphicsDevice.SetRenderTarget(mUpperWindow);
            graphicsDevice.Clear(Microsoft.Xna.Framework.Color.White);
            var animTexture = GameContentManager.GetTexture(
                GameContentManager.TextureType.Animation, cmbUpperGraphic.Text
                );

            if (animTexture != null)
            {
                long w = animTexture.Width / (int)nudUpperHorizontalFrames.Value;
                long h = animTexture.Height / (int)nudUpperVerticalFrames.Value;
                long x = 0;
                if (mUpperFrame > 0)
                {
                    x = mUpperFrame % (int)nudUpperHorizontalFrames.Value * w;
                }

                var y = (int)Math.Floor(mUpperFrame / nudUpperHorizontalFrames.Value) * h;
                Core.Graphics.DrawTexture(
                    animTexture, new RectangleF(x, y, w, h),
                    new RectangleF(
                        picUpperAnimation.Width / 2 - (int)w / 2, (int)picUpperAnimation.Height / 2 - (int)h / 2, w,
                        h
                        ), mUpperWindow
                    );
            }

            Core.Graphics.DrawTexture(mUpperDarkness, 0, 0, mUpperWindow, Core.Graphics.MultiplyState);
            Core.Graphics.EndSpriteBatch();
            mUpperWindow.Present();
        }
Example #9
0
 public virtual void Present(Display display) => SwapChain?.Present();