From: Ash Tyndall Date: Tue, 18 Oct 2011 12:00:48 +0000 (+0800) Subject: (no commit message) X-Git-Url: https://git.ucc.asn.au/?p=atyndall%2Fcits2231.git;a=commitdiff_plain;h=a2f1c50d8985e2f043840ffea632fba446535a34 --- diff --git a/scene.c b/scene.c index 0481882..6993bd4 100644 --- a/scene.c +++ b/scene.c @@ -562,6 +562,37 @@ void idle() { glutPostRedisplay(); } + +int drawFloorRecurse = 2; + +void drawSquare(int recurseLevel, float x1, float y1, float x2, float y2) { + + printf("%d, %d, %d, %d\n", x1, y2, x2, y2); + + if ( drawFloorRecurse != recurseLevel ) { + float xm = (x1 + x2) / 2.0; + float ym = (y1 + y2) / 2.0; + int rnew = recurseLevel + 1; + printf("Recursing to level %d\n", rnew); + + // 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 (%.10f, %.10f) -> (%.10f, %.10f)\n", x1, y2, x2, y2); + glBegin(GL_QUADS); + glVertex3f(x1, 0.0, y1); + glVertex3f(x1, 0.0, y2); + glVertex3f(x2, 0.0, y2); + glVertex3f(x2, 0.0, y1); + glEnd(); + } + +} + /** * Draw a floor. */ @@ -592,39 +623,10 @@ drawSquare(0, -10.0, -10.0, 10.0, 10.0); glEnable(GL_LIGHTING); } -int drawFloorRecurse = 2; /*void drawSquare(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2) { drawSquare(0, x1, y1, x2, y2); }*/ -void drawSquare(int recurseLevel, float x1, float y1, float x2, float y2) { - - printf("%d, %d, %d, %d\n", x1, y2, x2, y2); - - if ( drawFloorRecurse != recurseLevel ) { - float xm = (x1 + x2) / 2.0; - float ym = (y1 + y2) / 2.0; - int rnew = recurseLevel + 1; - printf("Recursing to level %d\n", rnew); - - // 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 (%.10f, %.10f) -> (%.10f, %.10f)\n", x1, y2, x2, y2); - glBegin(GL_QUADS); - glVertex3f(x1, 0.0, y1); - glVertex3f(x1, 0.0, y2); - glVertex3f(x2, 0.0, y2); - glVertex3f(x2, 0.0, y1); - glEnd(); - } - -} - /** * Display function */