Duality.Resources.Font.EmitTextVertices C# (CSharp) 메소드

EmitTextVertices() 공개 메소드

Emits a set of vertices based on a text. To render this text, simply use that set of vertices combined with the Fonts Material.
public EmitTextVertices ( string text, Duality.Drawing.VertexC1P3T2 &vertices ) : int
text string The text to render.
vertices Duality.Drawing.VertexC1P3T2 The set of vertices that is emitted. You can re-use the same array each frame.
리턴 int
        public int EmitTextVertices(string text, ref VertexC1P3T2[] vertices)
        {
            int len = text.Length * 4;
            if (vertices == null || vertices.Length < len) vertices = new VertexC1P3T2[len];

            float curOffset = 0.0f;
            GlyphData glyphData;
            Rect uvRect;
            float glyphXOff;
            float glyphXAdv;
            for (int i = 0; i < text.Length; i++)
            {
                this.ProcessTextAdv(text, i, out glyphData, out uvRect, out glyphXAdv, out glyphXOff);

                Vector2 glyphPos;
                glyphPos.X = MathF.Round(curOffset + glyphXOff);
                glyphPos.Y = MathF.Round(0.0f);

                vertices[i * 4 + 0].Pos.X = glyphPos.X;
                vertices[i * 4 + 0].Pos.Y = glyphPos.Y;
                vertices[i * 4 + 0].Pos.Z = 0.0f;
                vertices[i * 4 + 0].TexCoord = uvRect.TopLeft;
                vertices[i * 4 + 0].Color = ColorRgba.White;

                vertices[i * 4 + 1].Pos.X = glyphPos.X + glyphData.width;
                vertices[i * 4 + 1].Pos.Y = glyphPos.Y;
                vertices[i * 4 + 1].Pos.Z = 0.0f;
                vertices[i * 4 + 1].TexCoord = uvRect.TopRight;
                vertices[i * 4 + 1].Color = ColorRgba.White;

                vertices[i * 4 + 2].Pos.X = glyphPos.X + glyphData.width;
                vertices[i * 4 + 2].Pos.Y = glyphPos.Y + glyphData.height;
                vertices[i * 4 + 2].Pos.Z = 0.0f;
                vertices[i * 4 + 2].TexCoord = uvRect.BottomRight;
                vertices[i * 4 + 2].Color = ColorRgba.White;

                vertices[i * 4 + 3].Pos.X = glyphPos.X;
                vertices[i * 4 + 3].Pos.Y = glyphPos.Y + glyphData.height;
                vertices[i * 4 + 3].Pos.Z = 0.0f;
                vertices[i * 4 + 3].TexCoord = uvRect.BottomLeft;
                vertices[i * 4 + 3].Color = ColorRgba.White;

                curOffset += glyphXAdv;
            }

            return len;
        }

Same methods

Font::EmitTextVertices ( string text, Duality.Drawing.VertexC1P3T2 &vertices, float x, float y, ColorRgba clr ) : int
Font::EmitTextVertices ( string text, Duality.Drawing.VertexC1P3T2 &vertices, float x, float y, float z = 0.0f ) : int
Font::EmitTextVertices ( string text, Duality.Drawing.VertexC1P3T2 &vertices, float x, float y, float z, ColorRgba clr, float angle = 0.0f, float scale = 1.0f ) : int