Skip to content

Instantly share code, notes, and snippets.

@elucent
Created August 1, 2017 01:01
Show Gist options
  • Save elucent/d5b349651540917331fa12b47f5f9c52 to your computer and use it in GitHub Desktop.
Save elucent/d5b349651540917331fa12b47f5f9c52 to your computer and use it in GitHub Desktop.
public static void drawString(float x, float y, float z, String text){
glBindTexture(GL_TEXTURE_2D,TextureManager.get("font"));
glDepthMask(false);
glBegin(GL_QUADS);
byte[] bytes = text.getBytes(StandardCharsets.UTF_8);
glColor4f(1,1,1,1);
for (int i = 0; i < text.length(); i ++){
int asciiCode = bytes[i]-1;
int minU = (asciiCode%16)*8;
int minV = (asciiCode/16)*8;
draw2DQuad(x+i*0.4375f,y+0.5f,z,0.5f,0.5f,minU,minV,minU+8f,minV+8f,128f,128f);
}
glEnd();
glDepthMask(true);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment