From: Ash Tyndall Date: Tue, 18 Oct 2011 11:30:06 +0000 (+0800) Subject: (no commit message) X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=9f1ff4bb4917d0dedec9d57c50d066a99d890241;p=atyndall%2Fcits2231.git --- diff --git a/scene.c b/scene.c index aa3967b..a2da934 100644 --- a/scene.c +++ b/scene.c @@ -583,6 +583,8 @@ void drawFloor() { glVertex3fv(floorVertices[3]); glEnd();*/ +drawSquare(0, -1000, -1000, 1000, 1000); + /*if (useTexture) { glDisable(GL_TEXTURE_2D); }*/ @@ -590,6 +592,32 @@ void drawFloor() { glEnable(GL_LIGHTING); } +int drawFloorRecurse = 10; +/*void drawSquare(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2) { + drawSquare(0, x1, y1, x2, y2); +}*/ + +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; + } + + drawSquare(recurseLevel + 1, x1, y1, xm, y2); + drawSquare(recurseLevel + 1, xm, y1, x2, y2); + } else { + 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 */