Hello, I am currently taking an opengl class and have hit a wall with my texture coordinates. I am attempting to have my texture drawn onto a vehicle made up of triangles but no matter what combination of coordinates I use there is always unwanted stretching on some parts and working perfectly on others.
This is what I am currently using to populate my texture coordinates:
for (unsigned int z = 0; z < m_texture.getWidth(); z++)
{
m_texCoords.push_back(TexCoord(0.0f, 1.0f));
m_texCoords.push_back(TexCoord(1.0f, 1.0f));
m_texCoords.push_back(TexCoord(0.0f, 0.0f));
m_texCoords.push_back(TexCoord(1.0f, 0.0f));
}
I have also tried:
m_texCoords.push_back(TexCoord(0.0f, 0.0f));
m_texCoords.push_back(TexCoord(1.0f, 0.0f));
m_texCoords.push_back(TexCoord(0.0f, 1.0f));
m_texCoords.push_back(TexCoord(1.0f, 0.0f));
m_texCoords.push_back(TexCoord(0.0f, 1.0f));
m_texCoords.push_back(TexCoord(1.0f, 1.0f));
The first is the only combination I have found that gives me the least amount of stretching on multiple parts.
Here is how I set up the texture:
glGenTextures(1, &m_textureID);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, m_textureID);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_texture.getWidth(), m_texture.getHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, m_texture.getImageData());
If anyone could give me a hand I would greatly appreciate it.