Vertex Array question (OpenGL)

Discussion in 'Mac Programming' started by Cromulent, Apr 13, 2008.

  1. macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #1
    I'm having a bit of a problem understanding this. Consider this code:

    Code:
    static GLint vertices[] = {25, 25,
                              100, 325,
                              175, 25,
                              175, 325,
                              250, 25,
                              325, 325};
    static GLfloat colors[] = {1.0, 0.2, 0.2,
                              0.2, 0.2, 1.0,
                              0.8, 1.0, 0.2,
                              0.75, 0.75, 0.75,
                              0.35, 0.35, 0.35,
                              0.5, 0.5, 0.5};
    
    glEnableClientState (GL_COLOR_ARRAY);
    glEnableClientState (GL_VERTEX_ARRAY);
    
    glColorPointer (3, GL_FLOAT, 0, colors);
    glVertexPointer (2, GL_INT, 0, vertices);
    what is the layout of the vertices array? Is it
    {x, y (bottom left)
    x, y (bottom right)
    x, y (top left)
    x, y (top right)}

    or is it some other layout? Basically what do the individual x, y co-ordinates refer too?
     
  2. macrumors 6502a

    Joined:
    Sep 3, 2005
    Location:
    Cramlington, UK
    #2
    Hi

    Not sure what you're asking for exactly, but x/y refer to model coordinates so those verticies are relative to the origin of the model. Normally your model would be defined using a right hand coordinate system. The order of the verticies in the array may or may not have any significance depending on how you draw your model. It looks to me though that your array is defining a triangle strip.

    b e n
     
  3. macrumors 65816

    Joined:
    Apr 19, 2004
    #3
    Not sure what you mean. Unless you specify them as Quads then the polygons are generally triangles. The order is what ever order you put them in, but I believe the face is determined in counter-clockwise order.
     
  4. thread starter macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #4
    Ah excellent thanks for your help. Sorry I should have been clearer when I posted my question.
     

Share This Page