const int edges[numEdges][2] = {{0,1},{1,3},{3,2},{2,0},{2,4},{3,4}};

I understand the declaration, in that the first dec are point arrays, and the 2nd is line construction between two points. but what I don’t get how glVertex2fv works and its args, what does vertices[edges[i][0]] equate to!

Let’s take glVertex2fv(vertices[edges[i][0]]);
as an example.

glVertex<u>2</u>fv means that you will be passing two values as arguments to the function
glVertex2<u>f</u>v means that the values you are passing to the function are of type float.
glVertex2f<u>v</u> means that you will be passing the values for the function as a pointer to an array ( in this case an array of 2 floats)

vertices[edges[i][0]] is a pointer to the 2-dimensional vertex at position edges[i][0].

Okay, right I see how multidimensionals work now. I think I’ve almost got you, but aren’t we only passing the method 1 arg,

glVertex2fv(vertices[edges[i][0]]);
i.e : this points to the first subelement in element 0 on the first iteration, which is : 0

then we run the 2nd method in the loop which is the second subelement in element 0, which is : 1

So each iteration of the loop outputs one line, this doesn’t quite add up to me as it seems the method should accept 2 args, as it would make more sense. But I can’t see it…

Why doesn’t it add up? you need 4 variables to draw a line. X and Y position of startpoint and X and Y position of endpoint. So you need to call glVertex2f twice, once for each point.

Pointers are not that hard to understand.
glVertex2fv(vertices[edges[i][0]]);
is equivalent to
glVertex2f(vertices[edges[i][0]][0],vertices[edges[i][0]][1]);

The only difference is that in the first case you provide a pointer to the first element because vertices[edges[i][0]] is equivalent to &vertices[edges[i][0]][0]

That’s because glVertex2fv takes it’s two expected arguments as a vector (array) of two floats. So if you pass a pointer p to such a function, it will in fact access p and p+1.

So the first call to glVertex2fv() references the vertex at index 0, and the second call references the vertex at index 1.
Because vertices is in fact a two-dimensional array, using vertices with a single index is of type float[2], which, in your example, comes down to {0.0,0.0} for index 0 and {100.0,0.0} for index 1 respectively.

It only needs to remember the amount of points that is necessary to draw the type of primitive that was passed to glBegin(). So points are drawn immediately. Lines are drawn for every pair and triangles need three points. As soon as it has enough data to draw the primitive type you suggested (or a part of it) the command queue will get processed. e.g. if you want to draw triangles but you only specify 5 points, then the last 2 points will have no affect.

Idd, that should’ve been “effect”. At least a forum-search for “affect” quickly reveals that I’m not the only one making this mistake by writing too fast