stl: working on the viewer more

git-svn-id: svn://anubis/misc/stl@6 bd8a9e45-a331-0410-811e-c64571078777
This commit is contained in:
josh 2007-06-03 03:06:04 +00:00
parent ffe4f07ace
commit 2b94b8b523

View File

@ -8,7 +8,7 @@
#define HEIGHT 500 #define HEIGHT 500
stl_t * stl = NULL; stl_t * stl = NULL;
GLuint stldl; GLuint stldl = 0;
GLfloat default_color[] = {1, 1, 1, 1}; GLfloat default_color[] = {1, 1, 1, 1};
GLuint buildDL(void); GLuint buildDL(void);
@ -28,12 +28,8 @@ void init(void)
void display(void) void display(void)
{ {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glBegin(GL_QUADS); if (stldl)
glVertex3f(-2.0, -1.0, 0.0); glCallList(stldl);
glVertex3f(-2.0, 1.0, 0.0);
glVertex3f(0.0, 1.0, 0.0);
glVertex3f(0.0, -1.0, 0.0);
glEnd();
SDL_GL_SwapBuffers(); SDL_GL_SwapBuffers();
} }
@ -42,10 +38,10 @@ void reshape(GLsizei w, GLsizei h)
glViewport(0, 0, w, h); glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glLoadIdentity(); 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); glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); glLoadIdentity();
glTranslatef(0.0, 0.0, -3.6); glTranslatef(0.0, 0.0, -30);
} }
int main(int argc, char *argv[]) int main(int argc, char *argv[])
@ -63,7 +59,7 @@ int main(int argc, char *argv[])
return -2; return -2;
} }
stldl = buildDL(); stldl = buildDL();
if (SDL_Init(SDL_INIT_VIDEO)) if (SDL_Init(SDL_INIT_VIDEO))
{ {
fprintf(stderr, "Failed to initialize SDL!\n"); fprintf(stderr, "Failed to initialize SDL!\n");
@ -123,6 +119,7 @@ GLuint buildDL(void)
else if (!dfltClrAct) else if (!dfltClrAct)
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE,
default_color); default_color);
glNormal3fv(stl_face(stl, i).normal);
int j; int j;
for (j = 0; j < 3; j++) for (j = 0; j < 3; j++)
glVertex3fv(stl_face(stl, i).vertices[j]); glVertex3fv(stl_face(stl, i).vertices[j]);