Vertex Array question (OpenGL)

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

  1. Cromulent macrumors 603


    Oct 2, 2006
    The Land of Hope and Glory
    I'm having a bit of a problem understanding this. Consider this 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. lazydog macrumors 6502a

    Sep 3, 2005
    Cramlington, UK

    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. psingh01 macrumors 65816

    Apr 19, 2004
    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. Cromulent thread starter macrumors 603


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

Share This Page