Results 1 to 5 of 5

Thread: glIndexPointer & glDrawArrays

  1. #1
    Junior Member Newbie damma's Avatar
    Join Date
    Apr 2008
    Posts
    18

    glIndexPointer & glDrawArrays

    Instead of using vertex arrays, I'm using vertex buffers to specify the data for glDrawArrays.

    I am using 3 buffers of the same size. I am updating the buffers from a framebuffer object by glReadPixels. The framebuffer object has 3 textures attached of size width*height in RGBA format and type GL_FLOAT.

    According to the following code, the index_buffer should dictate in what sequence the points from the vertex_buffer are drawn. But instead the problem is that the points are drawn in a sequential manner from the vertex buffer.


    glEnableClientState(GL_COLOR_ARRAY);
    glBindBufferARB(GL_ARRAY_BUFFER, color_buffer);
    glColorPointer(4, GL_FLOAT, 0, 0);

    glEnableClientState(GL_INDEX_ARRAY);
    glBindBufferARB(GL_ARRAY_BUFFER, index_buffer);
    glIndexPointer(GL_FLOAT, 4, 0);

    glBindBufferARB(GL_ARRAY_BUFFER, vertex_buffer);
    glVertexPointer(4, GL_FLOAT, 0, 0);
    glEnableClientState(GL_VERTEX_ARRAY);

    glDrawArrays(GL_POINTS, 0, width*height);

  2. #2
    Senior Member Frequent Contributor
    Join Date
    Apr 2004
    Posts
    990

    Re: glIndexPointer & glDrawArrays

    You may want to try out glDrawElements instead of glDrawArrays

  3. #3
    Senior Member OpenGL Pro Zengar's Avatar
    Join Date
    Sep 2001
    Location
    Germany
    Posts
    1,931

    Re: glIndexPointer & glDrawArrays

    Index array is something completely different (it is about color index).

    What you are looking for is glDrawRangedElements in combination with a GL_ELEMENT_ARRAY_BUFFER

  4. #4
    Junior Member Newbie damma's Avatar
    Join Date
    Apr 2008
    Posts
    18

    Re: glIndexPointer & glDrawArrays

    thanks for the quick reply.
    I had one more query. Since I have my index buffer of float values, it will not work with glDrawRangedElements as it does not take float for indices ?
    and is there a way to specify the stride for the indices (i.e. read the index after "stride" number of bytes/elements) ?

  5. #5
    Senior Member OpenGL Pro Zengar's Avatar
    Join Date
    Sep 2001
    Location
    Germany
    Posts
    1,931

    Re: glIndexPointer & glDrawArrays

    No, you will have to use tightly packed integers.

Similar Threads

  1. glDrawArrays not using VBO
    By Fastjack in forum OpenGL: Advanced Coding
    Replies: 6
    Last Post: 06-29-2008, 09:21 AM
  2. glDrawArrays
    By Hylke Donker in forum OpenGL: Basic Coding
    Replies: 11
    Last Post: 08-10-2006, 04:23 AM
  3. Looking for help with glDrawArrays
    By Scott Casey in forum OpenGL: Advanced Coding
    Replies: 5
    Last Post: 04-01-2005, 03:20 PM
  4. glDrawArrays
    By guju in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 05-16-2002, 10:17 AM
  5. using glDrawArrays
    By NOAH IV in forum OpenGL: Basic Coding
    Replies: 7
    Last Post: 02-05-2001, 05:56 PM

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