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 10 of 14

Thread: Spec. clarification: gl_VertexID, is the generation by glDrawElements optional?

Hybrid View

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2011
    Posts
    16

    Spec. clarification: gl_VertexID, is the generation by glDrawElements optional?

    The Specification defines:

    gl_VertexID is a vertex language input variable that holds an integer index for the vertex. The index is impliclty generated by glDrawArrays and other commands that do not reference the content of the GL_ELEMENT_ARRAY_BUFFER, or explicitly generated from the content of the GL_ELEMENT_ARRAY_BUFFER by commands such as glDrawElements.

    I would like to know, if the "or" part of the specification is optional. Since this is ignored by a server released few days ago. Also I would like to know if re-indexing with random ordering is allowed e.g:

    indexx < indexy => gl_VertexIDx > gl_VertexIDy == true

  2. #2
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,948
    The "or" there is not optional. glDrawArrays uses implicit indices, because they don't read them from an index array. glDrawElements uses explicit indices, taken from the index array. So if you use non-indexed rendering functions, the index is implicitly generated. If you use indexed rendering functions, then the index will be taken from the index array.

    Since this is ignored by a server released few days ago.
    What "server" are you referring to?

    indexx < indexy => gl_VertexIDx > gl_VertexIDy == true
    I'm not sure what this equation could possibly mean.

  3. #3
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,099
    Quote Originally Posted by Alfonse
    I'm not sure what this equation could possibly mean.
    I think the OP wants to know whether gl_VertexID of vertex x could still be larger than gl_VertexID of vertex y even though the index of x is smaller than the index of y after indices have been somehow rearranged. The answer would be: no, this implication does not hold. (EDIT: And I'm not sure if this implication is even correct logically speaking.)

  4. #4
    Junior Member Newbie
    Join Date
    Dec 2011
    Posts
    16
    So my understanding is correct:

    It is not allowed to use the index from the vertex-array if an index-array is assigned.

    Thanks.

    The second part of my question is unclear but already answered. (=> := implication)

    I was wandering if only an offset is allowed.

    For example:
    (x, x+1, x+2 ...) could be mapped to (x+10, x+20, x+21..)

    or a random re-ordering is allowed:

    (x, x+1, x+2 ...) could be mapped to (x+10, x-15, x+20..)

  5. #5
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,099
    Quote Originally Posted by yousry
    It is not allowed to use the index from the vertex-array if an index-array is assigned.
    That statement doesn't make any sense. O_o You don't use indices from a vertex buffer - you use the vertex attributes stored in it's data store. And index arrays (or buffers or whatever you want to call it) aren't assigned, they are sourced during vertex submission with glDrawElements*() calls if a non-zero element array buffer is bound and reference one unique set of attributes per index. The value of gl_VertexID may be very different for the same set of vertex data depending on whether you source it with indices(DrawElements*) or directly (DrawArrays*). That's it.

    I was wandering if only an offset is allowed.

    For example:
    (x, x+1, x+2 ...) could be mapped to (x+10, x+20, x+21..)

    or a random re-ordering is allowed:

    (x, x+1, x+2 ...) could be mapped to (x+10, x-15, x+20..)
    You can't do that with a draw call. The only offset you can add to indices is the so called base vertex which is constant, however.

  6. #6
    Junior Member Newbie
    Join Date
    Dec 2011
    Posts
    16
    Please help me to understand:

    If I have a vbo: (p0, p1, p2, p3)

    And an IBO with indices
    (
    0, 2, 1, // triangle one
    2, 3, 0 // triangle two
    )


    OpenGL Server A creates:

    gl_VertexID == 0 for p0
    gl_VertexID == 1 for p1
    gl_VertexID == 2 for p2
    gl_VertexID == 3 for p3

    and OpenGL Server B creates:

    gl_VertexID == 0, 5 for p0
    gl_VertexID == 2 for p1
    gl_VertexID == 1,3 for p2
    gl_VertexID == 4 for p3

    Which one is correct?

Posting Permissions

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