Created
March 17, 2012 21:39
-
-
Save thvortex/2065520 to your computer and use it in GitHub Desktop.
Fade out text fix plus possible white text fix for buggy GL drivers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/minecraft/net/minecraft/src/FontRenderer.java b/src/minecraft/net/minecraft/src/FontRenderer.java | |
index a10060d..ac492a6 100644 | |
--- a/src/minecraft/net/minecraft/src/FontRenderer.java | |
+++ b/src/minecraft/net/minecraft/src/FontRenderer.java | |
@@ -154,7 +154,7 @@ public class FontRenderer | |
/** | |
* Render a single character with the default.png font at current (posX,posY) location. | |
*/ | |
- private void renderDefaultChar(int par1) | |
+ private void renderDefaultChar(int par1, int color) | |
{ | |
float f = (par1 % 16) * 8; | |
float f1 = (par1 / 16) * 8; | |
@@ -166,16 +166,15 @@ public class FontRenderer | |
} | |
float f2 = (float)charWidth[par1] - 0.01F; | |
- GL11.glBegin(GL11.GL_TRIANGLE_STRIP); | |
- GL11.glTexCoord2f(f / 128F, f1 / 128F); | |
- GL11.glVertex3f(posX, posY, 0.0F); | |
- GL11.glTexCoord2f(f / 128F, (f1 + 7.99F) / 128F); | |
- GL11.glVertex3f(posX, posY + 7.99F, 0.0F); | |
- GL11.glTexCoord2f((f + f2) / 128F, f1 / 128F); | |
- GL11.glVertex3f(posX + f2, posY, 0.0F); | |
- GL11.glTexCoord2f((f + f2) / 128F, (f1 + 7.99F) / 128F); | |
- GL11.glVertex3f(posX + f2, posY + 7.99F, 0.0F); | |
- GL11.glEnd(); | |
+ Tessellator tess = Tessellator.instance; | |
+ tess.startDrawing(GL11.GL_TRIANGLE_STRIP); | |
+ tess.setColorRGBA(color >> 16 & 0xff, color >> 8 & 0xff, color & 0xff, color >> 24 & 0xff); | |
+ tess.addVertexWithUV(posX, posY, 0.0F, f / 128F, f1 / 128F); | |
+ tess.addVertexWithUV(posX, posY + 7.99F, 0.0F, f / 128F, (f1 + 7.99F) / 128F); | |
+ tess.addVertexWithUV(posX + f2, posY, 0.0F, (f + f2) / 128F, f1 / 128F); | |
+ tess.addVertexWithUV(posX + f2, posY + 7.99F, 0.0F, (f + f2) / 128F, (f1 + 7.99F) / 128F); | |
+ tess.draw(); | |
+ | |
posX += charWidth[par1]; | |
} | |
@@ -206,7 +205,7 @@ public class FontRenderer | |
/** | |
* Render a single Unicode character at current (posX,posY) location using one of the /font/glyph_XX.png files. | |
*/ | |
- private void renderUnicodeChar(char par1) | |
+ private void renderUnicodeChar(char par1, int color) | |
{ | |
if (glyphWidth[par1] == 0) | |
{ | |
@@ -233,16 +232,14 @@ public class FontRenderer | |
float f2 = (float)((par1 % 16) * 16) + f; | |
float f3 = ((par1 & 0xff) / 16) * 16; | |
float f4 = f1 - f - 0.02F; | |
- GL11.glBegin(GL11.GL_TRIANGLE_STRIP); | |
- GL11.glTexCoord2f(f2 / 256F, f3 / 256F); | |
- GL11.glVertex3f(posX, posY, 0.0F); | |
- GL11.glTexCoord2f(f2 / 256F, (f3 + 15.98F) / 256F); | |
- GL11.glVertex3f(posX, posY + 7.99F, 0.0F); | |
- GL11.glTexCoord2f((f2 + f4) / 256F, f3 / 256F); | |
- GL11.glVertex3f(posX + f4 / 2.0F, posY, 0.0F); | |
- GL11.glTexCoord2f((f2 + f4) / 256F, (f3 + 15.98F) / 256F); | |
- GL11.glVertex3f(posX + f4 / 2.0F, posY + 7.99F, 0.0F); | |
- GL11.glEnd(); | |
+ Tessellator tess = Tessellator.instance; | |
+ tess.startDrawing(GL11.GL_TRIANGLE_STRIP); | |
+ tess.setColorRGBA(color >> 16 & 0xff, color >> 8 & 0xff, color & 0xff, color >> 24 & 0xff); | |
+ tess.addVertexWithUV(posX, posY, 0.0F, f2 / 256F, f3 / 256F); | |
+ tess.addVertexWithUV(posX, posY + 7.99F, 0.0F, f2 / 256F, (f3 + 15.98F) / 256F); | |
+ tess.addVertexWithUV(posX + f4 / 2.0F, posY, 0.0F, (f2 + f4) / 256F, f3 / 256F); | |
+ tess.addVertexWithUV(posX + f4 / 2.0F, posY + 7.99F, 0.0F, (f2 + f4) / 256F, (f3 + 15.98F) / 256F); | |
+ tess.draw(); | |
posX += (f1 - f) / 2.0F + 1.0F; | |
} | |
@@ -362,7 +359,7 @@ public class FontRenderer | |
/** | |
* Render a single line string at the current (posX,posY) and update posX | |
*/ | |
- private void renderStringAtPos(String par1Str, boolean par2) | |
+ private void renderStringAtPos(String par1Str, int color, boolean par2) | |
{ | |
boolean flag = false; | |
@@ -392,8 +389,7 @@ public class FontRenderer | |
j += 16; | |
} | |
- int l = colorCode[j]; | |
- GL11.glColor3f((float)(l >> 16) / 255F, (float)(l >> 8 & 0xff) / 255F, (float)(l & 0xff) / 255F); | |
+ color = colorCode[j] & 0xffffff | color & 0xff000000; | |
} | |
i++; | |
@@ -423,11 +419,11 @@ public class FontRenderer | |
if (k > 0 && !unicodeFlag) | |
{ | |
- renderDefaultChar(k + 32); | |
+ renderDefaultChar(k + 32, color); | |
} | |
else | |
{ | |
- renderUnicodeChar(c); | |
+ renderUnicodeChar(c, color); | |
} | |
} | |
} | |
@@ -441,7 +437,7 @@ public class FontRenderer | |
{ | |
boundTextureName = 0; | |
- if ((par4 & 0xfc000000) == 0) | |
+ if ((par4 & 0xff000000) == 0) | |
{ | |
par4 |= 0xff000000; | |
} | |
@@ -451,10 +447,9 @@ public class FontRenderer | |
par4 = (par4 & 0xfcfcfc) >> 2 | par4 & 0xff000000; | |
} | |
- GL11.glColor4f((float)(par4 >> 16 & 0xff) / 255F, (float)(par4 >> 8 & 0xff) / 255F, (float)(par4 & 0xff) / 255F, (float)(par4 >> 24 & 0xff) / 255F); | |
posX = par2; | |
posY = par3; | |
- renderStringAtPos(par1Str, par5); | |
+ renderStringAtPos(par1Str, par4, par5); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment