I am having some trouble rendering fonts with LWJGL, i have a 128x128 png with all the letters drawn out, my current code is
package com.bomberBox.game.screen;
import org.lwjgl.opengl.GL11;
import com.bomberBox.game.TextureHandler;
public class Font {
private static final String chars = "" + //
"ABCDEFGHIJ" +//
"KLMNOPQRST" +//
"UVWXYZabcd" +//
"efghijklmn" +//
"opqrstuvwx" +//
"yz/#: " +//
"0123456789";
public static void draw(String string, int x, int y, float r, float g, float b, float a) {
for (int i = 0; i < string.length(); i++) {
int ch = chars.indexOf(string.charAt(i));
if (ch < 0) continue;
int xx = (ch % 10) * 12;
int yy = (ch / 10) * 16;
int xd = x + i * 12;
GL11.glPushMatrix();
GL11.glColor4f(r, g, b, a);
TextureHandler.font.bind();
GL11.glBegin(GL11.GL_QUADS);
GL11.glTexCoord2f(xx, yy); GL11.glVertex2f(xd, y);
GL11.glTexCoord2f(xx + 10, yy); GL11.glVertex2f(xd+20, y);
GL11.glTexCoord2f(xx + 10, yy + 16); GL11.glVertex2f(xd+20, y+32);
GL11.glTexCoord2f(xx, yy + 16); GL11.glVertex2f(xd, y+32);
GL11.glEnd();
GL11.glPopMatrix();
}
}
}
It renders some white bars but not the font or words… I am struggling to see where i’ve gone wrong…