Vertex Array problem...

Here is what I’m doing:

| | |
| A | B |
| | |
| | |

I’m drawing a wall composed of two textures,
one goes to A, the other goes to B. My Vertex Array is: [1,4,2,5,2,5,3,6], and my Texture Array is [1,4,2,5,2,5,3,6].
My index1: [0,1,2,3]
My index2: [4,5,6,7]

I draw like this:

Here’s my question: in the vertex and texture arrays I have data copied,repeted, taking up space, is there any way I can avoid this?

No, don’t worry about it. The only way to avoid the duplication is to add more levels of indirection, which would hurt, not help, performance.

In any case, since you’re binding a new texture for each DrawElements, the cost of switching textures and rendering the geometry is probably going to overwhelm that of copying the geometry.

  • Matt

Actually in your particular case you don’t need to repeat the data in the vertex arrays, and you don’t need indirect references.

Just use glDrawArrays, instead of glDrawElements.

Your Vertex array will be [1,4,2,5,3,6]

Bind Texture 1
// draw the first 4 elements
Bind Texture 2
//draw the last 4 elements