stl: fixed when the display list was being generated

git-svn-id: svn://anubis/misc/stl@8 bd8a9e45-a331-0410-811e-c64571078777
This commit is contained in:
josh 2007-06-03 03:35:41 +00:00
parent 47911edec3
commit f49335bf37

View File

@ -41,7 +41,7 @@ void reshape(GLsizei w, GLsizei h)
gluPerspective(60.0, 1.0*(GLfloat)w/(GLfloat)h, 1.0, 10000.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0, 0.0, -30);
glTranslatef(0.0, 0.0, -3);
}
int main(int argc, char *argv[])
@ -58,7 +58,6 @@ int main(int argc, char *argv[])
fprintf(stderr, "Error loading '%s'\n", argv[1]);
return -2;
}
stldl = buildDL();
if (SDL_Init(SDL_INIT_VIDEO))
{
@ -77,6 +76,7 @@ int main(int argc, char *argv[])
}
SDL_WM_SetCaption(argv[0], argv[0]);
stldl = buildDL();
init();
reshape(WIDTH, HEIGHT);
display();
@ -89,6 +89,16 @@ int main(int argc, char *argv[])
{
if (event.key.keysym.sym == SDLK_ESCAPE)
break;
else if
}
else if (event.type == SDL_MOUSEDOWN)
{
}
else if (event.type == SDL_MOUSEUP)
{
}
else if (event.type == SDL_MOUSEMOTION)
{
}
}
@ -106,6 +116,7 @@ GLuint buildDL(void)
GLuint dl = glGenLists(1);
glNewList(dl, GL_COMPILE);
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, default_color);
glBegin(GL_TRIANGLES);
for (i = 0; i < n_faces; i++)
{
#if 0
@ -122,14 +133,18 @@ GLuint buildDL(void)
default_color);
#endif
stl_get_face_normal(stl, i, normal);
printf("normal: %f, %f, %f\n",
normal[0],
normal[1],
normal[2]);
// printf("normal: %f, %f, %f\n",
// normal[0], normal[1], normal[2]);
glNormal3fv(normal);
int j;
for (j = 0; j < 3; j++)
{
// printf("vertex: %f, %f, %f\n",
// stl_face(stl, i).vertices[j][0],
// stl_face(stl, i).vertices[j][1],
// stl_face(stl, i).vertices[j][2]);
glVertex3fv(stl_face(stl, i).vertices[j]);
}
}
glEnd();
glEndList();