0

https://i.stack.imgur.com/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.

GlassZee
  • 1,117
  • 2
  • 11
  • 22
  • 2
    It might be tedious, but you can always write a function that will abstract out the details and then in the actual drawing code, just call that function. – Platinum Azure Mar 26 '12 at 18:13
  • Thanks, I guess I'm on the right track then. And yea, automating it sounds like a good idea, I'll work on something that does that next. – GlassZee Mar 26 '12 at 18:20

1 Answers1

2

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
}
Thomas
  • 87,414
  • 12
  • 119
  • 157