Results 1 to 4 of 4

Thread: About glDrawElements and glVertexPointer

  1. #1
    Member Contributor
    Join Date
    Jan 2001
    Posts
    60

    About glDrawElements and glVertexPointer

    When we call glVertexPointer, will the vertex data be transferred to the card immediatly or wait for some other instruction like glDrawElements?

    Lets say we have a vertex array with 500 vertices. And two calls to glDrawElements using different subsets of vertices, lets say 300 and 250.

    glVertexPointer(...,...,...,...);
    glDrawElements(...,...,...,indices1);
    glDrawElements(...,...,...,indices2);

    How would this work?

    a) 500 vertices will be transferred and the two meshes redered using a subset of this vertices?

    b) 300 vertices will be transferred for the fist call of glDrawElements plus 250 for the second call?

    c) the same 500 vertices will be transferred two times?

    I think (b) is probably the way it works but I'm not confident. And depending on how it works my data structure may change a lot.

    Thanks!

  2. #2
    Senior Member Frequent Contributor
    Join Date
    Sep 2000
    Location
    SWEDEN
    Posts
    601

    Re: About glDrawElements and glVertexPointer

    The driver doesn't know how many vertices you are referencing in your drawelements call so it probably scans through the index array on the cpu and only copies the referenced range of indices.

    If you use DrawRangeElements you provide the range implicitly and you should get better performance. For best performance use the ARB_vertex_buffer_object extension, or display lists.

  3. #3
    Member Contributor
    Join Date
    Jan 2001
    Posts
    60

    Re: About glDrawElements and glVertexPointer

    So, glDrawElements will transfer all vertices specified in glVertexPointer? Even when "indices1" and "indices2" only point to a subset of vertices?

    Is it worth to split the mesh in some smaller meshs??

  4. #4
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,450

    Re: About glDrawElements and glVertexPointer

    No, if you have 500 vertices in your array, but reference only 250 in the indices, only those 250 are transformed.
    The glVertexPointer alone doesn't tell OpenGL how many vertices are behind the pointer.

Similar Threads

  1. GlVertexPointer
    By Crownable in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 07-22-2012, 08:03 AM
  2. glVertexPointer
    By trackin in forum OpenGL: Basic Coding
    Replies: 8
    Last Post: 05-30-2012, 06:36 AM
  3. VBO->glVertexPointer()
    By dletozeun in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 06-14-2006, 05:20 AM
  4. How do I use glVertexPointer?
    By Melker in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 01-08-2003, 02:01 AM
  5. glVertexPointer and stl...
    By imported_robert in forum OpenGL: Advanced Coding
    Replies: 16
    Last Post: 07-19-2002, 07:24 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