public static Texture2D GetDefaultFontTexture(GraphicsDevice graphicsDevice) { var colors = DefaultFontDataColors.GetColorArray(); Texture2D texture = new Texture2D(graphicsDevice, 256, 128); #if XNA3 texture.SetData <Microsoft.Xna.Framework.Graphics.Color>(colors); #else texture.SetData <Microsoft.Xna.Framework.Color>(colors); #endif return(texture); }
public static Texture2D GetDefaultFontTexture(GraphicsDevice graphicsDevice) { #if ANDROID var activity = FlatRedBallServices.Game.Services.GetService<Android.App.Activity>(); if(activity == null) { string message = "As of July 2017, FlatRedBall Android performs a much faster loading of the default font. This requires a change to the Activity1.cs file. You can look at a brand-new Android template to see the required changes."; throw new NullReferenceException(message); } Android.Content.Res.AssetManager androidAssetManager = activity.Assets; Texture2D texture; try { using (var stream = androidAssetManager.Open("content/defaultfonttexture.png")) { texture = Texture2D.FromStream(graphicsDevice, stream); } } catch { throw new Exception("The file defaultfonttexture.png in the game's content folder is missing. If you are missing this file, look at the default Android template to see where it should be added (in Assets/content/)"); } #else var colors = DefaultFontDataColors.GetColorArray(); Texture2D texture = new Texture2D(graphicsDevice, 256, 128); texture.SetData<Microsoft.Xna.Framework.Color>(colors); #endif return texture; }