Incorrect Texture Mapping

Mesh : Plane_Plane.001
Vertices:
V0: P(-0.733609, 0, 0.733609) N(0, 1, 0) TC(0, 0)
V1: P(0.733609, 0, 0.733609) N(0, 1, 0) TC(1, 0)
V2: P(0.733609, 0, -0.733609) N(0, 1, 0) TC(1, 1)
V3: P(-0.733609, 0, -0.733609) N(0, 1, 0) TC(0, 1)
Indices:
T0: 0, 1, 3
T1: 1, 2, 3

Hey all…

I am trying to write some OpenGL to map a texture on to a simple plane, composed of two triangles. It’s real close to working, but it appears that the UV mapping is messed up. I’ve included the output image of a flower mapped to the plane, as well as a screenshot of the OBJ data as interpreted by my “stb_image” loader after loading the PNG.

I’ve tried everything I can think of, but no luck. It appears to be something maybe related to winding, and as you can see in the plane’s vertex data (exported from Blender, BTW), it seems to be CW winding. I’ve tried setting “void glFrontFace(GLenum = GL_CW);”, but that doesn’t seem to matter. As you can see, it’s applying the top right coordinate of the texture to the top left coordinate of the plane.

I’d post some code but I’m not sure what is pertinent. Anyone have any ideas on where to look? Thanks much.

For clarity, I made a simple grid PNG and mapped it to the plane, and here’s the result. Clearly it seems it’s mapping the upper right image UV to the upper left plane coordinate.

Okay, I found the problem. Stupid mistake.

My vertices have 3 attributes: position, normal, and texture coordinates.

For my normals, I stupidly set and bound a separate normals buffer, and then set the attributes, rather than just referencing those attributes held in the vertex buffer. So to fix it I just commented out the generation of a separate normals buffer, and left the AttribArray and AttribPointer calls, and all is well.