From 9f1ff4bb4917d0dedec9d57c50d066a99d890241 Mon Sep 17 00:00:00 2001 From: Ash Tyndall Date: Tue, 18 Oct 2011 19:30:06 +0800 Subject: [PATCH] --- scene.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) 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 */ -- 2.20.1