PDA

View Full Version : Vertex Array question (OpenGL)




Cromulent
Apr 13, 2008, 04:40 AM
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?



lazydog
Apr 13, 2008, 06:37 AM
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

psingh01
Apr 13, 2008, 10:15 AM
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.

Cromulent
Apr 13, 2008, 10:45 AM
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

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.

Ah excellent thanks for your help. Sorry I should have been clearer when I posted my question.