I have a simple cube mesh, which I scale with modifying the model matrix.
Texture settings:
glGenTextures(1, &m_texture);
glBindTexture(GL_TEXTURE_2D, m_texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
I set GL_REPEAT
as wrap mode, but in my case it doesn't help, because the texture coordinates don't exceed [0...1]
.
For example from the unit cube I want to make a column whose dimensions are (1,10,1).
Just scaling this doesn't work because it textures the cube and then applies the scaling, which means that the texture will be stretched, instead of repeated along the y axis.
How can I implement this so I could set the length, width and depth of a cube dynamically and the texture will be repeated on it instead of stretched?