Results 1 to 4 of 4

Thread: tex coords and gldrawelements

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2004
    Location
    Denver, CO
    Posts
    24

    tex coords and gldrawelements

    glDrawElements uses the index also to look up the texture coordinates. This is a bit of a pain, since a particular vertex can have different texture coordinates depending on the polygon.
    How would you go about solving this?

    If you duplicate the vertex, you are starting to eliminate the advantage of using the arrays in the first place.
    Duplicating the texture coordinate array (and for example switching the coord pointer between calls with drawarrays) seems like an awful lot of memory waste.

    I'm cracking my head trying to find a proper way to solve this, but i guess a lot depends on the models you are using.
    Still, anyone has any good ideas?

  2. #2
    Senior Member Frequent Contributor
    Join Date
    Aug 2001
    Location
    Italy
    Posts
    625

    Re: tex coords and gldrawelements

    What you said is true but however the models to be used are decisive.
    DrawElements assumes you have a "dense" mesh, one which re-uses many vertices. In real world scenarios, there's no need to do what you want.

    Another point is that you have vertices and then you have the attributes.
    You mean, since the two vertices have the same xyz coordinates, I want to share, say, texcoords.
    Providing this functionality would be difficult and using it would be quite cumbersome. For the time being, you shall duplicate the data.

    The fact two vertices does have the same position does not mean they are the same vertex (well, in real world they are, but not here!), consider for example the vertices of a cube. Every face has a different normal so to render correctly they need multiple vertices with the same xyz position.

    Mind that: in real world scenarios, the memory waste you refer to is a non-issue.
    Sharing vertex data in the way you mean would require some special machinery and heavier difficulties... you would need to have indices for vertex to use, indices for texcoords, indices for normals... what a mess!

  3. #3
    Junior Member Newbie
    Join Date
    Feb 2004
    Location
    Denver, CO
    Posts
    24

    Re: tex coords and gldrawelements

    Thanks for your input. I guess i will be duplicating the vertices.

    However, what you say about having indices for everything... I can see several ways to circumvent that, but i agree it is not the prettiest solution.

  4. #4
    Senior Member Frequent Contributor
    Join Date
    Aug 2001
    Location
    Italy
    Posts
    625

    Re: tex coords and gldrawelements

    Now I am the one who does not understand.
    What I meant to say is that you could (theorically) solve the problem by telling the hardware that "vertex 501 uses position i15, texcoords i123 and color i300", using three indices.
    What are your ideas on solving the problem? This is somewhat curious to me.

Similar Threads

  1. unable to translate from screen coords to world coords
    By etiennecouturie in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 04-28-2014, 06:04 AM
  2. Convert Eye Coords to Window Coords in GLSL?
    By Megusta in forum OpenGL: GLSL
    Replies: 4
    Last Post: 03-30-2011, 04:01 PM
  3. Depth problem with translating screen coords to world coords
    By Bryan_dup1 in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 04-13-2006, 05:02 AM
  4. Text & object coords vs. world coords
    By GW in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 05-20-2004, 06:14 AM
  5. View coords to world coords problem
    By NoAntz in forum OpenGL: Advanced Coding
    Replies: 0
    Last Post: 02-19-2002, 03:33 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean