Inheritance: ITextSurfaceRenderer
Example #1
0
 public FPSCounterComponent(Microsoft.Xna.Framework.Game game)
     : base(game)
 {
     console = new TextSurface(30, 1, Engine.DefaultFont);
     editor = new SurfaceEditor(console);
     console.DefaultBackground = Color.Black;
     editor.Clear();
     consoleRender = new TextSurfaceRenderer();
 }
        /// <summary>
        /// Updates the cache based on the <paramref name="source"/> surface.
        /// </summary>
        /// <param name="source">The surface to render and cache.</param>
        public void Update(ITextSurfaceRendered source)
        {
            if (renderedConsole != null)
                renderedConsole.Dispose();

            renderedConsole = new RenderTarget2D(Engine.Device, source.AbsoluteArea.Width, source.AbsoluteArea.Height, false, Engine.Device.DisplayMode.Format, DepthFormat.Depth24);
            Engine.Device.SetRenderTarget(renderedConsole);
            Engine.Device.Clear(Color.Transparent);
            TextSurfaceRenderer renderer = new TextSurfaceRenderer();
            renderer.Render(source, new Point(0, 0));
            Engine.RestoreRenderTarget();
        }