I am using OpenGL to draw textures in my game.
glClear(GL_COLOR_BUFFER_BIT);
float w = 128;
float h = 128;
w *= scale;
h *= scale;
GLfloat vertices[] = {
w, 0,
w, h,
0, 0,
0, h
};
float u1 = 0;
float u2 = 1;
float v1 = 0;
float v2 = 1;
GLfloat texCoords[] = {
u2, v1,
u2, v2,
u1, v1,
u1, v2
};
glVertexPointer(2, GL_FLOAT, 0, vertices);
glEnableClientState(GL_VERTEX_ARRAY);
glTexCoordPointer(2, GL_FLOAT, 0, texCoords);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
It is a simple example to explain my problem. I change scale variable, which impacts only on triangle vertices and should not alter texture coordinates. When scale is 1, i have this picture:
one http://dl.dropbox.com/u/21467/opengl/1.png
When I change scale to 0.99, I have this picture:
two http://dl.dropbox.com/u/21467/opengl/3.png
If you look carefully, you notice little stripe on the top of the texture. Why is it there and how can I avoid it?
In my real game I draw tiles and if I change scale, my tiles start having those stripes and in result I got this nasty grid of stripes in my game. Does anybody know, what is wrong?