Update answer to account for inaccuracy.
Source Link
kevintodisco
  • 3.8k
  • 1
  • 13
  • 26

The call you're looking for is

glTexCoordPointer(2, GL_FLOAT, sizeof(float)*6, (GLvoid*)(sizeof(float)*4));

The first argument is the number of elements that need to be read per element (vertex), and it's two because texture coordinates are just u and v coordinates. The second argument describes the type of data being passed. In this case, they're floats.

The third argument is the stride, which is the byte offset between consecutive texture coordinates. In this case, it's simply the size of one of your vertex-texcoord pairs (if I'm understanding the way you packed the data correctly). In other words, there are 6 floats between the start of two texture coordinates and the start of the next two.

Finally, the buffer offset specifies how far into the structure OpenGL must look before it finds the first values. You set it to 4 because you have to instruct OpenGL to skip the first 4 float it reads, as they are the vertex coordinates. Also note that this last pointer is casted to a GLvoid*.

Edit: If you want to point only to the texture coordinates of only the second quad, then use:

glTexCoordPointer(2, GL_FLOAT, sizeof(float)*6, (GLvoid*)(sizeof(float)*28));

The call you're looking for is

glTexCoordPointer(2, GL_FLOAT, sizeof(float)*6, (GLvoid*)(sizeof(float)*4));

The first argument is the number of elements that need to be read per element (vertex), and it's two because texture coordinates are just u and v coordinates. The second argument describes the type of data being passed. In this case, they're floats.

The third argument is the stride, which is the byte offset between consecutive texture coordinates. In this case, it's simply the size of one of your vertex-texcoord pairs (if I'm understanding the way you packed the data correctly). In other words, there are 6 floats between the start of two texture coordinates and the start of the next two.

Finally, the buffer offset specifies how far into the structure OpenGL must look before it finds the first values. You set it to 4 because you have to instruct OpenGL to skip the first 4 float it reads, as they are the vertex coordinates. Also note that this last pointer is casted to a GLvoid*.

The call you're looking for is

glTexCoordPointer(2, GL_FLOAT, sizeof(float)*6, (GLvoid*)(sizeof(float)*4));

The first argument is the number of elements that need to be read per element (vertex), and it's two because texture coordinates are just u and v coordinates. The second argument describes the type of data being passed. In this case, they're floats.

The third argument is the stride, which is the byte offset between consecutive texture coordinates. In this case, it's simply the size of one of your vertex-texcoord pairs (if I'm understanding the way you packed the data correctly). In other words, there are 6 floats between the start of two texture coordinates and the start of the next two.

Finally, the buffer offset specifies how far into the structure OpenGL must look before it finds the first values. You set it to 4 because you have to instruct OpenGL to skip the first 4 float it reads, as they are the vertex coordinates. Also note that this last pointer is casted to a GLvoid*.

Edit: If you want to point only to the texture coordinates of only the second quad, then use:

glTexCoordPointer(2, GL_FLOAT, sizeof(float)*6, (GLvoid*)(sizeof(float)*28));
Source Link
kevintodisco
  • 3.8k
  • 1
  • 13
  • 26

The call you're looking for is

glTexCoordPointer(2, GL_FLOAT, sizeof(float)*6, (GLvoid*)(sizeof(float)*4));

The first argument is the number of elements that need to be read per element (vertex), and it's two because texture coordinates are just u and v coordinates. The second argument describes the type of data being passed. In this case, they're floats.

The third argument is the stride, which is the byte offset between consecutive texture coordinates. In this case, it's simply the size of one of your vertex-texcoord pairs (if I'm understanding the way you packed the data correctly). In other words, there are 6 floats between the start of two texture coordinates and the start of the next two.

Finally, the buffer offset specifies how far into the structure OpenGL must look before it finds the first values. You set it to 4 because you have to instruct OpenGL to skip the first 4 float it reads, as they are the vertex coordinates. Also note that this last pointer is casted to a GLvoid*.