   Vertex Ararys glTexCoordPointer
  Hi guys,i am displaying my models by using VertexArrays (sooner or later switching to VBO).It gives a really high boost but there is a small issue with texture coords.;glClientActiveTextureARB(GL_TEXTURE1_ARB);glEnableClientState(GL_TEXTURE_COORD_ARRAY);glBindTexture(GL_TEXTURE_2D, m_Textures[0]);glTexCoordPointer(2, GL_FLOAT, sizeof(CVector2), pObject->pTexVerts);glEnableClientState(GL_VERTEX_ARRAY);glVertexPointer( 3, GL_FLOAT,sizeof(CVector3),pObject->pVerts);glDrawArrays( GL_TRIANGLES, 0,pObject->numOfVerts);glDisableClientState(GL_VERTEX_ARRAY);glClientActiveTexture(GL_TEXTURE1_ARB);glDisableClientState(GL_TEXTURE_COORD_ARRAY);Verts are rendered correctly,also the correct texture is bound by the coordinates seem not to be applied correctly.Does someone know by any chance what might be the cause here?   
  Just checking, are you sure you want GL_TEXTURE1 and not GL_TEXTURE0? Are you using multitexturing?   ;  Did you maybe mean GL_TEXTURE0_ARB, rather than GL_TEXTURE1_ARB?   ;  Sure guys i'm on multitexingi believe this has something to do with the vertex arrays,i have more tex coords than vertices, might be that the cause?Isn't the glDrawElements - what i should pick when drawing models like md5/obj...?   ;  Yeah you can't just use raw OBJ indices when you're using drawelements.You have to have the same number of vertices as texcoords. This involves doing a lot of post-processing once you load the obj to duplicate various elements as needed. Its a bit of a pain but its what you have to do to use buffers, theres no way to index different arrays with different indices.   ;  Hold on,so what you're saying to me is that i won't be able to - draw my object and texture it by using a vbo , texture_coord_array , and drawelements ?I have all the data i need, indices, faces, texcoords, vertices..Is numTexCoords!=numVerts a deal?Shouldn't i just double  vertex data and stick it in a structurewhich has the vertice, texture and normal informationin one structure. ?   ;  Let me repeat my explanation a little more clearly.Lets say you're drawing a quad with a different texture coord on each triangle. In this case you will have four vertices, and six texcoords. Your obj file would look like this (vertex/texcoord)f 0/0 1/1 2/2f 1/3 2/4 3/5The first face uses vertices 0,1,2 and texcoords 0,1,2, and the second face uses vertices 1,2,3 and texcoords 3,4,5.When you're using glDrawElements, the index for the vertex must be the same as the index for the texcoord. This means that there always must be the same number of texcoords and vertices in your array.In this situation you would double the vertices 1 and 2 so that you had six vertices and six texcoords in your array.Index 0 always points to vertex 0 and texcoord 0. Index 1 always points to vertex 1 and texcoord 1. Thats why you always have to have the same number of verts and texcoords. You'll have to do the same thing with normals, or any other kind of data you want per-vertex.   ;  Karwosts,so what would you say about this:taken from GT series:"// glDrawElements(GL_TRIANGLES, pObject->m_numberOfFaces * 3, GL_UNSIGNED_INT, pObject.m_pIndices);//// As you can see, you pass in the type (triangles, etc...), how many indices you want to// render (the number of faces of the object * 3 [assuming it's triangles]), then the// type that the indices are stored as (unsigned int) and finally, the array of indices).//// The only downside to this is that when you load an object from a 3D file format, usually// there is more texture coordinates and/or normals than there is vertices.  Since you can't// specify different arrays of indices for each data type (vertex, textureCoords, etc...) it// makes it a pay to render all that information using vertex arrays.  It will render the // vertices fine, but the textures will look funny.  To get around this you have about 2 options.// 1) The first is to go through and just double your vertex data and stick it in a structure// like CVertex (see below in the tutorial) which has the vertice, texture and normal information// in one structure.  This of course doubles your memory, but in the long run (if added memory // isn't a problem with your computer) it does render faster.  The second method is to create// the structure that holds that information, but set up your data so that you render using// triangle fans or triangle strips.  Many games do this, which is always the fastest result.";Quote:The second method is to create the structure that holds that information, but set up your data so that you render using triangle fans or triangle strips. Many games do this, which is always the fastest result.This doesn't make any sense to me at all. Using triangle strips vs. triangles has nothing to do with the vertex data specification. Your only option to use glDrawElements is to duplicate non-unique vertices.   ;  You should call glActiveTexture(GL_TEXTUREX) before calling glBindTexture.It should be something like thisglClientActiveTexture(GL_TEXTURE0);glEnableClientState(GL_TEXTURE_COORD_ARRAY);glTexCoordPointer(2, GL_FLOAT, sizeof(CVector2), pObject->pTexVerts[0]);glClientActiveTexture(GL_TEXTURE1);glEnableClientState(GL_TEXTURE_COORD_ARRAY);glTexCoordPointer(2, GL_FLOAT, sizeof(CVector2), pObject->pTexVerts[1]);glEnableClientState(GL_VERTEX_ARRAY);glVertexPointer( 3, GL_FLOAT,sizeof(CVector3),pObject->pVerts);glActiveTexture(GL_TEXTURE0);glBindTexture(GL_TEXTURE_2D, m_Textures[0]);//Do some glTexEnv calls for unit 0 to setup the combiners (I guess you aren't using shaders)glActiveTexture(GL_TEXTURE1);glBindTexture(GL_TEXTURE_2D, m_Textures[1]);//Do some glTexEnv calls for unit 1 to setup the combiners (I guess you aren't using shaders)glDrawArrays( GL_TRIANGLES, 0,pObject->numOfVerts);glDisableClientState(GL_VERTEX_ARRAY);glClientActiveTexture(GL_TEXTURE0);glDisableClientState(GL_TEXTURE_COORD_ARRAY);glClientActiveTexture(GL_TEXTURE1);glDisableClientState(GL_TEXTURE_COORD_ARRAY); [Edited by - V-man on May 29, 2010 11:43:36 AM]