From 6f5b17c9cccc5ffa90dbccab465b1010504f8d75 Mon Sep 17 00:00:00 2001 From: Ash Tyndall Date: Tue, 18 Oct 2011 19:41:45 +0800 Subject: [PATCH] --- scene.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) 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); -- 2.20.1