Esempio n. 1
0
		public static void SetData<T>(Texture2D texture, T[] data) where T: struct
		{
#if !STRIDE
			texture.SetData(data);
#else
			var commandList = MyraEnvironment.Game.GraphicsContext.CommandList;

			texture.SetData(commandList, data);
#endif
		}
Esempio n. 2
0
        protected override Task LoadContent()
#endif
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            _spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
            var assembly = GetType().Assembly;

            _font = StaticSpriteFont.FromBMFont(assembly.ReadResourceAsString("FontStashSharp.Samples.StaticSpriteFont.Fonts.Arial.fnt"),
                                                fileName => assembly.OpenResourceStream("FontStashSharp.Samples.StaticSpriteFont.Fonts." + fileName),
                                                GraphicsDevice);

#if MONOGAME || FNA
            _white = new Texture2D(GraphicsDevice, 1, 1);
            _white.SetData(new[] { Color.White });
#elif STRIDE
            _white = Texture2D.New2D(GraphicsDevice, 1, 1, false, PixelFormat.R8G8B8A8_UNorm_SRgb, TextureFlags.ShaderResource);
            _white.SetData(GraphicsContext.CommandList, new[] { Color.White });
#endif

            GC.Collect();

#if STRIDE
            return(base.LoadContent());
#endif
        }
Esempio n. 3
0
        public static void SetTextureData(Texture2D texture, Rectangle bounds, byte[] data)
        {
#if MONOGAME || FNA
            texture.SetData(0, bounds, data, 0, bounds.Width * bounds.Height * 4);
#elif STRIDE
            var    size = bounds.Width * bounds.Height * 4;
            byte[] temp;
            if (size == data.Length)
            {
                temp = data;
            }
            else
            {
                // Since Stride requres buffer size to match exactly, copy data in the temporary buffer
                temp = new byte[bounds.Width * bounds.Height * 4];
                Array.Copy(data, temp, temp.Length);
            }

            var context = MyraEnvironment.Game.GraphicsContext;
            texture.SetData(context.CommandList, temp, 0, 0, new ResourceRegion(bounds.Left, bounds.Top, 0, bounds.Right, bounds.Bottom, 1));
#endif
        }
Esempio n. 4
0
        protected override Task LoadContent()
#endif
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            _spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
            var fontSystems = new List <FontSystem>();

            // Simple
            var fontSystem = new FontSystem();

            LoadFontSystem(fontSystem);
            fontSystems.Add(fontSystem);

            // Blurry
            var settings = new FontSystemSettings
            {
                Effect       = FontSystemEffect.Blurry,
                EffectAmount = EffectAmount,
            };

            var blurryFontSystem = new FontSystem(settings);

            LoadFontSystem(blurryFontSystem);
            fontSystems.Add(blurryFontSystem);

            // Stroked
            settings.Effect = FontSystemEffect.Stroked;
            var strokedFontSystem = new FontSystem(settings);

            LoadFontSystem(strokedFontSystem);
            fontSystems.Add(strokedFontSystem);

            _fontSystems       = fontSystems.ToArray();
            _currentFontSystem = _fontSystems[0];

#if MONOGAME || FNA
            _white = new Texture2D(GraphicsDevice, 1, 1);
            _white.SetData(new[] { Color.White });
#elif STRIDE
            _white = Texture2D.New2D(GraphicsDevice, 1, 1, false, PixelFormat.R8G8B8A8_UNorm_SRgb, TextureFlags.ShaderResource);
            _white.SetData(GraphicsContext.CommandList, new[] { Color.White });
#endif

            GC.Collect();

#if STRIDE
            return(base.LoadContent());
#endif
        }