Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Cromulent

macrumors 604
Original poster
Oct 2, 2006
6,812
1,100
The Land of Hope and Glory
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?
 

lazydog

macrumors 6502a
Sep 3, 2005
709
6
Cramlington, UK
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

macrumors 68000
Apr 19, 2004
1,586
629
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

macrumors 604
Original poster
Oct 2, 2006
6,812
1,100
The Land of Hope and Glory
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.