# Texture Wrapping isn't being applied properly

I've debugged my application with codeXL and can verify that my texture is getting these attributes applied:

GL_TEXTURE_MIN_FILTER: GL_LINEAR
GL_TEXTURE_MAG_FILTER: GL_LINEAR
GL_TEXTURE_WRAP_S: GL_CLAMP_TO_EDGE
GL_TEXTURE_WRAP_T: GL_CLAMP_TO_EDGE
GL_TEXTURE_WRAP_R: GL_CLAMP_TO_EDGE


With the following UV data:

0, 0,
1, 0,
1, 1,
1, 1,
0, 1,
0, 0,
0, 0,
1, 0,
1, 1,
1, 1,
0, 1,
0, 0,
0, 1,
0, 1,
0, 0,
0, 0,
0, 0,
0, 1,
1, 1,
1, 1,
1, 0,
1, 0,
1, 0,
1, 1,
0, 0,
1, 0,
1, 0,
1, 0,
0, 0,
0, 0,
0, 1,
1, 1,
1, 1,
1, 1,
0, 1,
0, 1


Yet my cube still looks like this: http://imgur.com/Dj2hCkp

The Front and Back are being mapped fine, but the sides and top/bot are all stretched. I've tried with GL_REPEAT, GL_CLAMP_TO_EDGE/BORDER, GL_MIRRORED_REPEAT, it's all the same result. I've tried only doing it with S and T. At this point I'm not sure what the problem is.

Vertex Shader + fragment + Buffers: (It's not that long)

https://ideone.com/5U39M3

I'm not really sure what it could be at this point. I thought my texture wasn't getting it's attributes applied correctly, but it is. Then i thought it was just my wrapping method, but all methods lead to the same result.

• My crystal ball tells me that your UV coordinates for vertices are incorrect or used incorrectly. – HolyBlackCat Jun 12 '16 at 20:27
• I calculate them by clamping the x,y vertices position to 0-1 by doing UV = vec2((Position.x + 1.0) / 2.0 ), (Position.y + 1.0) / 2.0); so they should be right. – Omar Martinez Jun 12 '16 at 20:29
• Nope. You don't take Z into account. – HolyBlackCat Jun 12 '16 at 20:53
• I'm using the same texture on all sides, so I didn't think I needed the z coordinator. Glsl won't let me pass in a texture(sampler2DTexture, textureCoords); sampler2D needs a vec2 as Texpositions. – Omar Martinez Jun 12 '16 at 21:21
• I'm pretty sure that texture coordinates are incorrect. Instead of computing them you can try to specify them manually. (I think there is no way of computing texture coordinate for a point based only on it's position.) – HolyBlackCat Jun 12 '16 at 21:56