Reputation: 1127
https://i.sstatic.net/bRXcy.png
This image is a 78*24 image of the alphabet, with each letter in a 6*6, so 52 total squares.
Wouldn't using glTexCoord to get a single letter out of that image get kind of tedious?
GL11.glTexCoord2f(0,0);
GL11.glTexCoord2f(0.0769f,0);
GL11.glTexCoord2f(0.0769f,0.25f);
GL11.glTexCoord2f(0,0.25f);
Since 1/13(0.0769) of 78 is 6 and 1/4(0.25) of 24 is 6, is this kind of what I'm looking to do, to single out a letter? I'm just making sure this is the way to go.
Upvotes: 0
Views: 230
Reputation: 88707
You might want to write a function/method to create the texture coordinates for a single character. Since you know the number of characters as well as the dimensions you might just pass the character into that method, calculate the coordinates and return those, e.g.
Vector2D[] getCharacterCoords(char c) {
//calculate the coords with the knowledge that you have 78 * 24 pixels and a character is 6 * 6
//thus resulting in a 13 * 4 character grid.
//Note: since ASCII 'A' is code 65 and 'a' is 97 you'd need to subtract those values accordingly
}
Upvotes: 2