Advertisement

Vertex Array and Texture coordinates

Started by October 20, 2004 02:02 PM
0 comments, last by Brother Bob 20 years, 1 month ago
Hi, I would like some info about glTexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); and vertex arrays. I assume that size is the number of texture coordinate in *pointer, that type is the type of *pointer (GL_FLOAT for exemple), that stride is 2 (since I only have a UV map) and that pointer is the array holding the texture coordinates. Please correct if I'm wrong. Now I would like to know how a vertex retrieve it's texture coordinate. Is it just "the i-th vertex gets the i-th texture coordinate" or can I specify something else, like "for the i-th face, the textures coordinates of each vertex are the i-th, i+1-th, and i+2-th of the array" ? What I'm doing: I'm coding an ASE loader, and the ASE file gives me for each face a pointer to a table of UV coordinates. This means that a vertex can have different UV coordinates depending of which face is drawn. Thus, I'm wondering how do I have to handle it in order to put it into an array and do a glDrawElements(...). Thanks for any help, Roming22
Quote: Original post by Roming22
I would like some info about glTexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); and vertex arrays.

I assume that size is the number of texture coordinate in *pointer, that type is the type of *pointer (GL_FLOAT for exemple), that stride is 2 (since I only have a UV map) and that pointer is the array holding the texture coordinates. Please correct if I'm wrong.

size is the number of components per texture coordinate. 2 is probably what you want. type is the type of data pointed to by pointer. stride is the number of bytes between the start of two consecutive entries, 2*sizeof(GLfloat) for a tightly packed array (zero also works, it's a special case for tightly packed arrays).

Quote:
Now I would like to know how a vertex retrieve it's texture coordinate. Is it just "the i-th vertex gets the i-th texture coordinate" or can I specify something else, like "for the i-th face, the textures coordinates of each vertex are the i-th, i+1-th, and i+2-th of the array" ?

i:th vertex gets the i:th texture coordinate. The same index is used for all enabled arrays.

Quote:
What I'm doing: I'm coding an ASE loader, and the ASE file gives me for each face a pointer to a table of UV coordinates. This means that a vertex can have different UV coordinates depending of which face is drawn. Thus, I'm wondering how do I have to handle it in order to put it into an array and do a glDrawElements(...).

ASE files are not directly loadable to vertex arrays. Just like you say, the same vertex can get different texture coordinates. So you have to post-process the loaded data, and duplicate vertices sharing position, but not other attributes, and build a new set of vertices/texture coordinates arrays.

This topic is closed to new replies.

Advertisement