通常我使用从 0 到 1 的纹理坐标。
glTexCoord2f(0, 0);
glTexCoord2f(1, 0);
glTexCoord2f(1, 1);
glTexCoord2f(0, 1);
如果我需要纹理部分(剪辑),我使用 -
glTexCoord2f(Texture.Left / Texture.Width, Texture.Top / Texture.Height);
glTexCoord2f(Texture.Right / Texture.Width, Texture.Top / Texture.Height);
glTexCoord2f(Texture.Right / Texture.Width, Texture.Bottom / Texture.Height);
glTexCoord2f(Texture.Left / Texture.Width, Texture.Bottom / Texture.Height);
如果我需要重复纹理 A x B 次,我使用 -
glTexCoord2f(0, 0);
glTexCoord2f(A, 0);
glTexCoord2f(A, B);
glTexCoord2f(0, B);
虽然如果我只需要重复部分纹理(剪辑)这不起作用 -
glTexCoord2f(Texture.Left / Texture.Width * A, Texture.Top / Texture.Height * B);
glTexCoord2f(Texture.Right / Texture.Width * A, Texture.Top / Texture.Height * B);
glTexCoord2f(Texture.Right / Texture.Width * A, Texture.Bottom / Texture.Height * B);
glTexCoord2f(Texture.Left / Texture.Width * A, Texture.Bottom / Texture.Height * B);