コード例 #1
0
        /// <summary>
        /// Draws the <see cref="IRefractionEffect"/>.
        /// </summary>
        /// <param name="spriteBatch">The <see cref="ISpriteBatch"/> to draw with.</param>
        public void Draw(ISpriteBatch spriteBatch)
        {
            if (IsExpired || !IsEnabled)
            {
                return;
            }

            SetShaderParameters(TickCount.Now);

            // Draw
            var dest = ToRectangle();

            var oldBlendMode = spriteBatch.BlendMode;

            try
            {
                spriteBatch.BlendMode = BlendMode.None;
                try
                {
                    Shader.Bind();

                    WaveNoise.Draw(spriteBatch, dest);
                }
                finally
                {
                    Shader.Unbind();
                }
            }
            finally
            {
                spriteBatch.BlendMode = oldBlendMode;
            }
        }
コード例 #2
0
        /// <summary>
        /// Updates the <see cref="IRefractionEffect"/>.
        /// </summary>
        /// <param name="currentTime">The current game time in milliseconds.</param>
        public void Update(TickCount currentTime)
        {
            if (IsExpired)
            {
                return;
            }

            // Most all of the updating takes place in the shader itself, which is done right before drawing

            // Update the sprite
            WaveNoise.Update(currentTime);
        }