Esempio n. 1
0
        public GraphicComponent(String texturePath)
        {
            _transform = new Transform();

            _batchInfo = new BatchedDrawable() { BatchTextureID = texturePath };
            _batchInfo.UpdateTexture();
        }
            public override void Render(ITextSurfaceRendered surface, Matrix renderingMatrix)
            {
                if (surface.Tint.A != 255)
                {
                    Cell cell;

                    if (surface.DefaultBackground.A != 0)
                    {
                        Batch.DrawQuad(surface.AbsoluteArea, surface.Font.SolidGlyphRectangle, surface.DefaultBackground, surface.Font.FontImage);
                    }

                    for (int i = 0; i < surface.RenderCells.Length; i++)
                    {
                        cell = surface.RenderCells[i];

                        if (cell.IsVisible)
                        {
                            Batch.DrawCell(cell, surface.RenderRects[i], surface.Font.SolidGlyphRectangle, surface.DefaultBackground, surface.Font);
                        }
                    }
                }

                if (surface.Tint.A != 0)
                {
                    Batch.DrawQuad(surface.AbsoluteArea, surface.Font.SolidGlyphRectangle, surface.Tint, surface.Font.FontImage);
                }
            }
Esempio n. 3
0
 ////////////////////////////////////////////////////////////
 /// <summary>
 /// Construct a set of render states with all its attributes
 /// </summary>
 /// <param name="blendMode">Blend mode to use</param>
 /// <param name="transform">Transform to use</param>
 /// <param name="texture">Texture to use</param>
 /// <param name="shader">Shader to use</param>
 ////////////////////////////////////////////////////////////
 public RenderStates(BlendMode blendMode, Transform transform, Texture texture, Shader shader)
 {
     BlendMode = blendMode;
     Transform = transform;
     Texture = texture;
     Shader = shader;
 }
Esempio n. 4
0
            internal MarshalData Marshal(Transform transform)
            {
                MarshalData data = new MarshalData();
                data.blendMode = BlendMode;
                data.transform = Transform * transform;
                data.texture = Texture != null ? Texture.CPointer : IntPtr.Zero;
                data.shader = Shader != null ? Shader.CPointer : IntPtr.Zero;

                return data;
            }
Esempio n. 5
0
        public Map(Game game, string path)
            : base(game)
        {
            tiles = new List<Tile>();

            var size = new Vector2f(128, 128);
            for (var y = 0; y < 8; y += 1)
                for (var x = 0; x < 8; x += 1)
                    tiles.Add(new Tile(game, new Vector2f(x, y), size));

            transform = GetTransform();
        }
Esempio n. 6
0
 /// <summary>
 /// Calculate the corner positions based on the transform of the parent object
 /// </summary>
 /// <param name="parentTransform">Transformation of the parent</param>
 public void UpdateTransform(Transform parentTransform)
 {
     //init array if its still uninitialized
     if (Position == null)
         Position = new Vector2f[4];
     //for every corner
     for(int i=0;i<4;++i)
     {
         //translate the base corner with the parents transform
         Position[i]=parentTransform.TransformPoint(BatchedDrawable.Corners[i]);
     }
 }
