I using OpenGL 4.1 and GLSL 410. I am attempting to texture a square that I made using the following coordinates:
float points[] = {
-0.5, 0.5,
-0.5, -0.5,
0.5, -0.5,
-0.5, 0.5,
0.5, -0.5,
0.5, 0.5
};
I draw the square like this:
glDrawArrays (GL_TRIANGLES, 0, 6);
From all of the tutorials I have read, the author uses an element buffer to draw the square or has just four vertices. This means that all the tutorials I have read have texture coordinates that line up with each vertex. For me, I'm using 6 vertices, so I'm not sure how to line up the texture coordinates.
Would coordinates like this work for my case:
float texcoords[] = {
0.0, 1.0,
0.0, 0.0,
1.0, 0.0,
0.0, 1.0,
1.0, 0.0,
1.0, 1.0
};
I've done lots of reading, but haven't come across anyone else who is using six vertices like I am.
Would my texture coordinates work and if not, what is the best way to come up with texture coordinates.