Right now, I'm having no problems adding polygons like triangles or squares, but the problem comes when I try to add something more complex.
This is what I use for a square:
GLfloat squareVertices[] = {
50, 50,
150, 50,
50, 150,
150, 150
};
GLfloat squareTexture[] = {
0, 0,
1, 0,
0, 1,
1, 1
};
glColor4f( 1, 0, 0, 1 );
glEnableVertexAttribArray(GLKVertexAttribPosition);
glEnableVertexAttribArray(GLKVertexAttribTexCoord0);
glEnable(GL_BLEND);
glBlendFunc( GL_ONE, GL_ONE_MINUS_SRC_ALPHA );
glVertexAttribPointer(GLKVertexAttribPosition, 2, GL_FLOAT, GL_FALSE, 0, squareVertices);
glVertexAttribPointer(GLKVertexAttribTexCoord0, 2, GL_FLOAT, GL_FALSE, 0, squareTexture
That works perfectly, but what about an arbitrary number of points?
Let say that I have, for example, an L shape, with these points:
0,0 10,0
10,80 100,80
0,100 10,100 100,100
This is an L (try to see lines joining the coordinates)
My question is, given these 7 points (or 8, or 100), how can I draw the figure?