different settings for vertex array

I have brush tool. It draws vertices from vertex array. And I need to set multiple setting for them. Like for example texture1 for first 10 vertices, texture2 for next 15 vertices and texture3 for all other vertices. Is there any possibility to do that? If yes, then how? If no, how can I do such a thing? Thanks in advance.

There are multiple ways to do that:

  1. Break the batches, i.e. draw the first 10 vertices using a separate draw call than then next 15 vertices and bind a different texture in between draw calls using glBindTexture. This is compatible with all OpenGL implementations out there, but it’s far from efficient.

  2. Use texture arrays. That means you create a texture array and upload the individual 2D textures as layers of the texture array (as long as they are the same size). Also, you have to extend your texture coordinate set with a third coordinate that will indicate which layer you want to fetch from, so this Z texture coordinate will be 0 for the first 10 vertices, 1 for the next 15 vertices and so on. This approach requires OpenGL 3.x class hardware (i.e. GeForce 8000+, Radeon HD2000+) but it is far more efficient than the previous one.

There are probably other ways too, but I think these should be the ones that you should consider.

Thank you very much for help. 2nd way looks very nice. I’ll try to implement it. :slight_smile: