I'm using the glDrawElements call with VBOs to render my scene. The scene is a cloth with vertices and texture coordinates - in this example, I'm rendering a flag.
With my scene, the vertices are dynamic which means I need to write to a VBO every frame. Much of my processing is done on the GPU using CUDA, so I'm constantly mapping CPU memory to GPU memory. The texture coordinates, on the other hand, are static. In order to render with glDrawElements (as I understand it), I should interleave the texture coordinates in the vertices VBO and then simply call glTexCoordPointer() and glEnableClientState(). This is not optimal because then I'd need to draw all the texture coordinates with me when I do CPU<-->GPU memory mapping.
Is there a way to arrange my vbo such that I can update the vertex data in the vbo without touching the texture data in the vbo? Below is my code for rendering - I have three arrays currently filled: an index array, a vertex array, and a texture array.
In the code below, the indexVbo has been mapped to the index array and vbo has been mapped to the vertex array. I now need to incorporate textures. Any insight or suggestions would be much appreciated.
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, flagTexId);
glPushMatrix();
glColor3f(1.0, 1.0, 1.0);
glVertexPointer(4, GL_FLOAT, 0, 0);
glTexCoordPointer(2, GL_FLOAT, 0, 0);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexVbo);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
// Render flag mesh
glDrawElements(GL_TRIANGLES, numTriangles * 3, GL_UNSIGNED_INT, 0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glPopMatrix();
glDisable(GL_TEXTURE_2D);