diff options
author | DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> | 2022-02-14 21:19:30 +0100 |
---|---|---|
committer | DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> | 2022-02-14 21:19:30 +0100 |
commit | 40de734a68cd83d4e1d3ab96703b57bf896bcae0 (patch) | |
tree | 5d7f9f93864eee045cd6a19e9f05837bde8a3b08 /src/main/java/io | |
parent | 752979fec2f8a902a319691a92f468f27137c16a (diff) | |
download | OneConfig-40de734a68cd83d4e1d3ab96703b57bf896bcae0.tar.gz OneConfig-40de734a68cd83d4e1d3ab96703b57bf896bcae0.tar.bz2 OneConfig-40de734a68cd83d4e1d3ab96703b57bf896bcae0.zip |
Make font renderer work
Diffstat (limited to 'src/main/java/io')
-rw-r--r-- | src/main/java/io/polyfrost/oneconfig/gui/Window.java | 8 | ||||
-rw-r--r-- | src/main/java/io/polyfrost/oneconfig/renderer/TrueTypeFont.java | 29 |
2 files changed, 19 insertions, 18 deletions
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/Window.java b/src/main/java/io/polyfrost/oneconfig/gui/Window.java index 8a1c434..7456026 100644 --- a/src/main/java/io/polyfrost/oneconfig/gui/Window.java +++ b/src/main/java/io/polyfrost/oneconfig/gui/Window.java @@ -22,7 +22,7 @@ public class Window extends GuiScreen { TrueTypeFont font; public Window() { - font = new TrueTypeFont(new Font("FreeSerif", Font.PLAIN, 30), true); + font = new TrueTypeFont(new Font("FreeSerif", Font.PLAIN, 40), true); super.initGui(); currentWindow = this; guiScaleToRestore = Minecraft.getMinecraft().gameSettings.guiScale; @@ -39,8 +39,8 @@ public class Window extends GuiScreen { int alphaVal = (int) (50 * currentProgress); drawGradientRect(0, 0, super.width, super.height, new Color(80, 80, 80, alphaVal).getRGB(), new Color(80, 80, 80, alphaVal + 10).getRGB()); //drawWindow(); - GL11.glTranslatef(0, 0, 3000); - font.drawString(50, 50, "e", 1, 1); + //Minecraft.getMinecraft().fontRendererObj.drawString() + font.drawString(50, 50, "Test", 1, 1); } public void drawWindow() { @@ -59,8 +59,6 @@ public class Window extends GuiScreen { Gui.drawRect(left, top + 100, right, top + 101, testingColor.getRGB()); t.getTextureManager().draw(ThemeElement.ALL_MODS, 10, 10, 32, 32); - - } public static Window getWindow() { 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) { |