public Loon.Core.Graphics.Opengl.LTextureBatch.GLCache NewBatchCache() { if (isBatch) { return(batch.NewGLCache()); } return(null); }
private void DrawString(float x, float y, float sx, float sy, float ax, float ay, float rotation, string chars, LColor c, int startIndex, int endIndex) { if (displays.Count > LSystem.DEFAULT_MAX_CACHE_SIZE) { lock (displays) { foreach (Loon.Core.Graphics.Opengl.LTextureBatch.GLCache cache in displays.Values) { if (cache != null) { cache.Dispose(); } } } displays.Clear(); } this.intObject = null; this.charCurrent = 0; this.totalWidth = 0; if (rotation != 0 && (ax == 0 && ay == 0)) { ax = font.StringWidth(chars) / 2; ay = font.GetHeight(); } if (useCache) { display = (Loon.Core.Graphics.Opengl.LTextureBatch.GLCache)CollectionUtils.Get(displays, chars); if (display == null) { fontBatch.GLBegin(); char[] charList = chars.ToCharArray(); for (int i = 0; i < charList.Length; i++) { charCurrent = charList[i]; if (charCurrent < totalCharSet) { intObject = charArray[charCurrent]; } else { intObject = (IntObject)CollectionUtils.Get(customChars, (char)charCurrent); } if (intObject != null) { if ((i >= startIndex) || (i <= endIndex)) { if (antiAlias) { fontBatch.DrawQuad(totalWidth * fontScale, 0, (totalWidth + intObject.width) * fontScale, (intObject.height * fontScale), intObject.storedX, intObject.storedY, intObject.storedX + intObject.width, intObject.storedY + intObject.height); } else { fontBatch.DrawQuad(totalWidth, 0, (totalWidth + intObject.width), intObject.height, intObject.storedX, intObject.storedY, intObject.storedX + intObject.width, intObject.storedY + intObject.height); } } totalWidth += intObject.width; } } fontBatch.CommitQuad(c, x, y, sx, sy, ax, ay, rotation); CollectionUtils.Put(displays, chars, display = fontBatch.NewGLCache()); } else if (display != null && fontBatch != null && fontBatch.GetTexture() != null) { LTextureBatch.CommitQuad(fontBatch.GetTexture(), display, c, x, y, sx, sy, ax, ay, rotation); } } else { fontBatch.GLBegin(); char[] charList = chars.ToCharArray(); for (int i = 0; i < charList.Length; i++) { charCurrent = charList[i]; if (charCurrent < totalCharSet) { intObject = charArray[charCurrent]; } else { intObject = (IntObject)CollectionUtils.Get(customChars, (char)charCurrent); } if (intObject != null) { if ((i >= startIndex) || (i <= endIndex)) { if (antiAlias) { fontBatch.DrawQuad(totalWidth * fontScale, 0, (totalWidth + intObject.width) * fontScale, (intObject.height * fontScale), intObject.storedX, intObject.storedY, intObject.storedX + intObject.width, intObject.storedY + intObject.height); } else { fontBatch.DrawQuad(totalWidth, 0, (totalWidth + intObject.width), intObject.height, intObject.storedX, intObject.storedY, intObject.storedX + intObject.width, intObject.storedY + intObject.height); } } totalWidth += intObject.width; } } fontBatch.CommitQuad(c, x, y, sx, sy, ax, ay, rotation); } }