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 5 of 5

Thread: glVertexPointer Stride

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2000
    Location
    Mexico
    Posts
    22

    glVertexPointer Stride

    hi i have this structures

    typedef struct VERTEX {

    float xyz[3] ; // x,y,z of the vertex (modified)
    float nxyz[3] ; // x,y,z of the vertex (never modified)
    float tex[2] ; // 2D texture index
    int np ; // number of polygons associated with node
    int plist[30] ; // list of polygons associated with node
    float norm[3] ; // polygon vertex normal
    float anorm[3] ; /* average vertex normal */
    } VERTEX ;


    typedef struct POLYGON {

    VERTEX *vertex[3] ; // pointer to an array of three vertices

    } POLYGON ;

    and i make this

    POLYGON** polygon;

    and then i use it like this:

    polygon = _new_array(POLYGON *, 500);

    polygon[0] = p0;
    polygon[1] = p1;
    .
    .
    .
    polygon[n] = pn;

    but the numbers of polygons is huge, so i'd like to use the vertex array extension, but in the glVertexpointer i need to know the stride thing, how can i calculate the bytes?
    please help.
    thanks

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Jun 2000
    Location
    Shreveport, LA, USA
    Posts
    1,757

    Re: glVertexPointer Stride

    Stride is usually just sizeof(VERTEX)

  3. #3
    Junior Member Newbie
    Join Date
    Feb 2000
    Location
    Mexico
    Posts
    22

    Re: glVertexPointer Stride

    Yes. i'm sorry what was i thinking, i mean in the *pointer parameter, how do i put it?

    glVertexPointer(3, GL_FLOAT, sizeof(VERTEX), ?????);

    and in the display function

    gldrawArrays(GL_POLYGON,0,np); /* np = number of polys */

    thanks

  4. #4
    Junior Member Newbie
    Join Date
    Jun 2000
    Posts
    2

    Re: glVertexPointer Stride

    In order to use "glVertexPointer(...)", you'll need to clean-up some of your data structures. First, all your vertices must be in a single, contiguous array. Try this:

    struct POLYGON{
    VERTEX vertex[3];
    };
    POLYGON* polygon;
    polygon = new POLYGON[ number_of_polys ];

    Then you can call:
    "glVertexPointer(3, GL_FLOAT, sizeof(VERTEX), polygon[0].vertex[0].xyz );"

    If you try to use:
    typedef struct POLYGON{
    VERTEX* vertex[3];
    };
    Then each of your data elements (ie. VERTEX structures) will be allocated individually in heap memory instead of in a contiguous array.

  5. #5
    Junior Member Newbie
    Join Date
    Feb 2000
    Location
    Mexico
    Posts
    22

    Re: glVertexPointer Stride

    Hi again, what BritC says make sense but somehow it doesn't work, i'll have to make the vertex array without the VERTEX struct. please if you figure out something, please let me know thanks for your help.

Posting Permissions

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