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:
parent
47911edec3
commit
f49335bf37
27
stl-viewer.c
27
stl-viewer.c
@ -41,7 +41,7 @@ void reshape(GLsizei w, GLsizei h)
|
|||||||
gluPerspective(60.0, 1.0*(GLfloat)w/(GLfloat)h, 1.0, 10000.0);
|
gluPerspective(60.0, 1.0*(GLfloat)w/(GLfloat)h, 1.0, 10000.0);
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glTranslatef(0.0, 0.0, -30);
|
glTranslatef(0.0, 0.0, -3);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
@ -58,7 +58,6 @@ int main(int argc, char *argv[])
|
|||||||
fprintf(stderr, "Error loading '%s'\n", argv[1]);
|
fprintf(stderr, "Error loading '%s'\n", argv[1]);
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
stldl = buildDL();
|
|
||||||
|
|
||||||
if (SDL_Init(SDL_INIT_VIDEO))
|
if (SDL_Init(SDL_INIT_VIDEO))
|
||||||
{
|
{
|
||||||
@ -77,6 +76,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
SDL_WM_SetCaption(argv[0], argv[0]);
|
SDL_WM_SetCaption(argv[0], argv[0]);
|
||||||
|
|
||||||
|
stldl = buildDL();
|
||||||
init();
|
init();
|
||||||
reshape(WIDTH, HEIGHT);
|
reshape(WIDTH, HEIGHT);
|
||||||
display();
|
display();
|
||||||
@ -89,6 +89,16 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
if (event.key.keysym.sym == SDLK_ESCAPE)
|
if (event.key.keysym.sym == SDLK_ESCAPE)
|
||||||
break;
|
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);
|
GLuint dl = glGenLists(1);
|
||||||
glNewList(dl, GL_COMPILE);
|
glNewList(dl, GL_COMPILE);
|
||||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, default_color);
|
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, default_color);
|
||||||
|
glBegin(GL_TRIANGLES);
|
||||||
for (i = 0; i < n_faces; i++)
|
for (i = 0; i < n_faces; i++)
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
@ -122,15 +133,19 @@ GLuint buildDL(void)
|
|||||||
default_color);
|
default_color);
|
||||||
#endif
|
#endif
|
||||||
stl_get_face_normal(stl, i, normal);
|
stl_get_face_normal(stl, i, normal);
|
||||||
printf("normal: %f, %f, %f\n",
|
// printf("normal: %f, %f, %f\n",
|
||||||
normal[0],
|
// normal[0], normal[1], normal[2]);
|
||||||
normal[1],
|
|
||||||
normal[2]);
|
|
||||||
glNormal3fv(normal);
|
glNormal3fv(normal);
|
||||||
int j;
|
int j;
|
||||||
for (j = 0; j < 3; 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]);
|
glVertex3fv(stl_face(stl, i).vertices[j]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
glEnd();
|
glEnd();
|
||||||
glEndList();
|
glEndList();
|
||||||
return dl;
|
return dl;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user