示例#1
0
        public static int DrawChar(Vector4 rect, uint c, Vector4 color)
        {
            if (c < 33)
            {
                return(6);
            }
            var glyph = Context.Font.GetGlyphInfo(c);

            if (glyph == null)
            {
                return((int)Context.Font.FontPixelSize);
            }

            float x1 = rect.X + glyph.LineOffsetX;
            float y1 = rect.Y + glyph.LineOffsetY;
            float x2 = Math.Min(rect.X + rect.Z, x1 + glyph.PixelWidth);
            float y2 = Math.Min(rect.Y + rect.W, y1 + glyph.PixelHeight);

            BufferText.AddVertices(new Vector4(x1, y1, s_depthz, 1), color, glyph.UV[0]);
            BufferText.AddVertices(new Vector4(x1, y2, s_depthz, 1), color, glyph.UV[1]);
            BufferText.AddVertices(new Vector4(x2, y2, s_depthz, 1), color, glyph.UV[2]);
            BufferText.AddVertices(new Vector4(x2, y1, s_depthz, 1), color, glyph.UV[3]);

            //BufferText.Add(new RigelEGUIVertex()
            //{
            //    Position = new Vector4(x1, y1, s_depthz, 1),
            //    Color = color,
            //    UV = glyph.UV[0]
            //});
            //BufferText.Add(new RigelEGUIVertex()
            //{
            //    Position = new Vector4(x1, y2, s_depthz, 1),
            //    Color = color,
            //    UV = glyph.UV[1]
            //});
            //BufferText.Add(new RigelEGUIVertex()
            //{
            //    Position = new Vector4(x2, y2, s_depthz, 1),
            //    Color = color,
            //    UV = glyph.UV[2]
            //});
            //BufferText.Add(new RigelEGUIVertex()
            //{
            //    Position = new Vector4(x2, y1, s_depthz, 1),
            //    Color = color,
            //    UV = glyph.UV[3]
            //});

            DepthIncrease();

            return(glyph.AdvancedX);
        }
示例#2
0
        public static int _ImplDrawCharWithRectA(Vector4 recta, Vector2 posa, uint c, Vector4 color, bool noclip = false)
        {
            if (c < 33)
            {
                return(6);
            }

            var glyph = Context.Font.GetGlyphInfo(c);

            Vector4 charrect = new Vector4(posa, glyph.PixelWidth, glyph.PixelHeight);

            charrect.X += glyph.LineOffsetX;
            charrect.Y += glyph.LineOffsetY;

            float x2 = charrect.X + charrect.Z;
            float y2 = charrect.Y + charrect.W;

            float rectx2 = recta.X + recta.Z;
            float recty2 = recta.Y + recta.W;

            if (x2 <= recta.X || charrect.X >= rectx2 || y2 <= recta.Y || charrect.Y >= recty2)
            {
                return(glyph.AdvancedX);
            }


            if (!noclip)
            {
                Vector4 clipsize = Vector4.Zero;
                if (charrect.X < recta.X)
                {
                    clipsize.X = recta.X - charrect.X;
                    charrect.X = recta.X;
                }
                if (x2 > rectx2)
                {
                    clipsize.Z = x2 - rectx2;
                    x2         = rectx2;
                }

                if (charrect.Y < recta.Y)
                {
                    clipsize.Y = recta.Y - charrect.Y;
                    charrect.Y = recta.Y;
                }

                if (y2 > recty2)
                {
                    clipsize.W = y2 - recty2;
                    y2         = recty2;
                }
                clipsize *= Context.Font.UVUnit;

                Vector2 uv0 = glyph.UV[0];
                Vector2 uv1 = glyph.UV[1];
                Vector2 uv2 = glyph.UV[2];
                Vector2 uv3 = glyph.UV[3];

                uv0.X += clipsize.X;
                uv1.X += clipsize.X;
                uv2.X -= clipsize.Z;
                uv3.X -= clipsize.Z;

                uv0.Y += clipsize.Y;
                uv3.Y += clipsize.Y;
                uv1.Y -= clipsize.W;
                uv2.Y -= clipsize.W;

                BufferText.AddVertices(new Vector4(charrect.X, charrect.Y, s_depthz, 1), color, uv0);
                BufferText.AddVertices(new Vector4(charrect.X, y2, s_depthz, 1), color, uv1);
                BufferText.AddVertices(new Vector4(x2, y2, s_depthz, 1), color, uv2);
                BufferText.AddVertices(new Vector4(x2, charrect.Y, s_depthz, 1), color, uv3);
            }
            else
            {
                BufferText.AddVertices(new Vector4(charrect.X, charrect.Y, s_depthz, 1), color, glyph.UV[0]);
                BufferText.AddVertices(new Vector4(charrect.X, y2, s_depthz, 1), color, glyph.UV[1]);
                BufferText.AddVertices(new Vector4(x2, y2, s_depthz, 1), color, glyph.UV[2]);
                BufferText.AddVertices(new Vector4(x2, charrect.Y, s_depthz, 1), color, glyph.UV[3]);
            }

            return(glyph.AdvancedX);
        }