X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;ds=sidebyside;f=scene.c;h=caa7f1951dc1678be5d95b5600c15202b6347fa5;hb=6f5b17c9cccc5ffa90dbccab465b1010504f8d75;hp=a2da934e0d3d4cbe62c573d727b44ea522f3e8d1;hpb=9f1ff4bb4917d0dedec9d57c50d066a99d890241;p=atyndall%2Fcits2231.git diff --git a/scene.c b/scene.c index a2da934..caa7f19 100644 --- a/scene.c +++ b/scene.c @@ -558,7 +558,7 @@ void idle() { angle = (int)(angle + 10) % 360; //angle2 = (int)(angle2 + 10) % 360; printf("Angle 1: %f, Angle 2: %f\n", angle, angle2); - sleep(2); + sleep(25); glutPostRedisplay(); } @@ -599,15 +599,21 @@ int drawFloorRecurse = 10; void drawSquare(int recurseLevel, GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2) { - if ( drawFloorRecurse != recurseLevel ) { - GLfloat xm = (x2 - x1) / 2; - if ( x1 > x2 ) { - xm = (x1 - x2) / 2; - } + printf("Recurse level %d\n", recurseLevel); - drawSquare(recurseLevel + 1, x1, y1, xm, y2); - drawSquare(recurseLevel + 1, xm, y1, x2, y2); + if ( drawFloorRecurse != recurseLevel ) { + GLfloat xm = (x1 + x2) / 2.0; + GLfloat ym = (y1 + y2) / 2.0; + int rnew = recurseLevel + 1; + + // Split into four sub-quads + drawSquare(rnew, x1, y1, xm, ym); + drawSquare(rnew, x1, ym, xm, y2); + drawSquare(rnew, xm, ym, x2, y2); + drawSquare(rnew, xm, y1, x2, ym); + } else { + printf("Drawing (%f, %f) -> (%f, %f)\n", x1, y2, x2, y2); glBegin(GL_QUADS); glVertex3f(x1, 0.0, y1); glVertex3f(x1, 0.0, y2);