<p>I'm trying to apply a texture to 4 different triangle strips using JOGL (OpenGL/Java). I'm trying to make a 1000×1000 path in a square, where the path is 100 wide. The texture should be stamped 10 times on each side (though the corner pieces will have a diagonal discontinuity). I'm making 4 trapezoids here:</p>
<pre><code>float[] positions = { /* S,W,N,E */
        500,-50,500, 400,-50,400, -500,-50,500, -400,-50,400,
        -500,-50,500, -400,-50,400, -500,-50,-500, -400,-50,-400,
        -500,-50,-500, -400,-50,-400, 500,-50,-500, 400,-50,-400,
        500,-50,-500, 400,-50,-400, 500,-50,500, 400,-50,400
};
float[] textureCoords = {
    0f,0f, 1f,1f, 0f,10f, 1f,9f,
    0f,0f, 1f,1f, 0f,10f, 1f,9f,
    0f,0f, 1f,1f, 0f,10f, 1f,9f,
    0f,0f, 1f,1f, 0f,10f, 1f,9f
};
</code></pre>
<p>I then get this data into VBOs, and every frame I draw with the following code:</p>
<pre><code>gl.glActiveTexture(GL_TEXTURE0);
gl.glBindTexture(GL_TEXTURE_2D, textureIDs[0]);
gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
for (int i=0; i&lt;4; i++) gl.glDrawArrays(GL_TRIANGLE_STRIP, i*4, 4);
</code></pre>
<p><a href="https://i.sstatic.net/zQVZn.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/zQVZn.png" alt="Texture smeared out" /></a></p>
<p>The texture appears to be loading fine. You can see that it looks okay in one triangle of the trapezoid, within the range (0,0 -&gt; 1,1). But as soon as my interpolated (s,t) values leave that range, it just smears things. I'm very confused by this--isn't it supposed to tile, when I have texture coordinates beyond 1.0? Does this have something to do with using GL_TRIANGLE_STRIP to draw?</p>

<opengl><texture><java>
Why is my texture being stretched out on a triangle strip?
Adam Smith
# Why is my texture being stretched out on a triangle strip?

(Asked by: username_0 on 2022-10-02)

I'm trying to apply a texture to 4 different triangle strips using JOGL (OpenGL/Java). I'm trying to make a 1000×1000 path in a square, where the path is 100 wide. The texture should be stamped 10 times on each side (though the corner pieces will have a diagonal discontinuity). I'm making 4 trapezoids here:
float[] positions = { /* S,W,N,E */
        500,-50,500, 400,-50,400, -500,-50,500, -400,-50,400,
        -500,-50,500, -400,-50,400, -500,-50,-500, -400,-50,-400,
        -500,-50,-500, -400,-50,-400, 500,-50,-500, 400,-50,-400,
        500,-50,-500, 400,-50,-400, 500,-50,500, 400,-50,400
};
float[] textureCoords = {
    0f,0f, 1f,1f, 0f,10f, 1f,9f,
    0f,0f, 1f,1f, 0f,10f, 1f,9f,
    0f,0f, 1f,1f, 0f,10f, 1f,9f,
    0f,0f, 1f,1f, 0f,10f, 1f,9f
};

I then get this data into VBOs, and every frame I draw with the following code:
gl.glActiveTexture(GL_TEXTURE0);
gl.glBindTexture(GL_TEXTURE_2D, textureIDs[0]);
gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
for (int i=0; i<4; i++) gl.glDrawArrays(GL_TRIANGLE_STRIP, i*4, 4);


The texture appears to be loading fine. You can see that it looks okay in one triangle of the trapezoid, within the range (0,0 -> 1,1). But as soon as my interpolated (s,t) values leave that range, it just smears things. I'm very confused by this--isn't it supposed to tile, when I have texture coordinates beyond 1.0? Does this have something to do with using GL_TRIANGLE_STRIP to draw?

**Tags:** opengl, texture, java

---

## 0 answers

