I'm drawing a quad and binding a texture to this quad like this:
#define TERRAIN_WIDTH 2000 #define TERRAIN_LENGTH 2000 #define TERRAIN_WIDTH_2 (TERRAIN_WIDTH / 2) #define TERRAIN_LENGTH_2 (TERRAIN_LENGTH / 2) glBindTexture(GL_TEXTURE_2D, gameTextures.terrain); glBegin(GL_QUADS); glTexCoord2f(0, 0); glVertex3f(-TERRAIN_WIDTH_2, 0.0f, TERRAIN_LENGTH_2); glTexCoord2f(X, 0); glVertex3f( TERRAIN_WIDTH_2, 0.0f, TERRAIN_LENGTH_2); glTexCoord2f(X, X); glVertex3f( TERRAIN_WIDTH_2, 0.0f, -TERRAIN_LENGTH_2); glTexCoord2f(0, X); glVertex3f(-TERRAIN_WIDTH_2, 0.0f, -TERRAIN_LENGTH_2); glEnd(); glBindTexture(GL_TEXTURE_2D, 0);
X would be equal to
1 but this will stretch the texture because the quad is very large. The idea is to increase that value so the texture is repeated (the texture was generated with
GL_REPEAT of course).
But how should I find the best value for
X? I have a few 512x512 textures which look nice if I replace
X=512. Then I have another 1024x1024 texture which looks good to with
X=512 but doesn't start to look so good with a higher/lower value. Another texture is 2048x2048 and now I need to go down to
X=256, otherwise it won't look so good.
What's confusing me even more is the fact that both 512x512 and 1024x1024 textures look good with
X=512. The way I see it, the lower the texture resolution, the more times I need to repeat it.
How should I calculate the value of X then?