#define RECURSIVE_LEVELS 3
typedef GLFloat point2[2];
point2 triangle[] = {{0,0},{0.5,1},{1,0}}
void drawTriangle(point2 a, point2 b, point2 c){
glBegin(GL_TRIANGLES);
glVertex2fv(a);
glVertex2fv(b);
glVertex2fv(c);
glEnd();
}
void divideTriangle(point2 a, point2 b, point2 c, int level){
point2 m0,m1,m2;
int j;
if(level > 0){
for( j = 0; j < 2; j++){
m0[j] = (a[j] + b[j]) / 2
m1[j] = //same for a and c
m2[j] = //same for b and c
}
divideTriangle(a,m0,m1,level-1);
divideTriangle(c,m1,m2,level-1);
divideTriangle(b,m2,m0,level-1);
} else {
drawTriangle(a,b,c);
}
}
typedef GLFloat point3[3]
point3 tetra[] = {{0.0, 0.0, 0.0},{0.5,1.0,0.0},{,,,0.0},{,,,1.0}}//final point has a z of 1