Esempio n. 7
0
        /// <summary>
        /// Renders a
        /// </summary>
        /// <param name="surface"></param>
        /// <param name="renderingMatrix"></param>

        public override void Render(ITextSurfaceRendered surface, Matrix renderingMatrix)
        {
            if (IsModal && ModalTint.A != 0)
            {
#if SFML
                Batch.Reset(Engine.Device, RenderStates.Default, Matrix.Identity);
                Batch.DrawQuad(new IntRect(0, 0, (int)Engine.Device.Size.X, (int)Engine.Device.Size.Y), surface.Font.SolidGlyphRectangle, ModalTint, surface.Font.FontImage);
                Batch.End();
#elif MONOGAME
                Batch.Begin(samplerState: SamplerState.PointClamp);
                Batch.Draw(surface.Font.FontImage, new Rectangle(0, 0, Engine.Device.PresentationParameters.BackBufferWidth, Engine.Device.PresentationParameters.BackBufferHeight), surface.Font.GlyphIndexRects[surface.Font.SolidGlyphIndex], ModalTint);
                Batch.End();
#endif
            }

            base.Render(surface, renderingMatrix);
        }
        /// <summary>
        /// Renders the cached surface from a previous call to the constructor or the <see cref="Update(ITextSurfaceRendered)"/> method.
        /// </summary>
        /// <param name="surface">Used only for tinting.</param>
        /// <param name="renderingMatrix">Display matrix for the rendered console.</param>
        public virtual void Render(ITextSurfaceRendered surface, Matrix renderingMatrix)
        {
#if SFML
            //Batch.Start(1, renderedConsole.Texture, renderingMatrix);
            Batch.Reset(Engine.Device, RenderStates.Default, renderingMatrix);
            BeforeRenderCallback?.Invoke(Batch);
            if (surface.Tint == Color.Transparent)
            {
                Batch.DrawQuad(surface.AbsoluteArea, surface.AbsoluteArea, Color.White, renderedConsole.Texture);
            }
            else
            {
                Batch.DrawQuad(surface.AbsoluteArea, surface.AbsoluteArea, surface.Tint, renderedConsole.Texture);
            }

            AfterRenderCallback?.Invoke(Batch);

            Batch.End();
#elif MONOGAME
            Batch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.PointClamp, DepthStencilState.DepthRead, RasterizerState.CullNone, null, renderingMatrix);

            BeforeRenderCallback?.Invoke(Batch);

            if (surface.Tint.A != 255)
            {
                Batch.Draw(renderedConsole, Vector2.Zero, Color.White);

                if (surface.Tint.A != 0)
                {
                    Batch.Draw(surface.Font.FontImage, surface.AbsoluteArea, surface.Font.GlyphIndexRects[surface.Font.SolidGlyphIndex], surface.Tint, 0f, Vector2.Zero, SpriteEffects.None, 0.5f);
                }
            }
            else
            {
                Batch.Draw(surface.Font.FontImage, surface.AbsoluteArea, surface.Font.GlyphIndexRects[surface.Font.SolidGlyphIndex], surface.Tint, 0f, Vector2.Zero, SpriteEffects.None, 0.5f);
            }

            AfterRenderCallback?.Invoke(Batch);

            Batch.End();
