From 2b94b8b523f570688bcf9671aa2a9498e8533023 Mon Sep 17 00:00:00 2001 From: josh Date: Sun, 3 Jun 2007 03:06:04 +0000 Subject: [PATCH] stl: working on the viewer more git-svn-id: svn://anubis/misc/stl@6 bd8a9e45-a331-0410-811e-c64571078777 --- stl-viewer.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/stl-viewer.c b/stl-viewer.c index f4f0462..2bc7b51 100644 --- a/stl-viewer.c +++ b/stl-viewer.c @@ -8,7 +8,7 @@ #define HEIGHT 500 stl_t * stl = NULL; -GLuint stldl; +GLuint stldl = 0; GLfloat default_color[] = {1, 1, 1, 1}; GLuint buildDL(void); @@ -28,12 +28,8 @@ void init(void) void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glBegin(GL_QUADS); - glVertex3f(-2.0, -1.0, 0.0); - glVertex3f(-2.0, 1.0, 0.0); - glVertex3f(0.0, 1.0, 0.0); - glVertex3f(0.0, -1.0, 0.0); - glEnd(); + if (stldl) + glCallList(stldl); SDL_GL_SwapBuffers(); } @@ -42,10 +38,10 @@ void reshape(GLsizei w, GLsizei h) glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); - gluPerspective(60.0, 1.0*(GLfloat)w/(GLfloat)h, 1.0, 30.0); + gluPerspective(60.0, 1.0*(GLfloat)w/(GLfloat)h, 1.0, 10000.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - glTranslatef(0.0, 0.0, -3.6); + glTranslatef(0.0, 0.0, -30); } int main(int argc, char *argv[]) @@ -63,7 +59,7 @@ int main(int argc, char *argv[]) return -2; } stldl = buildDL(); - + if (SDL_Init(SDL_INIT_VIDEO)) { fprintf(stderr, "Failed to initialize SDL!\n"); @@ -123,6 +119,7 @@ GLuint buildDL(void) else if (!dfltClrAct) glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, default_color); + glNormal3fv(stl_face(stl, i).normal); int j; for (j = 0; j < 3; j++) glVertex3fv(stl_face(stl, i).vertices[j]);