From 40de734a68cd83d4e1d3ab96703b57bf896bcae0 Mon Sep 17 00:00:00 2001 From: DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> Date: Mon, 14 Feb 2022 21:19:30 +0100 Subject: Make font renderer work --- .../polyfrost/oneconfig/renderer/TrueTypeFont.java | 29 ++++++++++++---------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'src/main/java/io/polyfrost/oneconfig/renderer') diff --git a/src/main/java/io/polyfrost/oneconfig/renderer/TrueTypeFont.java b/src/main/java/io/polyfrost/oneconfig/renderer/TrueTypeFont.java index 1ce922b..16e7556 100644 --- a/src/main/java/io/polyfrost/oneconfig/renderer/TrueTypeFont.java +++ b/src/main/java/io/polyfrost/oneconfig/renderer/TrueTypeFont.java @@ -1,5 +1,7 @@ package io.polyfrost.oneconfig.renderer; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.GlStateManager; import org.lwjgl.BufferUtils; import org.lwjgl.opengl.GL11; import org.lwjgl.util.glu.GLU; @@ -262,14 +264,18 @@ public class TrueTypeFont { float RenderWidth = (SrcWidth / textureWidth); float RenderHeight = (SrcHeight / textureHeight); - GL11.glTexCoord2f(TextureSrcX, TextureSrcY); - GL11.glVertex2f(drawX, drawY); - GL11.glTexCoord2f(TextureSrcX, TextureSrcY + RenderHeight); - GL11.glVertex2f(drawX, drawY + DrawHeight); - GL11.glTexCoord2f(TextureSrcX + RenderWidth, TextureSrcY + RenderHeight); - GL11.glVertex2f(drawX + DrawWidth, drawY + DrawHeight); - GL11.glTexCoord2f(TextureSrcX + RenderWidth, TextureSrcY); - GL11.glVertex2f(drawX + DrawWidth, drawY); + GlStateManager.bindTexture(fontTextureID); + + GL11.glBegin(GL11.GL_TRIANGLE_STRIP); + GL11.glTexCoord2f(TextureSrcX + RenderWidth, TextureSrcY); // 2 + GL11.glVertex2f(drawX + DrawWidth, drawY + DrawHeight); // 1 + GL11.glTexCoord2f(TextureSrcX, TextureSrcY); // 1 + GL11.glVertex2f(drawX, drawY + DrawHeight); // 2 + GL11.glTexCoord2f(TextureSrcX + RenderWidth, TextureSrcY + RenderHeight); // 4 + GL11.glVertex2f(drawX + DrawWidth, drawY); // 3 + GL11.glTexCoord2f(TextureSrcX, TextureSrcY + RenderHeight); // 3 + GL11.glVertex2f(drawX, drawY); // 4 + GL11.glEnd(); } public int getWidth(String whatchars) { @@ -362,9 +368,7 @@ public class TrueTypeFont { } - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glBindTexture(GL11.GL_TEXTURE_2D, fontTextureID); - GL11.glBegin(GL11.GL_QUADS); + //GlStateManager.enableTexture2D(); while (i >= startIndex && i <= endIndex) { @@ -406,8 +410,7 @@ public class TrueTypeFont { } } - GL11.glDisable(GL11.GL_TEXTURE_2D); - GL11.glEnd(); + //GlStateManager.disableTexture2D(); } public static int loadImage(BufferedImage bufferedImage) { -- cgit