#endif
        }
            public override void Render(ITextSurfaceRendered surface, Matrix renderingMatrix)
            {
                if (surface.Tint.A != 255)
                {
                    Cell cell;

                    if (surface.DefaultBackground.A != 0)
                    {
                        Batch.Draw(surface.Font.FontImage, surface.AbsoluteArea, surface.Font.GlyphIndexRects[surface.Font.SolidGlyphIndex], surface.DefaultBackground, 0f, Vector2.Zero, SpriteEffects.None, 0.2f);
                    }

                    for (int i = 0; i < surface.RenderCells.Length; i++)
                    {
                        cell = surface.RenderCells[i];

                        if (cell.IsVisible)
                        {
                            if (cell.ActualBackground != Color.Transparent && cell.ActualBackground != surface.DefaultBackground)
                            {
                                Batch.Draw(surface.Font.FontImage, surface.RenderRects[i], surface.Font.GlyphIndexRects[surface.Font.SolidGlyphIndex], cell.ActualBackground, 0f, Vector2.Zero, SpriteEffects.None, 0.3f);
                            }

                            if (cell.ActualForeground != Color.Transparent)
                            {
                                Batch.Draw(surface.Font.FontImage, surface.RenderRects[i], surface.Font.GlyphIndexRects[cell.ActualGlyphIndex], cell.ActualForeground, 0f, Vector2.Zero, cell.ActualSpriteEffect, 0.4f);
                            }
                        }
                    }

                    if (surface.Tint.A != 0)
                    {
                        Batch.Draw(surface.Font.FontImage, surface.AbsoluteArea, surface.Font.GlyphIndexRects[surface.Font.SolidGlyphIndex], surface.Tint, 0f, Vector2.Zero, SpriteEffects.None, 0.5f);
                    }
                }
                else
                {
                    Batch.Draw(surface.Font.FontImage, surface.AbsoluteArea, surface.Font.GlyphIndexRects[surface.Font.SolidGlyphIndex], surface.Tint, 0f, Vector2.Zero, SpriteEffects.None, 0.5f);
                }
            }
        /// <summary>
        /// Gets the Matrix transform that positions the console on the screen.
        /// </summary>
        /// <returns>The transform.</returns>
        public virtual Matrix GetPositionTransform(Point position, Point CellSize, bool absolutePositioning)
        {
            Point worldLocation;

            if (absolutePositioning)
            {
                worldLocation = position;
            }
            else
            {
                worldLocation = position.ConsoleLocationToWorld(CellSize.X, CellSize.Y);
            }

#if SFML
            var transform = Matrix.Identity;
            transform.Translate(worldLocation.X, worldLocation.Y);

            return(transform);
#elif MONOGAME
            return(Matrix.CreateTranslation(worldLocation.X, worldLocation.Y, 0f));
#endif
        }
        /// <summary>
        /// Renders the cached surface from a previous call to the constructor or the <see cref="Update(ITextSurfaceRendered)"/> method.
        /// </summary>
        /// <param name="surface">Used only for tinting.</param>
        /// <param name="renderingMatrix">Display matrix for the rendered console.</param>
        public virtual void Render(ITextSurfaceRendered surface, Matrix renderingMatrix)
        {
#if SFML
            Batch.Reset(Engine.Device, RenderStates.Default, renderingMatrix);

            BeforeRenderCallback?.Invoke(Batch);

            Batch.DrawQuad(surface.AbsoluteArea, surface.AbsoluteArea, surface.Tint, renderedConsole.Texture);

            AfterRenderCallback?.Invoke(Batch);

            Batch.End();
#elif MONOGAME
            Batch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.PointClamp, DepthStencilState.DepthRead, RasterizerState.CullNone, null, renderingMatrix);

            BeforeRenderCallback?.Invoke(Batch);

            Batch.Draw(renderedConsole, Vector2.Zero, surface.Tint);

            AfterRenderCallback?.Invoke(Batch);

            Batch.End();
#endif
        }
Esempio n. 12
0
 static extern void sfTransform_translate(ref Transform transform, float x, float y);
Esempio n. 13
0
 static extern void sfTransform_combine(ref Transform transform, ref Transform other);
Esempio n. 14
0
 static extern FloatRect sfTransform_transformRect(ref Transform transform, FloatRect rectangle);
Esempio n. 15
0
 public void SetMap(string mapName)
 {
     currentMap = maps[mapName];
     worldTransform = currentMap.Transform;
 }
