stl: viewer working

git-svn-id: svn://anubis/misc/stl@9 bd8a9e45-a331-0410-811e-c64571078777
This commit is contained in:
josh 2007-06-03 04:11:24 +00:00
parent f49335bf37
commit 09b6b4ee69

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, -3);
glTranslatef(0.0, 0.0, -10);
}
int main(int argc, char *argv[])
@ -81,6 +81,7 @@ int main(int argc, char *argv[])
reshape(WIDTH, HEIGHT);
display();
SDL_Event event;
int dragging = 0;
while (SDL_WaitEvent(&event))
{
if (event.type == SDL_QUIT)
@ -89,16 +90,25 @@ 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_MOUSEBUTTONDOWN)
{
if (event.button.button == 1)
dragging = 1;
}
else if (event.type == SDL_MOUSEUP)
else if (event.type == SDL_MOUSEBUTTONUP)
{
if (event.button.button == 1)
dragging = 0;
}
else if (event.type == SDL_MOUSEMOTION)
{
if (dragging)
{
glRotatef(event.motion.xrel, 0, 1, 0);
glRotatef(event.motion.yrel, 0, 0, 1);
display();
}
}
}
@ -119,7 +129,6 @@ GLuint buildDL(void)
glBegin(GL_TRIANGLES);
for (i = 0; i < n_faces; i++)
{
#if 0
if (stl_attr_color_valid(stl_face(stl, i).attribute))
{
color[0] = stl_attr_color_r(stl_face(stl, i).attribute) / (float) 255;
@ -131,7 +140,6 @@ GLuint buildDL(void)
else if (!dfltClrAct)
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE,
default_color);
#endif
stl_get_face_normal(stl, i, normal);
// printf("normal: %f, %f, %f\n",
// normal[0], normal[1], normal[2]);
@ -145,6 +153,7 @@ GLuint buildDL(void)
// stl_face(stl, i).vertices[j][2]);
glVertex3fv(stl_face(stl, i).vertices[j]);
}
// printf("attribute: 0x%x\n", stl_face(stl, i).attribute);
}
glEnd();
glEndList();