Created
August 1, 2017 01:01
-
-
Save elucent/d5b349651540917331fa12b47f5f9c52 to your computer and use it in GitHub Desktop.
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
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