Esempio n. 16
0
        /// <summary>
        /// Only renders a <see cref="LayeredTextSurface"/>.
        /// </summary>
        /// <param name="surface">The <see cref="LayeredTextSurface"/> to render.</param>
        /// <param name="renderingMatrix">Rendering matrix used with the sprite batch.</param>
        public override void Render(ITextSurfaceRendered surface, Matrix renderingMatrix)
        {
            var layers = ((LayeredTextSurface)surface).GetLayers();

#if SFML
            //Batch.Start(surface, renderingMatrix);
            Batch.Reset(Engine.Device, RenderStates.Default, renderingMatrix);

            BeforeRenderCallback?.Invoke(Batch);

            if (surface.Tint.A != 255)
            {
                Cell cell;

                if (surface.DefaultBackground.A != 0)
                {
                    Batch.DrawQuad(surface.AbsoluteArea, surface.Font.SolidGlyphRectangle, surface.DefaultBackground, surface.Font.FontImage);
                }

                for (int l = 0; l < layers.Length; l++)
                {
                    if (layers[l].IsVisible)
                    {
                        for (int i = 0; i < layers[l].RenderCells.Length; i++)
                        {
                            cell = layers[l].RenderCells[i];

                            if (cell.IsVisible)
                            {
                                Batch.DrawCell(cell, surface.RenderRects[i], surface.Font.SolidGlyphRectangle, surface.DefaultBackground, surface.Font);
                            }
                        }
                    }
                }
            }

            if (surface.Tint.A != 0)
            {
                Batch.DrawQuad(surface.AbsoluteArea, surface.Font.SolidGlyphRectangle, surface.Tint, surface.Font.FontImage);
            }

            AfterRenderCallback?.Invoke(Batch);

            if (CallBatchEnd)
            {
                Batch.End();
            }
#elif MONOGAME
            Batch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.PointClamp, DepthStencilState.DepthRead, RasterizerState.CullNone, null, renderingMatrix);

            BeforeRenderCallback?.Invoke(Batch);

            if (surface.Tint.A != 255)
            {
                Cell cell;

                if (surface.DefaultBackground.A != 0)
                {
                    Batch.Draw(surface.Font.FontImage, surface.AbsoluteArea, surface.Font.GlyphIndexRects[surface.Font.SolidGlyphIndex], surface.DefaultBackground, 0f, Vector2.Zero, SpriteEffects.None, 0.2f);
                }

                for (int l = 0; l < layers.Length; l++)
                {
                    if (layers[l].IsVisible)
                    {
                        for (int i = 0; i < layers[l].RenderCells.Length; i++)
                        {
                            cell = layers[l].RenderCells[i];

                            if (cell.IsVisible)
                            {
                                if (cell.ActualBackground != Color.Transparent && cell.ActualBackground != surface.DefaultBackground)
                                {
                                    Batch.Draw(surface.Font.FontImage, surface.RenderRects[i], surface.Font.GlyphIndexRects[surface.Font.SolidGlyphIndex], cell.ActualBackground, 0f, Vector2.Zero, SpriteEffects.None, 0.3f);
                                }

                                if (cell.ActualForeground != Color.Transparent)
                                {
                                    Batch.Draw(surface.Font.FontImage, surface.RenderRects[i], surface.Font.GlyphIndexRects[cell.ActualGlyphIndex], cell.ActualForeground, 0f, Vector2.Zero, cell.ActualSpriteEffect, 0.4f);
                                }
                            }
                        }
                    }
                }
            }

            if (surface.Tint.A != 0)
            {
                Batch.Draw(surface.Font.FontImage, surface.AbsoluteArea, surface.Font.GlyphIndexRects[surface.Font.SolidGlyphIndex], surface.Tint, 0f, Vector2.Zero, SpriteEffects.None, 0.5f);
            }

            AfterRenderCallback?.Invoke(Batch);

            Batch.End();
#endif
        }
Esempio n. 17
0
 static extern void sfTransform_scale(ref Transform transform, float scaleX, float scaleY);
Esempio n. 18
0
 ////////////////////////////////////////////////////////////
 /// <summary>
 /// Change a matrix parameter of the shader
 ///
 /// "name" is the name of the variable to change in the shader.
 /// The corresponding parameter in the shader must be a 4x4 matrix
 /// (mat4 GLSL type).
 /// </summary>
 /// <param name="name">Name of the parameter in the shader</param>
 /// <param name="transform">Transform to assign</param>
 ////////////////////////////////////////////////////////////
 public void SetParameter(string name, Transform transform)
 {
     sfShader_setTransformParameter(CPointer, name, transform);
 }
Esempio n. 19
0
 ////////////////////////////////////////////////////////////
 /// <summary>
 /// Copy constructor
 /// </summary>
 /// <param name="copy">States to copy</param>
 ////////////////////////////////////////////////////////////
 public RenderStates(RenderStates copy)
 {
     BlendMode = copy.BlendMode;
     Transform = copy.Transform;
     Texture = copy.Texture;
     Shader = copy.Shader;
 }
Esempio n. 20
0
 static extern void sfTransform_rotate(ref Transform transform, float angle);
Esempio n. 21
0
 static extern void sfTransform_rotateWithCenter(ref Transform transform, float angle, float centerX, float centerY);
Esempio n. 22
0
 static extern void sfShader_setTransformParameter(IntPtr shader, string name, Transform transform);
