Hello once more all,
To the point, I have three sets of data I want to merge and upload to a buffer, those sets being Vertex, Normal, and Texcoord.
Do you know of an efficient, or more viable way to combine those three sets into one, than what I am presenting below?
Is this a correct technique, or am I not comprehending the index structure well enough?
I plan on formating my three sets of data to correspond with my index pattern, being the standard (VNTVNTVNTVNT) or (Vertex,Normal,Texcoord).
OpenGL Context, 4.0+.
Code :int* Indices = Mesh->Index; int size = Mesh->Index_count; float* Interleaved = new float[size]; for(int i=0; i<size;) { Interleaved[i] = Mesh->VERTEX.mData [Indices[i]]; i++; Interleaved[i] = Mesh->NORMAL.mData [Indices[i]]; i++; Interleaved[i] = Mesh->TEXCOORD.mData[Indices[i]]; i++; } // I believe both the interleaved and index buffers to have the same element count. GLuint Buffer_Interleaved,Buffer_Index; glGenBuffers(1,&Buffer_Interleaved); glGenBuffers(1,&Buffer_Index); glBindBuffer(GL_ARRAY_BUFFER,Buffer_Interleaved); glBufferData(GL_ARRAY_BUFFER,size*sizeof(float),Interleaved,GL_STATIC_DRAW); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,Buffer_Index); glBufferData(GL_ELEMENT_ARRAY_BUFFER,size*sizeof(int),Indices,GL_STATIC_DRAW); delete [] Interleaved;
Additionally, I would like to know how to use glDrawElements() with my newly formatted data.
Books and web references are lacking a good amount of clarity to me.
Any relative words of wisdom are words enough to suffice thanks.



