Exemplo n.º 1
0
 public static Texture CreateFromStream(Stream stream, bool preMultiplyAlpha, bool createAlpha)
 {
     var texture = new Texture();
     texture.LoadFromStream(stream, preMultiplyAlpha, createAlpha);
     return texture;
 }
Exemplo n.º 2
0
Arquivo: Font.cs Projeto: Tokter/TokED
        private void CreateMaterial(Stream fontStream, Stream fontInfoStream)
        {
            var texture = new Texture();
            texture.LoadFromStream(fontStream, true, false);
            using (var sr = fontInfoStream)
            {
                using (var br = new BinaryReader(sr))
                {
                    for (int i = 33; i < 256; i++)
                    {
                        var x1 = br.ReadByte();
                        var y1 = br.ReadByte();
                        var x2 = br.ReadByte();
                        var y2 = br.ReadByte();

                        _charInfo[i].U1 = x1 / (float)texture.Width;
                        _charInfo[i].V1 = y1 / (float)texture.Height;
                        _charInfo[i].U2 = x2 / (float)texture.Width;
                        _charInfo[i].V2 = y2 / (float)texture.Height;
                        _charInfo[i].Width = x2 - x1;
                        _charInfo[i].Height = y2 - y1;
                        _charInfo[i].YOffset = br.ReadByte();
                    }
                    for (int i = 0; i < 256*256; i++)
                    {
                        _kerning[i] = br.ReadByte();
                    }
                }
            }
            _charInfo[32].Width = _charInfo[101].Width-2;
            _charInfo[32].Height = _charInfo[101].Height;

            _material = Material.CreateTextureColor(texture);
            _material.AlphaBlend = true;
            _material.DepthTest = false;
        }