int d_mmount = 3;
int d_size = 64;
struct sVerts
{
float x;
float y;
float z;
};
sVerts Vert1,Vert2,Vert3;
sVerts newVert1, newVert2, newVert3, newVert4, newVert5, newVert6;
void DrawTri( int level, sVerts tmpVerts1, sVerts tmpVerts2, sVerts tmpVerts3 )
{
glBegin( GL_TRIANGLES );
glColor3f( 1.0f, 0.0f, 0.0f );
glVertex3f( tmpVerts1.x, tmpVerts1.y, tmpVerts1.z );
glVertex3f( tmpVerts2.x, tmpVerts2.y, tmpVerts2.z );
glVertex3f( tmpVerts3.x, tmpVerts3.y, tmpVerts3.z );
glEnd();
float midpoint = (tmpVerts2.x+tmpVerts3.x)/2;
float midpoint2 = (tmpVerts2.y+tmpVerts3.y)/2;
newVert1.x = midpoint; newVert1.y = midpoint2; newVert1.z = 0.0f;
newVert2.x = tmpVerts1.x; newVert2.y = tmpVerts1.y; newVert2.z = 0.0f;
newVert3.x = tmpVerts2.x; newVert3.y = tmpVerts2.y; newVert3.z = 0.0f;
newVert4.x = midpoint; newVert4.y = midpoint2; newVert4.z = 0.0f;
newVert5.x = tmpVerts3.x; newVert5.y = tmpVerts3.y; newVert5.z = 0.0f;
newVert6.x = tmpVerts1.x; newVert6.y = tmpVerts1.y; newVert6.z = 0.0f;
if( level < d_mmount )
{
DrawTri( level + 1, newVert4, newVert5, newVert6 );
DrawTri( level + 1, newVert1, newVert2, newVert3 );
return;
}
}
The Problem is, it is only splitting on one side, i think i understand why, its keeps looping threw the first of the two calls to DrawTri(), and the loop ends before it ever gets to the secound call.
My question is how can i call both functions at once? Should i just store to seperate counters? My biggest confusion about this is that in the articles i am reading, all use this method with no problem.
Any help or suggestions would be appreciated