private void DrawBatchString(float tx, float ty, string text, LColor c, int startIndex, int endIndex) { if (isClose) { return; } float x = tx, y = ty; displayList.GLBegin(); CharDef lastCharDef = null; char[] data = text.ToCharArray(); for (int i = 0; i < data.Length; i++) { int id = data[i]; if (id == '\n') { x = 0; y += GetLineHeight(); continue; } if (id >= chars.Length) { continue; } CharDef charDef = chars[id]; if (charDef == null) { continue; } if (lastCharDef != null) { x += lastCharDef.GetKerning(id); } lastCharDef = charDef; if ((i >= startIndex) && (i <= endIndex)) { charDef.Draw(x, y, 0, c); } x += charDef.advance; } displayList.GLEnd(); }
private void DrawBatchString(float tx, float ty, string text, LColor c, int startIndex, int endIndex) { if (isClose) { return; } if (displays.Size() > DEFAULT_MAX_CHAR) { displays.Clear(); } lazyHashCode = 1; if (c != null) { lazyHashCode = LSystem.Unite(lazyHashCode, c.r); lazyHashCode = LSystem.Unite(lazyHashCode, c.g); lazyHashCode = LSystem.Unite(lazyHashCode, c.b); lazyHashCode = LSystem.Unite(lazyHashCode, c.a); } string key = text + lazyHashCode; Display display = (Display)displays.Get(key); if (display == null) { int x = 0, y = 0; displayList.GLBegin(); displayList.SetBatchPos(tx, ty); if (c != null) { displayList.SetImageColor(c); } CharDef lastCharDef = null; char[] data = text.ToCharArray(); for (int i = 0; i < data.Length; i++) { int id = data[i]; if (id == '\n') { x = 0; y += GetLineHeight(); continue; } if (id >= chars.Length) { continue; } CharDef charDef = chars[id]; if (charDef == null) { continue; } if (lastCharDef != null) { x += lastCharDef.GetKerning(id); } lastCharDef = charDef; if ((i >= startIndex) && (i <= endIndex)) { charDef.Draw(x, y); } x += charDef.advance; } if (c != null) { displayList.SetImageColor(LColor.white); } displayList.GLEnd(); display = new Display(); display.cache = displayList.NewBatchCache(); display.text = text; display.width = 0; display.height = 0; displays.Put(key, display); } else if (display.cache != null) { display.cache.x = tx; display.cache.y = ty; LTextureBatch.Commit(displayList, display.cache); } }