I am about to go mad because of texture mapping of openGL. It nevers maps the right thing, please have a look.
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, speed.texID);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
glBegin(GL_QUADS);
glTexCoord2f(1,0);
glVertex2f(210, 638); //Top-Left
glTexCoord2f(1,1);
glVertex2f(210, 438); //Top-Right
glTexCoord2f(0,1);
glVertex2f(10, 438); //Bottom-Right
glTexCoord2f(0,0);
glVertex2f(10, 638); //Bottom-Left
glEnd();
glDisable(GL_TEXTURE_2D);
After this code output image becomes this:
But I want it to be like this:
When I change the texture to something else, it maps it correctly but apparently not this one. Why do you think this could be?
If other textures work, chances are this texture is an odd size or different format, and has been loaded without observing some necessary padding.
It is common for texture formats to need to be an even number of pixels, or to be rounded to some other multiple.
The 45-degree slant to the texture is also indicative of this kind of issue, as it often results from an extra pixel being read (or skipped) every line at some point in the pipeline.
Possible fixes for this are:
glPixelStorei()