# Question on vertex arrays

This topic is 3420 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I have read that it is better to send less, but larger vertex arrays than a bunch of small ones. What I don't understand is how to put objects into a vertex array "post transformation". So if I had an object defined by an array of points, then I translate, rotate, scale it - how do I add these transformed vertices to an array, for sending to glDrawArrays? Right now I am putting each object into an array, and then push/trans/drawArray/pop.

##### Share on other sites
Why do you want to do this? It's more efficient to use the GPU's built-in matrix transformations. Just put all your objects in one array, but do the modelview matrix operations as normal.

##### Share on other sites
>Why do you want to do this? It's more efficient to use the GPU's built-in matrix
>transformations. Just put all your objects in one array, but do the modelview
>matrix operations as normal.

That's what I don't understand. If the objects are all in a single array, how do I transform them individually? They all have different positions, scales and rotations.

Is this what you are suggesting?

1. build objects (with normalized coordinates), push each into large array
2. transform with glTranslate, etc
3. draw arrays for vertices in a single object
4. Go to 2 with next object

But then I am calling draw arrays bunches of times, which is what I wanted to avoid, no?

##### Share on other sites
If calling glDrawArrays too often is your bottleneck, then what you can do is put the XYZ for your translation in a texture coordinate.
In a vertex shader, you use that texture coordinate to translate your vertices

//GLSL vertex shaderuniform mat4 ProjectionMatrix;void main(){  vec3 myvertex;  myvertex = gl_Vertex.xyz + gl_MultiTexCoord0.xyz;  gl_Position = ProjectionMatrix * vec4(myvertex, 1.0);}