Esempio n. 23
0
 static extern void sfTransform_scaleWithCenter(ref Transform transform, float scaleX, float scaleY, float centerX, float centerY);
Esempio n. 24
0
            ////////////////////////////////////////////////////////////
            /// <summary>
            /// Construct a default set of render states with a custom transform
            /// </summary>
            /// <param name="transform">Transform to use</param>
            ////////////////////////////////////////////////////////////
            public RenderStates(Transform transform) :
                this(BlendMode.Alpha, transform, null, null)
            {

            }
        /// <summary>
        /// Renders a surface to the screen.
        /// </summary>
        /// <param name="surface">The surface to render.</param>
        /// <param name="renderingMatrix">Display matrix for the rendered console.</param>
        public virtual void Render(ITextSurfaceRendered surface, Matrix renderingMatrix)
        {
#if SFML
            Batch.Reset(Engine.Device, RenderStates.Default, renderingMatrix);

            BeforeRenderCallback?.Invoke(Batch);

            if (surface.Tint.A != 255)
            {
                Cell cell;

                if (surface.DefaultBackground.A != 0)
                {
                    Batch.DrawQuad(surface.AbsoluteArea, surface.Font.SolidGlyphRectangle, surface.DefaultBackground, surface.Font.FontImage);
                }

                for (int i = 0; i < surface.RenderCells.Length; i++)
                {
                    cell = surface.RenderCells[i];

                    if (cell.IsVisible)
                    {
                        Batch.DrawCell(cell, surface.RenderRects[i], surface.Font.SolidGlyphRectangle, surface.DefaultBackground, surface.Font);
                    }
                }

                #region Control Render
                int     cellCount;
                IntRect rect;
                Point   point;
                Controls.ControlBase control;

                // For each control
                for (int i = 0; i < Controls.Count; i++)
                {
                    if (Controls[i].IsVisible)
                    {
                        control   = Controls[i];
                        cellCount = control.TextSurface.Cells.Length;

                        var font = control.AlternateFont == null ? surface.Font : control.AlternateFont;

                        // Draw background of each cell for the control
                        for (int cellIndex = 0; cellIndex < cellCount; cellIndex++)
                        {
                            cell = control[cellIndex];

                            if (cell.IsVisible)
                            {
                                point = Consoles.TextSurface.GetPointFromIndex(cellIndex, control.TextSurface.Width);
                                point = new Point(point.X + control.Position.X, point.Y + control.Position.Y);

                                if (surface.RenderArea.Contains(point.X, point.Y))
                                {
                                    point = new Point(point.X - surface.RenderArea.Left, point.Y - surface.RenderArea.Top);
                                    rect  = surface.RenderRects[Consoles.TextSurface.GetIndexFromPoint(point, surface.Width)];

                                    Batch.DrawCell(cell, rect, font.SolidGlyphRectangle, Color.Transparent, font);
                                }
                            }
                        }
                    }
                }


                #endregion
            }
            AfterRenderCallback?.Invoke(Batch);

            if (surface.Tint.A != 0)
            {
                Batch.DrawQuad(surface.AbsoluteArea, surface.Font.SolidGlyphRectangle, surface.Tint, surface.Font.FontImage);
            }

            if (CallBatchEnd)
            {
                Batch.End();
            }
#elif MONOGAME
            Batch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.PointClamp, DepthStencilState.DepthRead, RasterizerState.CullNone, null, renderingMatrix);

            BeforeRenderCallback?.Invoke(Batch);

            if (surface.Tint.A != 255)
            {
                Cell cell;


                if (surface.DefaultBackground.A != 0)
                {
                    Batch.Draw(surface.Font.FontImage, surface.AbsoluteArea, surface.Font.GlyphIndexRects[surface.Font.SolidGlyphIndex], surface.DefaultBackground, 0f, PrimitiveStatic.Vector2Zero, SpriteEffects.None, 0.2f);
                }

                for (int i = 0; i < surface.RenderCells.Length; i++)
                {
                    cell = surface.RenderCells[i];

                    if (cell.IsVisible)
                    {
                        if (cell.ActualBackground != Color.Transparent && cell.ActualBackground != surface.DefaultBackground)
                        {
                            Batch.Draw(surface.Font.FontImage, surface.RenderRects[i], surface.Font.GlyphIndexRects[surface.Font.SolidGlyphIndex], cell.ActualBackground, 0f, Vector2.Zero, SpriteEffects.None, 0.3f);
                        }

                        if (cell.ActualForeground != Color.Transparent)
                        {
                            Batch.Draw(surface.Font.FontImage, surface.RenderRects[i], surface.Font.GlyphIndexRects[cell.ActualGlyphIndex], cell.ActualForeground, 0f, Vector2.Zero, cell.ActualSpriteEffect, 0.4f);
                        }
                    }
                }

                #region Control Render


                int                  cellCount;
                Rectangle            rect;
                Point                point;
                Controls.ControlBase control;

                // For each control
                for (int i = 0; i < Controls.Count; i++)
                {
                    if (Controls[i].IsVisible)
                    {
                        control   = Controls[i];
                        cellCount = control.TextSurface.Cells.Length;

                        var font = control.AlternateFont == null ? surface.Font : control.AlternateFont;

                        // Draw background of each cell for the control
                        for (int cellIndex = 0; cellIndex < cellCount; cellIndex++)
                        {
                            cell = control[cellIndex];

                            if (cell.IsVisible)
                            {
                                point = Consoles.TextSurface.GetPointFromIndex(cellIndex, control.TextSurface.Width);
                                point = new Point(point.X + control.Position.X, point.Y + control.Position.Y);

                                if (surface.RenderArea.Contains(point.X, point.Y))
                                {
                                    point = new Point(point.X - surface.RenderArea.Left, point.Y - surface.RenderArea.Top);
                                    rect  = surface.RenderRects[Consoles.TextSurface.GetIndexFromPoint(point, surface.Width)];

                                    if (cell.ActualBackground != Color.Transparent)
                                    {
                                        Batch.Draw(font.FontImage, rect, font.GlyphIndexRects[font.SolidGlyphIndex], cell.ActualBackground, 0f, Vector2.Zero, SpriteEffects.None, 0.23f);
                                    }
                                    if (cell.ActualForeground != Color.Transparent)
                                    {
                                        Batch.Draw(font.FontImage, rect, font.GlyphIndexRects[cell.ActualGlyphIndex], cell.ActualForeground, 0f, Vector2.Zero, cell.ActualSpriteEffect, 0.26f);
                                    }
                                }
                            }
                        }
                    }
                }


                #endregion

                if (surface.Tint.A != 0)
                {
                    Batch.Draw(surface.Font.FontImage, surface.AbsoluteArea, surface.Font.GlyphIndexRects[surface.Font.SolidGlyphIndex], surface.Tint, 0f, Vector2.Zero, SpriteEffects.None, 0.5f);
                }
            }
            else
            {
                Batch.Draw(surface.Font.FontImage, surface.AbsoluteArea, surface.Font.GlyphIndexRects[surface.Font.SolidGlyphIndex], surface.Tint, 0f, Vector2.Zero, SpriteEffects.None, 0.5f);
            }

            AfterRenderCallback?.Invoke(Batch);

            if (CallBatchEnd)
            {
                Batch.End();
            }
