此图像是78 * 24字母的图像,每个字母为6 * 6,总共52个正方形。
不会使用glTexCoord从该图像中获取单个字母变得有点乏味吗?
GL11.glTexCoord2f(0,0);
GL11.glTexCoord2f(0.0769f,0);
GL11.glTexCoord2f(0.0769f,0.25f);
GL11.glTexCoord2f(0,0.25f);
由于78的1/13(0.0769)是6而24的1/4(0.25)是6,这是我要做的那种,单挑一个字母?我只是确保这是要走的路。
答案 0 :(得分:2)
您可能想要编写一个函数/方法来为单个字符创建纹理坐标。既然您知道了字符的数量以及可能只是将字符传递给该方法的尺寸,那么计算坐标并返回这些坐标,例如:
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
}