Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: different settings for vertex array

Hybrid View

  1. #1
    Intern Newbie
    Join Date
    Jul 2012
    Posts
    41

    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.

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Dec 2007
    Location
    Hungary
    Posts
    985
    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.
    Disclaimer: This is my personal profile. Whatever I write here is my personal opinion and none of my statements or speculations are anyhow related to my employer and as such should not be treated as accurate or valid and in no case should those be considered to represent the opinions of my employer.
    Technical Blog: http://www.rastergrid.com/blog/

  3. #3
    Intern Newbie
    Join Date
    Jul 2012
    Posts
    41
    Thank you very much for help. 2nd way looks very nice. I'll try to implement it.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •