예제 #1
0
        public void RenderText(string text, float x, float y, float scale, vec3 color)
        {
            TextRender.BeginBatch();
            float c_Char = x;

            foreach (char c in text)
            {
                if (!Characters.ContainsKey(c))
                {
                    continue;
                }

                Character ch = Characters[c];

                float xpos = c_Char + ch.bearing.x * scale;
                float ypos = y - (ch.size.y - ch.bearing.y) * scale;

                float w = ch.size.x * scale;
                float h = ch.size.y * scale;

                TextRender.DrawText(new vec2(xpos, ypos + h), new vec2(w, -h), ch.textureID, color);

                // TODO: Do a decent bit shift and remove this Gap multiplication
                c_Char += ((ch.Advance * Gap) >> 6) * scale;
            }
            TextRender.EndBatch();
            TextRender.Flush();
        }