OpenGl Es 2.0 Texture Mapping Problem

Hello,

I render a street with OpenGL ES 2.0 and use TRIANGLE_STRIP for it. Now I want to add a texture to my road and use repead as the wrapping method. The street consists of segments. If the segment is 5 meters long, i want to map my texture 5 times to it, 3 meter 3 times and so on.

My problem looks like this:
[ATTACH=CONFIG]1199[/ATTACH]
If the road is to long the texture is wrong. It looks like I use CLAMP_TO_EDGE.

If I have a road that consits out of 10 segments, then I have 22 vertices. The variable “offsets” is a QVector with 10 elements and defines the length of each segment.
Here is the C++ (Qt) code for generating the texture coordinates:


...
    float len = 0;
    QVector<QVector2D> texcoords;
    texcoords.append(QVector2D(0.0, 0.0));
    texcoords.append(QVector2D(0.0, 1.0));
    for (GLubyte i = 0; i < offsets.size(); i++) {
        len += offsets[i];
        texcoords.append(QVector2D(len, 0.0));
        texcoords.append(QVector2D(len, 1.0));
    }
 
    glBindTexture(GL_TEXTURE_2D, m_asphaltTexId);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_asphaltTex.width(), m_asphaltTex.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, m_asphaltTex.bits());
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
 
    f->glVertexAttribPointer(m_aTexCoordLoc, 2, GL_FLOAT, GL_FALSE, 0, texcoords.data());
    f->glEnableVertexAttribArray(m_aTexCoordLoc);
...

Are the UV respectively ST coordinates limited to a maximum value?
Where is my problem?

Best regards
Eikou

No.

Check that the offsets are correct. You would get that result if all of the offsets after the first were zero (or very small).

Check that the wrap mode isn’t being changed back to clamping.

Ensure that the texture dimensions are powers of two. It’s invalid to use non-power-of-two textures with a wrap mode other than clamp-to-edge. That should cause texture reads to return (0,0,0,1), but implementers often treat the handling of “error” cases as a low priority, so it’s conceivable that an implementation might just force clamp-to-edge in that case.

[QUOTE=GClements;1277817]
Ensure that the texture dimensions are powers of two. It’s invalid to use non-power-of-two textures with a wrap mode other than clamp-to-edge …[/QUOTE]

Thank you very much GClements!!! The dimensions of my texture causes this problem. :slight_smile:

Best regards
Eikou