#endif
        }
Esempio n. 26
0
 static extern Vector2f sfTransform_transformPoint(ref Transform transform, Vector2f point);
Esempio n. 27
0
 ////////////////////////////////////////////////////////////
 /// <summary>
 /// Combine the current transform with another one.
 /// 
 /// The result is a transform that is equivalent to applying
 /// this followed by transform. Mathematically, it is
 /// equivalent to a matrix multiplication.
 /// </summary>
 /// <param name="transform">Transform to combine to this transform</param>
 ////////////////////////////////////////////////////////////
 public void Combine(Transform transform)
 {
     sfTransform_combine(ref this, ref transform);
 }
Esempio n. 28
0
 public Vector2f GetCenter(Transform transform)
 {
     return transform.TransformPoint(Position + size / 2);
 }
Esempio n. 29
0
 static extern Transform sfTransform_getInverse(ref Transform transform);
Esempio n. 30
0
        /// <summary>
        /// Renders a surface to the screen.
        /// </summary>
        /// <param name="surface">The surface to render.</param>
        /// <param name="renderingMatrix">Display matrix for the rendered console.</param>
        public virtual void Render(ITextSurfaceRendered surface, Matrix renderingMatrix)
        {
#if SFML
            if (AlternativeRenderTarget == null)
            {
                Batch.Reset(Engine.Device, RenderStates.Default, renderingMatrix);
            }
            else
            {
                Batch.Reset(AlternativeRenderTarget, RenderStates.Default, renderingMatrix);
            }

            BeforeRenderCallback?.Invoke(Batch);

            if (surface.Tint.A != 255)
            {
                Cell cell;

                if (surface.DefaultBackground.A != 0)
                {
                    Batch.DrawQuad(surface.AbsoluteArea, surface.Font.SolidGlyphRectangle, surface.DefaultBackground, surface.Font.FontImage);
                }

                for (int i = 0; i < surface.RenderCells.Length; i++)
                {
                    cell = surface.RenderCells[i];

                    if (cell.IsVisible)
                    {
                        Batch.DrawCell(cell, surface.RenderRects[i], surface.Font.SolidGlyphRectangle, surface.DefaultBackground, surface.Font);
                    }
                }
            }
            AfterRenderCallback?.Invoke(Batch);

            if (surface.Tint.A != 0)
            {
                Batch.DrawQuad(surface.AbsoluteArea, surface.Font.SolidGlyphRectangle, surface.Tint, surface.Font.FontImage);
            }

            if (CallBatchEnd)
            {
                Batch.End();
            }
#elif MONOGAME
            Batch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.PointClamp, DepthStencilState.DepthRead, RasterizerState.CullNone, null, renderingMatrix);

            BeforeRenderCallback?.Invoke(Batch);

            if (surface.Tint.A != 255)
            {
                Cell cell;


                if (surface.DefaultBackground.A != 0)
                {
                    Batch.Draw(surface.Font.FontImage, surface.AbsoluteArea, surface.Font.GlyphIndexRects[surface.Font.SolidGlyphIndex], surface.DefaultBackground, 0f, PrimitiveStatic.Vector2Zero, SpriteEffects.None, 0.2f);
                }

                for (int i = 0; i < surface.RenderCells.Length; i++)
                {
                    cell = surface.RenderCells[i];

                    if (cell.IsVisible)
                    {
                        if (cell.ActualBackground != Color.Transparent && cell.ActualBackground != surface.DefaultBackground)
                        {
                            Batch.Draw(surface.Font.FontImage, surface.RenderRects[i], surface.Font.GlyphIndexRects[surface.Font.SolidGlyphIndex], cell.ActualBackground, 0f, Vector2.Zero, SpriteEffects.None, 0.3f);
                        }

                        if (cell.ActualForeground != Color.Transparent)
                        {
                            Batch.Draw(surface.Font.FontImage, surface.RenderRects[i], surface.Font.GlyphIndexRects[cell.ActualGlyphIndex], cell.ActualForeground, 0f, Vector2.Zero, cell.ActualSpriteEffect, 0.4f);
                        }
                    }
                }

                if (surface.Tint.A != 0)
                {
                    Batch.Draw(surface.Font.FontImage, surface.AbsoluteArea, surface.Font.GlyphIndexRects[surface.Font.SolidGlyphIndex], surface.Tint, 0f, Vector2.Zero, SpriteEffects.None, 0.5f);
                }
            }
            else
            {
                Batch.Draw(surface.Font.FontImage, surface.AbsoluteArea, surface.Font.GlyphIndexRects[surface.Font.SolidGlyphIndex], surface.Tint, 0f, Vector2.Zero, SpriteEffects.None, 0.5f);
            }

            AfterRenderCallback?.Invoke(Batch);

            if (CallBatchEnd)
            {
                Batch.End();
            }
#endif
        }