From 36ec1b47394620aa3126127e35ab829f18e5e738 Mon Sep 17 00:00:00 2001 From: Kamil Kaminski Date: Sun, 3 Oct 2010 16:37:22 -0500 Subject: pyramid: draw ground --- sdl/pyramid.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/sdl/pyramid.c b/sdl/pyramid.c index b25d073..b2c9696 100644 --- a/sdl/pyramid.c +++ b/sdl/pyramid.c @@ -159,6 +159,24 @@ void processEvents() } } +static void draw_ground(void) +{ + GLfloat fExtent = 20.0f; + GLfloat fStep = 0.5f; + GLfloat y = -0.4f; + GLfloat iLine; + + glBegin(GL_LINES); + for (iLine = -fExtent; iLine <= fExtent; iLine += fStep) + { + glVertex3f(iLine, y, fExtent); + glVertex3f(iLine, y, -fExtent); + glVertex3f(fExtent, y, iLine); + glVertex3f(-fExtent, y, iLine); + } + glEnd(); +} + static void render(void) { M3DVector3f vNormal; @@ -176,7 +194,7 @@ static void render(void) /* save the matrix state and do the rotations */ glPushMatrix(); /* move object back and do in place rotation */ - glTranslatef(0.0f, 0.4f, -4.0f); + glTranslatef(0.0f, 0.2f, -3.5f); glRotatef(xRot, 1.0f, 0.0f, 0.0f); glRotatef(yRot, 0.0f, 1.0f, 0.0f); @@ -244,6 +262,8 @@ static void render(void) /* restore the matrix state */ glPopMatrix(); + + draw_ground(); /* buffer swap */ SDL_GL_SwapBuffers(); -- cgit v1.2.3