/// <summary> /// Load one of the /font/glyph_XX.png into a new GL texture and store the texture ID in glyphTextureName array. /// </summary> private void LoadGlyphTexture(int par1) { string s = string.Format("font.glyph_{0:X2}.png", par1); Texture2D bufferedimage; try { bufferedimage = renderEngine.GetTexture(s); } catch (IOException ioexception) { Console.WriteLine(ioexception.ToString()); Console.WriteLine(); throw ioexception; } glyphTextureName[par1] = renderEngine.AllocateTexture(bufferedimage); boundTextureName = glyphTextureName[par1]; }
public FontRendererOld(GameSettings par1GameSettings, string par2Str, RenderEngine par3RenderEngine, bool par4) { charWidth = new int[256]; FontTextureName = ""; FontHeight = 8; FontRandom = new Random(); glyphWidth = new byte[0x10000]; glyphTextureName = new string[256]; colorCode = new int[32]; renderEngine = par3RenderEngine; unicodeFlag = par4; Texture2D bufferedimage; try { bufferedimage = RenderEngine.Instance.GetTexture(par2Str); Stream inputstream = Minecraft.GetResourceStream("font.glyph_sizes.bin"); inputstream.Read(glyphWidth, 0, 0x10000); } catch (IOException ioexception) { Console.WriteLine(ioexception.ToString()); Console.WriteLine(); throw ioexception; } int i = bufferedimage.Width; int j = bufferedimage.Height; int[] ai = new int[i * j]; bufferedimage.GetData <int>(ai); //bufferedimage.getRGB(0, 0, i, j, ai, 0, i); for (int k = 0; k < 256; k++) { int i1 = k % 16; int k1 = k / 16; int i2 = 7; /* * do * { * if (i2 < 0) * { * break; * } * * int k2 = i1 * 8 + i2; * bool flag = true; * * for (int j3 = 0; j3 < 8 && flag; j3++) * { * int l3 = (k1 * 8 + j3) * i; * int j4 = ai[k2 + l3] & 0xff; * * if (j4 > 0) * { * flag = false; * } * } * * if (!flag) * { * break; * } * * i2--; * } * while (true); */ if (k == 32) { i2 = 2; } charWidth[k] = i2 + 2; } FontTextureName = par3RenderEngine.AllocateTexture(bufferedimage); for (int l = 0; l < 32; l++) { int j1 = (l >> 3 & 1) * 85; int l1 = (l >> 2 & 1) * 170 + j1; int j2 = (l >> 1 & 1) * 170 + j1; int l2 = (l >> 0 & 1) * 170 + j1; if (l == 6) { l1 += 85; } if (par1GameSettings.Anaglyph) { int i3 = (l1 * 30 + j2 * 59 + l2 * 11) / 100; int k3 = (l1 * 30 + j2 * 70) / 100; int i4 = (l1 * 30 + l2 * 70) / 100; l1 = i3; j2 = k3; l2 = i4; } if (l >= 16) { l1 /= 4; j2 /= 4; l2 /= 4; } colorCode[l] = (l1 & 0xff) << 16 | (j2 & 0xff) << 8 | l2 & 0xff; } }