Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: indexed drawing

  1. #1
    Intern Contributor
    Join Date
    Jun 2013

    indexed drawing

    hi all. im reading the new opengl programming guide and there is something that is uffer bound the bunclear to me about indexing. on page 122 the list of vertices and colors bound to GL_ARRAY_BUFFER are not seperated into seperate vertices by a set of curly braces, ie:
    the way it is in the book:
    float vertices[]{
    0.5, 0, 1.5, 1,
    0.5, 1, 1.2, 1,
    -0.5, 1, 1.3, 1

    the way i thought it was until i found the example:
    float vertices[][]{
    {0.5, 0, 1.5, 1},
    {0.5, 1, 1.2, 1},
    {-0.5, 1, 1.3, 1}

    so how does it read the vertexes when they aren't seperated and do you have to specify the size (number of elements in vertex) of the vertex to the program at some point and if so how do you do that?
    thanks alot

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Jan 2007
    This is specified by your glVertexAttribPointer call; the relevant parameters are:

    size: in this case it looks like 4 components (x, y, z and w) per vertex.
    type: GL_FLOAT here.
    stride: the number of bytes from the start of one vertex to the start of the next, or 0 if the data is tightly packed. Here you could give either 0 or (4 * sizeof (float)).

    You're better off reading on in the book, as all of this will be covered - it's pretty fundamental knowledge.

  3. #3
    Intern Contributor
    Join Date
    Jun 2013
    kk, i understand now. thanks lots

Posting Permissions

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