Greetings again all,
I’m trying to use a vertex array to render a texture-mapped cube. It has the 8 points in it and I use glDrawElements as follows:
GLubyte front[] = {4, 5, 6, 7};
GLubyte back[] = {0, 3, 2, 1};
GLubyte left[] = {0, 4, 7, 3};
GLubyte right[] = {1, 2, 6, 5};
GLubyte top[] = {2, 3, 7, 6};
GLubyte bottom[] = {0, 1, 5, 4};
glDrawElements(GL_QUADS, 4, GL_UNSIGNED_BYTE, front);
glDrawElements(GL_QUADS, 4, GL_UNSIGNED_BYTE, back);
glDrawElements(GL_QUADS, 4, GL_UNSIGNED_BYTE, left);
glDrawElements(GL_QUADS, 4, GL_UNSIGNED_BYTE, right);
glDrawElements(GL_QUADS, 4, GL_UNSIGNED_BYTE, top);
glDrawElements(GL_QUADS, 4, GL_UNSIGNED_BYTE, bottom);
The problem is, I can’t just give it 8 texture coordinates that correspond to the 8 vertices because the texture coordinates varies with the side that’s being drawn.
The only thing I can think of to solve this problem would be to use the stride feature and define 3 texture coordinates per vertex, then before drawing a side set glTextureCoordPointer to the proper “offset”. That would take a bit of work I’d think.
Is there an easier/better solution?
Thanks
Joe