X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=scene.c;h=64fcdb5959a2086e94a5fd7ce9b181894c6d51cb;hb=a452fcff3f30b458535e11d3d241d363bfc993b4;hp=aa3967bf518a0b83cc9a16a08d05f26226bb6ba2;hpb=fe0a6a8ae3ff8a57f0f92e6f9de8d7814886c94d;p=atyndall%2Fcits2231.git diff --git a/scene.c b/scene.c index aa3967b..64fcdb5 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,35 @@ 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) { + + printf("Recurse level %d", 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); + } else { + printf("Drawing (%f, %f) -> (%f, %f)\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 */