From: Ash Tyndall Date: Tue, 18 Oct 2011 11:41:45 +0000 (+0800) Subject: (no commit message) X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=6f5b17c9cccc5ffa90dbccab465b1010504f8d75;p=atyndall%2Fcits2231.git --- diff --git a/scene.c b/scene.c index cc96c00..caa7f19 100644 --- a/scene.c +++ b/scene.c @@ -602,13 +602,16 @@ void drawSquare(int recurseLevel, GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 printf("Recurse level %d\n", recurseLevel); if ( drawFloorRecurse != recurseLevel ) { - GLfloat xm = (x2 - x1) / 2.0; - if ( x1 > x2 ) { - xm = (x1 - x2) / 2.0; - } - - drawSquare(recurseLevel + 1, x1, y1, xm, y2); - drawSquare(recurseLevel + 1, xm, y1, x2, y2); + 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);